diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae4ac3c..2ebaa42 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: publish: - needs: [compile, unit-tests] + needs: [compile] if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 9965de2..11014f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,477 +1,484 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Mono auto generated files -mono_crash.* - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Ww][Ii][Nn]32/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ -[Ll]ogs/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUnit -*.VisualState.xml -TestResult.xml -nunit-*.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET -project.lock.json -project.fragment.lock.json -artifacts/ - -# Tye -.tye/ - -# ASP.NET Scaffolding -ScaffoldingReadMe.txt - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.tlog -*.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 - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Coverlet is a free, cross platform Code Coverage Tool -coverage*.json -coverage*.xml -coverage*.info - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# 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 -# Note: 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 -# NuGet Symbol Packages -*.snupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable 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 -*.appx -*.appxbundle -*.appxupload - -# 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 -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# 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 -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- [Bb]ackup.rdl -*- [Bb]ackup ([0-9]).rdl -*- [Bb]ackup ([0-9][0-9]).rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio 6 auto-generated project file (contains which files were open etc.) -*.vbp - -# Visual Studio 6 workspace and project file (working project files containing files to include in project) -*.dsw -*.dsp - -# Visual Studio 6 technical files -*.ncb -*.aps - -# 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/ - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# Visual Studio History (VSHistory) files -.vshistory/ - -# BeatPulse healthcheck temp database -healthchecksdb - -# Backup folder for Package Reference Convert tool in Visual Studio 2017 -MigrationBackup/ - -# Ionide (cross platform F# VS Code tools) working folder -.ionide/ - -# Fody - auto-generated XML schema -FodyWeavers.xsd - -# VS Code files for those working on multiple tools -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -# Local History for Visual Studio Code -.history/ - -# Windows Installer files from build outputs -*.cab -*.msi -*.msix -*.msm -*.msp - -# JetBrains Rider -*.sln.iml - -## -## Visual studio for Mac -## - - -# globs -Makefile.in -*.userprefs -*.usertasks -config.make -config.status -aclocal.m4 -install-sh -autom4te.cache/ -*.tar.gz -tarballs/ -test-results/ - -# Mac bundle stuff -*.dmg -*.app - -# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore -# General -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - - -# Thumbnails -._* - -# Files that might appear in the root of a volume -.DocumentRevisions-V100 -.fseventsd -.Spotlight-V100 -.TemporaryItems -.Trashes -.VolumeIcon.icns -.com.apple.timemachine.donotpresent - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore -# Windows thumbnail cache files -Thumbs.db -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +## This is based on `dotnet new gitignore` and customized by Fern + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +# [Rr]elease/ (Ignored by Fern) +# [Rr]eleases/ (Ignored by Fern) +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +# [Ll]og/ (Ignored by Fern) +# [Ll]ogs/ (Ignored by Fern) + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.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 + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# 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 +# Note: 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 +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable 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 +*.appx +*.appxbundle +*.appxupload + +# 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 +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# 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 +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# 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/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..6731756 --- /dev/null +++ b/reference.md @@ -0,0 +1,6490 @@ +# Reference +
client.GetCompanyPlansAsync() +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.GetCompanyPlansAsync(); +``` +
+
+
+
+ + +
+
+
+ +## accounts +
client.Accounts.ListApiKeysAsync(ListApiKeysRequest { ... }) -> ListApiKeysResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.ListApiKeysAsync(new ListApiKeysRequest { RequireEnvironment = true }); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListApiKeysRequest` + +
+
+
+
+ + +
+
+
+ +
client.Accounts.CreateApiKeyAsync(CreateApiKeyRequestBody { ... }) -> CreateApiKeyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.CreateApiKeyAsync(new CreateApiKeyRequestBody { Name = "name" }); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateApiKeyRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Accounts.GetApiKeyAsync(apiKeyId) -> GetApiKeyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.GetApiKeyAsync("api_key_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**apiKeyId:** `string` — api_key_id + +
+
+
+
+ + +
+
+
+ +
client.Accounts.UpdateApiKeyAsync(apiKeyId, UpdateApiKeyRequestBody { ... }) -> UpdateApiKeyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.UpdateApiKeyAsync("api_key_id", new UpdateApiKeyRequestBody()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**apiKeyId:** `string` — api_key_id + +
+
+ +
+
+ +**request:** `UpdateApiKeyRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Accounts.DeleteApiKeyAsync(apiKeyId) -> DeleteApiKeyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.DeleteApiKeyAsync("api_key_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**apiKeyId:** `string` — api_key_id + +
+
+
+
+ + +
+
+
+ +
client.Accounts.CountApiKeysAsync(CountApiKeysRequest { ... }) -> CountApiKeysResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.CountApiKeysAsync(new CountApiKeysRequest { RequireEnvironment = true }); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountApiKeysRequest` + +
+
+
+
+ + +
+
+
+ +
client.Accounts.ListApiRequestsAsync(ListApiRequestsRequest { ... }) -> ListApiRequestsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.ListApiRequestsAsync(new ListApiRequestsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListApiRequestsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Accounts.GetApiRequestAsync(apiRequestId) -> GetApiRequestResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.GetApiRequestAsync("api_request_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**apiRequestId:** `string` — api_request_id + +
+
+
+
+ + +
+
+
+ +
client.Accounts.CountApiRequestsAsync(CountApiRequestsRequest { ... }) -> CountApiRequestsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.CountApiRequestsAsync(new CountApiRequestsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountApiRequestsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Accounts.ListEnvironmentsAsync(ListEnvironmentsRequest { ... }) -> ListEnvironmentsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.ListEnvironmentsAsync(new ListEnvironmentsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListEnvironmentsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Accounts.CreateEnvironmentAsync(CreateEnvironmentRequestBody { ... }) -> CreateEnvironmentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.CreateEnvironmentAsync( + new CreateEnvironmentRequestBody + { + EnvironmentType = CreateEnvironmentRequestBodyEnvironmentType.Development, + Name = "name", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateEnvironmentRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Accounts.GetEnvironmentAsync(environmentId) -> GetEnvironmentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.GetEnvironmentAsync("environment_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environmentId:** `string` — environment_id + +
+
+
+
+ + +
+
+
+ +
client.Accounts.UpdateEnvironmentAsync(environmentId, UpdateEnvironmentRequestBody { ... }) -> UpdateEnvironmentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.UpdateEnvironmentAsync("environment_id", new UpdateEnvironmentRequestBody()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environmentId:** `string` — environment_id + +
+
+ +
+
+ +**request:** `UpdateEnvironmentRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Accounts.DeleteEnvironmentAsync(environmentId) -> DeleteEnvironmentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accounts.DeleteEnvironmentAsync("environment_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**environmentId:** `string` — environment_id + +
+
+
+
+ + +
+
+
+ +## features +
client.Features.CountAudienceCompaniesAsync(AudienceRequestBody { ... }) -> CountAudienceCompaniesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.CountAudienceCompaniesAsync( + new AudienceRequestBody + { + ConditionGroups = new List() + { + new CreateOrUpdateConditionGroupRequestBody + { + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + }, + }, + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `AudienceRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.CountAudienceUsersAsync(AudienceRequestBody { ... }) -> CountAudienceUsersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.CountAudienceUsersAsync( + new AudienceRequestBody + { + ConditionGroups = new List() + { + new CreateOrUpdateConditionGroupRequestBody + { + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + }, + }, + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `AudienceRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.ListAudienceCompaniesAsync(AudienceRequestBody { ... }) -> ListAudienceCompaniesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.ListAudienceCompaniesAsync( + new AudienceRequestBody + { + ConditionGroups = new List() + { + new CreateOrUpdateConditionGroupRequestBody + { + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + }, + }, + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `AudienceRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.ListAudienceUsersAsync(AudienceRequestBody { ... }) -> ListAudienceUsersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.ListAudienceUsersAsync( + new AudienceRequestBody + { + ConditionGroups = new List() + { + new CreateOrUpdateConditionGroupRequestBody + { + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + }, + }, + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `AudienceRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.ListFeaturesAsync(ListFeaturesRequest { ... }) -> ListFeaturesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.ListFeaturesAsync(new ListFeaturesRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListFeaturesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Features.CreateFeatureAsync(CreateFeatureRequestBody { ... }) -> CreateFeatureResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.CreateFeatureAsync( + new CreateFeatureRequestBody + { + Description = "description", + FeatureType = CreateFeatureRequestBodyFeatureType.Boolean, + Name = "name", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateFeatureRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.GetFeatureAsync(featureId) -> GetFeatureResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.GetFeatureAsync("feature_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `string` — feature_id + +
+
+
+
+ + +
+
+
+ +
client.Features.UpdateFeatureAsync(featureId, UpdateFeatureRequestBody { ... }) -> UpdateFeatureResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.UpdateFeatureAsync("feature_id", new UpdateFeatureRequestBody()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `string` — feature_id + +
+
+ +
+
+ +**request:** `UpdateFeatureRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.DeleteFeatureAsync(featureId) -> DeleteFeatureResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.DeleteFeatureAsync("feature_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**featureId:** `string` — feature_id + +
+
+
+
+ + +
+
+
+ +
client.Features.CountFeaturesAsync(CountFeaturesRequest { ... }) -> CountFeaturesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.CountFeaturesAsync(new CountFeaturesRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountFeaturesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Features.ListFlagsAsync(ListFlagsRequest { ... }) -> ListFlagsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.ListFlagsAsync(new ListFlagsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListFlagsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Features.CreateFlagAsync(CreateFlagRequestBody { ... }) -> CreateFlagResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.CreateFlagAsync( + new CreateFlagRequestBody + { + DefaultValue = true, + Description = "description", + FlagType = "flag_type", + Key = "key", + Name = "name", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateFlagRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.GetFlagAsync(flagId) -> GetFlagResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.GetFlagAsync("flag_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flagId:** `string` — flag_id + +
+
+
+
+ + +
+
+
+ +
client.Features.UpdateFlagAsync(flagId, CreateFlagRequestBody { ... }) -> UpdateFlagResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.UpdateFlagAsync( + "flag_id", + new CreateFlagRequestBody + { + DefaultValue = true, + Description = "description", + FlagType = "flag_type", + Key = "key", + Name = "name", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flagId:** `string` — flag_id + +
+
+ +
+
+ +**request:** `CreateFlagRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.DeleteFlagAsync(flagId) -> DeleteFlagResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.DeleteFlagAsync("flag_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flagId:** `string` — flag_id + +
+
+
+
+ + +
+
+
+ +
client.Features.UpdateFlagRulesAsync(flagId, UpdateFlagRulesRequestBody { ... }) -> UpdateFlagRulesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.UpdateFlagRulesAsync( + "flag_id", + new UpdateFlagRulesRequestBody + { + Rules = new List() + { + new CreateOrUpdateRuleRequestBody + { + ConditionGroups = new List() + { + new CreateOrUpdateConditionGroupRequestBody + { + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = + CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + }, + }, + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + Name = "name", + Priority = 1, + Value = true, + }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**flagId:** `string` — flag_id + +
+
+ +
+
+ +**request:** `UpdateFlagRulesRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.CheckFlagAsync(key, CheckFlagRequestBody { ... }) -> CheckFlagResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.CheckFlagAsync("key", new CheckFlagRequestBody()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**key:** `string` — key + +
+
+ +
+
+ +**request:** `CheckFlagRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.CheckFlagsAsync(CheckFlagRequestBody { ... }) -> CheckFlagsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.CheckFlagsAsync(new CheckFlagRequestBody()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CheckFlagRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Features.CountFlagsAsync(CountFlagsRequest { ... }) -> CountFlagsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Features.CountFlagsAsync(new CountFlagsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountFlagsRequest` + +
+
+
+
+ + +
+
+
+ +## billing +
client.Billing.UpsertBillingCouponAsync(CreateCouponRequestBody { ... }) -> UpsertBillingCouponResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.UpsertBillingCouponAsync( + new CreateCouponRequestBody + { + AmountOff = 1, + Duration = "duration", + DurationInMonths = 1, + ExternalId = "external_id", + MaxRedemptions = 1, + Name = "name", + PercentOff = 1.1, + TimesRedeemed = 1, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateCouponRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Billing.UpsertBillingCustomerAsync(CreateBillingCustomerRequestBody { ... }) -> UpsertBillingCustomerResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.UpsertBillingCustomerAsync( + new CreateBillingCustomerRequestBody + { + Email = "email", + ExternalId = "external_id", + FailedToImport = true, + Meta = new Dictionary() { { "key", "value" } }, + Name = "name", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateBillingCustomerRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Billing.ListCustomersAsync(ListCustomersRequest { ... }) -> ListCustomersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.ListCustomersAsync(new ListCustomersRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListCustomersRequest` + +
+
+
+
+ + +
+
+
+ +
client.Billing.CountCustomersAsync(CountCustomersRequest { ... }) -> CountCustomersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.CountCustomersAsync(new CountCustomersRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountCustomersRequest` + +
+
+
+
+ + +
+
+
+ +
client.Billing.ListInvoicesAsync(ListInvoicesRequest { ... }) -> ListInvoicesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.ListInvoicesAsync( + new ListInvoicesRequest { CustomerExternalId = "customer_external_id" } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListInvoicesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Billing.UpsertInvoiceAsync(CreateInvoiceRequestBody { ... }) -> UpsertInvoiceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.UpsertInvoiceAsync( + new CreateInvoiceRequestBody + { + AmountDue = 1, + AmountPaid = 1, + AmountRemaining = 1, + CollectionMethod = "collection_method", + Currency = "currency", + CustomerExternalId = "customer_external_id", + Subtotal = 1, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateInvoiceRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Billing.ListMetersAsync(ListMetersRequest { ... }) -> ListMetersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.ListMetersAsync(new ListMetersRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListMetersRequest` + +
+
+
+
+ + +
+
+
+ +
client.Billing.UpsertBillingMeterAsync(CreateMeterRequestBody { ... }) -> UpsertBillingMeterResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.UpsertBillingMeterAsync( + new CreateMeterRequestBody + { + DisplayName = "display_name", + EventName = "event_name", + EventPayloadKey = "event_payload_key", + ExternalId = "external_id", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateMeterRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Billing.ListPaymentMethodsAsync(ListPaymentMethodsRequest { ... }) -> ListPaymentMethodsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.ListPaymentMethodsAsync( + new ListPaymentMethodsRequest { CustomerExternalId = "customer_external_id" } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListPaymentMethodsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Billing.UpsertPaymentMethodAsync(CreatePaymentMethodRequestBody { ... }) -> UpsertPaymentMethodResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.UpsertPaymentMethodAsync( + new CreatePaymentMethodRequestBody + { + CustomerExternalId = "customer_external_id", + ExternalId = "external_id", + PaymentMethodType = "payment_method_type", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreatePaymentMethodRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Billing.SearchBillingPricesAsync(SearchBillingPricesRequest { ... }) -> SearchBillingPricesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.SearchBillingPricesAsync(new SearchBillingPricesRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `SearchBillingPricesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Billing.UpsertBillingPriceAsync(CreateBillingPriceRequestBody { ... }) -> UpsertBillingPriceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.UpsertBillingPriceAsync( + new CreateBillingPriceRequestBody + { + Currency = "currency", + Interval = "interval", + Price = 1, + PriceExternalId = "price_external_id", + ProductExternalId = "product_external_id", + UsageType = "usage_type", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateBillingPriceRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Billing.ListProductPricesAsync(ListProductPricesRequest { ... }) -> ListProductPricesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.ListProductPricesAsync(new ListProductPricesRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListProductPricesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Billing.DeleteProductPriceAsync(billingId) -> DeleteProductPriceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.DeleteProductPriceAsync("billing_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**billingId:** `string` — billing_id + +
+
+
+
+ + +
+
+
+ +
client.Billing.UpsertBillingProductAsync(CreateBillingProductRequestBody { ... }) -> UpsertBillingProductResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.UpsertBillingProductAsync( + new CreateBillingProductRequestBody + { + Currency = "currency", + ExternalId = "external_id", + Name = "name", + Price = 1.1, + Quantity = 1, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateBillingProductRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Billing.ListBillingProductsAsync(ListBillingProductsRequest { ... }) -> ListBillingProductsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.ListBillingProductsAsync(new ListBillingProductsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListBillingProductsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Billing.CountBillingProductsAsync(CountBillingProductsRequest { ... }) -> CountBillingProductsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.CountBillingProductsAsync(new CountBillingProductsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountBillingProductsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Billing.UpsertBillingSubscriptionAsync(CreateBillingSubscriptionsRequestBody { ... }) -> UpsertBillingSubscriptionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Billing.UpsertBillingSubscriptionAsync( + new CreateBillingSubscriptionsRequestBody + { + Currency = "currency", + CustomerExternalId = "customer_external_id", + Discounts = new List() + { + new BillingSubscriptionDiscount + { + CouponExternalId = "coupon_external_id", + ExternalId = "external_id", + IsActive = true, + StartedAt = new DateTime(2024, 01, 15, 09, 30, 00, 000), + }, + }, + ExpiredAt = new DateTime(2024, 01, 15, 09, 30, 00, 000), + ProductExternalIds = new List() + { + new BillingProductPricing + { + Currency = "currency", + Interval = "interval", + Price = 1, + PriceExternalId = "price_external_id", + ProductExternalId = "product_external_id", + Quantity = 1, + UsageType = "usage_type", + }, + }, + SubscriptionExternalId = "subscription_external_id", + TotalPrice = 1, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateBillingSubscriptionsRequestBody` + +
+
+
+
+ + +
+
+
+ +## checkout +
client.Checkout.InternalAsync(ChangeSubscriptionInternalRequestBody { ... }) -> CheckoutInternalResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Checkout.InternalAsync( + new ChangeSubscriptionInternalRequestBody + { + AddOnIds = new List() + { + new UpdateAddOnRequestBody { AddOnId = "add_on_id", PriceId = "price_id" }, + }, + CompanyId = "company_id", + NewPlanId = "new_plan_id", + NewPriceId = "new_price_id", + PayInAdvance = new List() + { + new UpdatePayInAdvanceRequestBody { PriceId = "price_id", Quantity = 1 }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ChangeSubscriptionInternalRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Checkout.PreviewCheckoutInternalAsync(ChangeSubscriptionInternalRequestBody { ... }) -> PreviewCheckoutInternalResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Checkout.PreviewCheckoutInternalAsync( + new ChangeSubscriptionInternalRequestBody + { + AddOnIds = new List() + { + new UpdateAddOnRequestBody { AddOnId = "add_on_id", PriceId = "price_id" }, + }, + CompanyId = "company_id", + NewPlanId = "new_plan_id", + NewPriceId = "new_price_id", + PayInAdvance = new List() + { + new UpdatePayInAdvanceRequestBody { PriceId = "price_id", Quantity = 1 }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ChangeSubscriptionInternalRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Checkout.UpdateCustomerSubscriptionTrialEndAsync(subscriptionId, UpdateTrialEndRequestBody { ... }) -> UpdateCustomerSubscriptionTrialEndResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Checkout.UpdateCustomerSubscriptionTrialEndAsync( + "subscription_id", + new UpdateTrialEndRequestBody() +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**subscriptionId:** `string` — subscription_id + +
+
+ +
+
+ +**request:** `UpdateTrialEndRequestBody` + +
+
+
+
+ + +
+
+
+ +## companies +
client.Companies.ListCompaniesAsync(ListCompaniesRequest { ... }) -> ListCompaniesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.ListCompaniesAsync(new ListCompaniesRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListCompaniesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.UpsertCompanyAsync(UpsertCompanyRequestBody { ... }) -> UpsertCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.UpsertCompanyAsync( + new UpsertCompanyRequestBody { Keys = new Dictionary() { { "key", "value" } } } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertCompanyRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.GetCompanyAsync(companyId) -> GetCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.GetCompanyAsync("company_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `string` — company_id + +
+
+
+
+ + +
+
+
+ +
client.Companies.DeleteCompanyAsync(companyId) -> DeleteCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.DeleteCompanyAsync("company_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyId:** `string` — company_id + +
+
+
+
+ + +
+
+
+ +
client.Companies.CountCompaniesAsync(CountCompaniesRequest { ... }) -> CountCompaniesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.CountCompaniesAsync(new CountCompaniesRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountCompaniesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.CreateCompanyAsync(UpsertCompanyRequestBody { ... }) -> CreateCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.CreateCompanyAsync( + new UpsertCompanyRequestBody { Keys = new Dictionary() { { "key", "value" } } } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertCompanyRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.DeleteCompanyByKeysAsync(KeysRequestBody { ... }) -> DeleteCompanyByKeysResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.DeleteCompanyByKeysAsync( + new KeysRequestBody { Keys = new Dictionary() { { "key", "value" } } } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `KeysRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.LookupCompanyAsync(LookupCompanyRequest { ... }) -> LookupCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.LookupCompanyAsync( + new LookupCompanyRequest + { + Keys = new Dictionary() + { + { + "keys", + new Dictionary() { { "key", "value" } } + }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `LookupCompanyRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.GetActiveDealsAsync(GetActiveDealsRequest { ... }) -> GetActiveDealsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.GetActiveDealsAsync( + new GetActiveDealsRequest { CompanyId = "company_id", DealStage = "deal_stage" } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `GetActiveDealsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.ListCompanyMembershipsAsync(ListCompanyMembershipsRequest { ... }) -> ListCompanyMembershipsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.ListCompanyMembershipsAsync(new ListCompanyMembershipsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListCompanyMembershipsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.GetOrCreateCompanyMembershipAsync(GetOrCreateCompanyMembershipRequestBody { ... }) -> GetOrCreateCompanyMembershipResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.GetOrCreateCompanyMembershipAsync( + new GetOrCreateCompanyMembershipRequestBody { CompanyId = "company_id", UserId = "user_id" } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `GetOrCreateCompanyMembershipRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.DeleteCompanyMembershipAsync(companyMembershipId) -> DeleteCompanyMembershipResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.DeleteCompanyMembershipAsync("company_membership_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyMembershipId:** `string` — company_membership_id + +
+
+
+
+ + +
+
+
+ +
client.Companies.GetActiveCompanySubscriptionAsync(GetActiveCompanySubscriptionRequest { ... }) -> GetActiveCompanySubscriptionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.GetActiveCompanySubscriptionAsync(new GetActiveCompanySubscriptionRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `GetActiveCompanySubscriptionRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.UpsertCompanyTraitAsync(UpsertTraitRequestBody { ... }) -> UpsertCompanyTraitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.UpsertCompanyTraitAsync( + new UpsertTraitRequestBody + { + Keys = new Dictionary() { { "key", "value" } }, + Trait = "trait", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertTraitRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.ListEntityKeyDefinitionsAsync(ListEntityKeyDefinitionsRequest { ... }) -> ListEntityKeyDefinitionsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.ListEntityKeyDefinitionsAsync(new ListEntityKeyDefinitionsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListEntityKeyDefinitionsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.CountEntityKeyDefinitionsAsync(CountEntityKeyDefinitionsRequest { ... }) -> CountEntityKeyDefinitionsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.CountEntityKeyDefinitionsAsync(new CountEntityKeyDefinitionsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountEntityKeyDefinitionsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.ListEntityTraitDefinitionsAsync(ListEntityTraitDefinitionsRequest { ... }) -> ListEntityTraitDefinitionsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.ListEntityTraitDefinitionsAsync(new ListEntityTraitDefinitionsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListEntityTraitDefinitionsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.GetOrCreateEntityTraitDefinitionAsync(CreateEntityTraitDefinitionRequestBody { ... }) -> GetOrCreateEntityTraitDefinitionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.GetOrCreateEntityTraitDefinitionAsync( + new CreateEntityTraitDefinitionRequestBody + { + EntityType = CreateEntityTraitDefinitionRequestBodyEntityType.Company, + Hierarchy = new List() { "hierarchy" }, + TraitType = CreateEntityTraitDefinitionRequestBodyTraitType.Boolean, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateEntityTraitDefinitionRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.GetEntityTraitDefinitionAsync(entityTraitDefinitionId) -> GetEntityTraitDefinitionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.GetEntityTraitDefinitionAsync("entity_trait_definition_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityTraitDefinitionId:** `string` — entity_trait_definition_id + +
+
+
+
+ + +
+
+
+ +
client.Companies.UpdateEntityTraitDefinitionAsync(entityTraitDefinitionId, UpdateEntityTraitDefinitionRequestBody { ... }) -> UpdateEntityTraitDefinitionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.UpdateEntityTraitDefinitionAsync( + "entity_trait_definition_id", + new UpdateEntityTraitDefinitionRequestBody + { + TraitType = UpdateEntityTraitDefinitionRequestBodyTraitType.Boolean, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**entityTraitDefinitionId:** `string` — entity_trait_definition_id + +
+
+ +
+
+ +**request:** `UpdateEntityTraitDefinitionRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.CountEntityTraitDefinitionsAsync(CountEntityTraitDefinitionsRequest { ... }) -> CountEntityTraitDefinitionsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.CountEntityTraitDefinitionsAsync(new CountEntityTraitDefinitionsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountEntityTraitDefinitionsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.GetEntityTraitValuesAsync(GetEntityTraitValuesRequest { ... }) -> GetEntityTraitValuesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.GetEntityTraitValuesAsync( + new GetEntityTraitValuesRequest { DefinitionId = "definition_id" } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `GetEntityTraitValuesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.UpsertUserTraitAsync(UpsertTraitRequestBody { ... }) -> UpsertUserTraitResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.UpsertUserTraitAsync( + new UpsertTraitRequestBody + { + Keys = new Dictionary() { { "key", "value" } }, + Trait = "trait", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertTraitRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.ListUsersAsync(ListUsersRequest { ... }) -> ListUsersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.ListUsersAsync(new ListUsersRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListUsersRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.UpsertUserAsync(UpsertUserRequestBody { ... }) -> UpsertUserResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.UpsertUserAsync( + new UpsertUserRequestBody + { + Company = new Dictionary() { { "key", "value" } }, + Keys = new Dictionary() { { "key", "value" } }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertUserRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.GetUserAsync(userId) -> GetUserResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.GetUserAsync("user_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**userId:** `string` — user_id + +
+
+
+
+ + +
+
+
+ +
client.Companies.DeleteUserAsync(userId) -> DeleteUserResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.DeleteUserAsync("user_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**userId:** `string` — user_id + +
+
+
+
+ + +
+
+
+ +
client.Companies.CountUsersAsync(CountUsersRequest { ... }) -> CountUsersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.CountUsersAsync(new CountUsersRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountUsersRequest` + +
+
+
+
+ + +
+
+
+ +
client.Companies.CreateUserAsync(UpsertUserRequestBody { ... }) -> CreateUserResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.CreateUserAsync( + new UpsertUserRequestBody + { + Company = new Dictionary() { { "key", "value" } }, + Keys = new Dictionary() { { "key", "value" } }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `UpsertUserRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.DeleteUserByKeysAsync(KeysRequestBody { ... }) -> DeleteUserByKeysResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.DeleteUserByKeysAsync( + new KeysRequestBody { Keys = new Dictionary() { { "key", "value" } } } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `KeysRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Companies.LookupUserAsync(LookupUserRequest { ... }) -> LookupUserResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Companies.LookupUserAsync( + new LookupUserRequest + { + Keys = new Dictionary() + { + { + "keys", + new Dictionary() { { "key", "value" } } + }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `LookupUserRequest` + +
+
+
+
+ + +
+
+
+ +## entitlements +
client.Entitlements.ListCompanyOverridesAsync(ListCompanyOverridesRequest { ... }) -> ListCompanyOverridesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.ListCompanyOverridesAsync(new ListCompanyOverridesRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListCompanyOverridesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.CreateCompanyOverrideAsync(CreateCompanyOverrideRequestBody { ... }) -> CreateCompanyOverrideResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.CreateCompanyOverrideAsync( + new CreateCompanyOverrideRequestBody + { + CompanyId = "company_id", + FeatureId = "feature_id", + ValueType = CreateCompanyOverrideRequestBodyValueType.Boolean, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateCompanyOverrideRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.GetCompanyOverrideAsync(companyOverrideId) -> GetCompanyOverrideResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.GetCompanyOverrideAsync("company_override_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyOverrideId:** `string` — company_override_id + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.UpdateCompanyOverrideAsync(companyOverrideId, UpdateCompanyOverrideRequestBody { ... }) -> UpdateCompanyOverrideResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.UpdateCompanyOverrideAsync( + "company_override_id", + new UpdateCompanyOverrideRequestBody + { + ValueType = UpdateCompanyOverrideRequestBodyValueType.Boolean, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyOverrideId:** `string` — company_override_id + +
+
+ +
+
+ +**request:** `UpdateCompanyOverrideRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.DeleteCompanyOverrideAsync(companyOverrideId) -> DeleteCompanyOverrideResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.DeleteCompanyOverrideAsync("company_override_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**companyOverrideId:** `string` — company_override_id + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.CountCompanyOverridesAsync(CountCompanyOverridesRequest { ... }) -> CountCompanyOverridesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.CountCompanyOverridesAsync(new CountCompanyOverridesRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountCompanyOverridesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.ListFeatureCompaniesAsync(ListFeatureCompaniesRequest { ... }) -> ListFeatureCompaniesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.ListFeatureCompaniesAsync( + new ListFeatureCompaniesRequest { FeatureId = "feature_id" } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListFeatureCompaniesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.CountFeatureCompaniesAsync(CountFeatureCompaniesRequest { ... }) -> CountFeatureCompaniesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.CountFeatureCompaniesAsync( + new CountFeatureCompaniesRequest { FeatureId = "feature_id" } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountFeatureCompaniesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.ListFeatureUsageAsync(ListFeatureUsageRequest { ... }) -> ListFeatureUsageResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.ListFeatureUsageAsync(new ListFeatureUsageRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListFeatureUsageRequest` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.CountFeatureUsageAsync(CountFeatureUsageRequest { ... }) -> CountFeatureUsageResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.CountFeatureUsageAsync(new CountFeatureUsageRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountFeatureUsageRequest` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.ListFeatureUsersAsync(ListFeatureUsersRequest { ... }) -> ListFeatureUsersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.ListFeatureUsersAsync( + new ListFeatureUsersRequest { FeatureId = "feature_id" } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListFeatureUsersRequest` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.CountFeatureUsersAsync(CountFeatureUsersRequest { ... }) -> CountFeatureUsersResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.CountFeatureUsersAsync( + new CountFeatureUsersRequest { FeatureId = "feature_id" } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountFeatureUsersRequest` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.ListPlanEntitlementsAsync(ListPlanEntitlementsRequest { ... }) -> ListPlanEntitlementsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.ListPlanEntitlementsAsync(new ListPlanEntitlementsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListPlanEntitlementsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.CreatePlanEntitlementAsync(CreatePlanEntitlementRequestBody { ... }) -> CreatePlanEntitlementResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.CreatePlanEntitlementAsync( + new CreatePlanEntitlementRequestBody + { + FeatureId = "feature_id", + PlanId = "plan_id", + ValueType = CreatePlanEntitlementRequestBodyValueType.Boolean, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreatePlanEntitlementRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.GetPlanEntitlementAsync(planEntitlementId) -> GetPlanEntitlementResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.GetPlanEntitlementAsync("plan_entitlement_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planEntitlementId:** `string` — plan_entitlement_id + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.UpdatePlanEntitlementAsync(planEntitlementId, UpdatePlanEntitlementRequestBody { ... }) -> UpdatePlanEntitlementResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.UpdatePlanEntitlementAsync( + "plan_entitlement_id", + new UpdatePlanEntitlementRequestBody + { + ValueType = UpdatePlanEntitlementRequestBodyValueType.Boolean, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planEntitlementId:** `string` — plan_entitlement_id + +
+
+ +
+
+ +**request:** `UpdatePlanEntitlementRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.DeletePlanEntitlementAsync(planEntitlementId) -> DeletePlanEntitlementResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.DeletePlanEntitlementAsync("plan_entitlement_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planEntitlementId:** `string` — plan_entitlement_id + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.CountPlanEntitlementsAsync(CountPlanEntitlementsRequest { ... }) -> CountPlanEntitlementsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.CountPlanEntitlementsAsync(new CountPlanEntitlementsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountPlanEntitlementsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Entitlements.GetFeatureUsageByCompanyAsync(GetFeatureUsageByCompanyRequest { ... }) -> GetFeatureUsageByCompanyResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Entitlements.GetFeatureUsageByCompanyAsync( + new GetFeatureUsageByCompanyRequest + { + Keys = new Dictionary() + { + { + "keys", + new Dictionary() { { "key", "value" } } + }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `GetFeatureUsageByCompanyRequest` + +
+
+
+
+ + +
+
+
+ +## components +
client.Components.ListComponentsAsync(ListComponentsRequest { ... }) -> ListComponentsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Components.ListComponentsAsync(new ListComponentsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListComponentsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Components.CreateComponentAsync(CreateComponentRequestBody { ... }) -> CreateComponentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Components.CreateComponentAsync( + new CreateComponentRequestBody + { + EntityType = CreateComponentRequestBodyEntityType.Entitlement, + Name = "name", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateComponentRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Components.GetComponentAsync(componentId) -> GetComponentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Components.GetComponentAsync("component_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**componentId:** `string` — component_id + +
+
+
+
+ + +
+
+
+ +
client.Components.UpdateComponentAsync(componentId, UpdateComponentRequestBody { ... }) -> UpdateComponentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Components.UpdateComponentAsync("component_id", new UpdateComponentRequestBody()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**componentId:** `string` — component_id + +
+
+ +
+
+ +**request:** `UpdateComponentRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Components.DeleteComponentAsync(componentId) -> DeleteComponentResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Components.DeleteComponentAsync("component_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**componentId:** `string` — component_id + +
+
+
+
+ + +
+
+
+ +
client.Components.CountComponentsAsync(CountComponentsRequest { ... }) -> CountComponentsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Components.CountComponentsAsync(new CountComponentsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountComponentsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Components.PreviewComponentDataAsync(PreviewComponentDataRequest { ... }) -> PreviewComponentDataResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Components.PreviewComponentDataAsync(new PreviewComponentDataRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `PreviewComponentDataRequest` + +
+
+
+
+ + +
+
+
+ +## crm +
client.Crm.UpsertDealLineItemAssociationAsync(CreateCrmDealLineItemAssociationRequestBody { ... }) -> UpsertDealLineItemAssociationResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Crm.UpsertDealLineItemAssociationAsync( + new CreateCrmDealLineItemAssociationRequestBody + { + DealExternalId = "deal_external_id", + LineItemExternalId = "line_item_external_id", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateCrmDealLineItemAssociationRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Crm.UpsertLineItemAsync(CreateCrmLineItemRequestBody { ... }) -> UpsertLineItemResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Crm.UpsertLineItemAsync( + new CreateCrmLineItemRequestBody + { + Amount = "amount", + Interval = "interval", + LineItemExternalId = "line_item_external_id", + ProductExternalId = "product_external_id", + Quantity = 1, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateCrmLineItemRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Crm.UpsertCrmDealAsync(CreateCrmDealRequestBody { ... }) -> UpsertCrmDealResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Crm.UpsertCrmDealAsync( + new CreateCrmDealRequestBody + { + CrmCompanyKey = "crm_company_key", + CrmType = "crm_type", + DealExternalId = "deal_external_id", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateCrmDealRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Crm.ListCrmProductsAsync(ListCrmProductsRequest { ... }) -> ListCrmProductsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Crm.ListCrmProductsAsync(new ListCrmProductsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListCrmProductsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Crm.UpsertCrmProductAsync(CreateCrmProductRequestBody { ... }) -> UpsertCrmProductResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Crm.UpsertCrmProductAsync( + new CreateCrmProductRequestBody + { + Currency = "currency", + Description = "description", + ExternalId = "external_id", + Interval = "interval", + Name = "name", + Price = "price", + Quantity = 1, + Sku = "sku", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateCrmProductRequestBody` + +
+
+
+
+ + +
+
+
+ +## events +
client.Events.CreateEventBatchAsync(CreateEventBatchRequestBody { ... }) -> CreateEventBatchResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Events.CreateEventBatchAsync( + new CreateEventBatchRequestBody + { + Events = new List() + { + new CreateEventRequestBody { EventType = CreateEventRequestBodyEventType.Identify }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateEventBatchRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Events.GetEventSummariesAsync(GetEventSummariesRequest { ... }) -> GetEventSummariesResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Events.GetEventSummariesAsync(new GetEventSummariesRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `GetEventSummariesRequest` + +
+
+
+
+ + +
+
+
+ +
client.Events.ListEventsAsync(ListEventsRequest { ... }) -> ListEventsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Events.ListEventsAsync(new ListEventsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListEventsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Events.CreateEventAsync(CreateEventRequestBody { ... }) -> CreateEventResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Events.CreateEventAsync( + new CreateEventRequestBody { EventType = CreateEventRequestBodyEventType.Identify } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateEventRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Events.GetEventAsync(eventId) -> GetEventResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Events.GetEventAsync("event_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**eventId:** `string` — event_id + +
+
+
+
+ + +
+
+
+ +
client.Events.GetSegmentIntegrationStatusAsync() -> GetSegmentIntegrationStatusResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Events.GetSegmentIntegrationStatusAsync(); +``` +
+
+
+
+ + +
+
+
+ +## plans +
client.Plans.GetAudienceAsync(planAudienceId) -> GetAudienceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plans.GetAudienceAsync("plan_audience_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planAudienceId:** `string` — plan_audience_id + +
+
+
+
+ + +
+
+
+ +
client.Plans.UpdateAudienceAsync(planAudienceId, UpdateAudienceRequestBody { ... }) -> UpdateAudienceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plans.UpdateAudienceAsync( + "plan_audience_id", + new UpdateAudienceRequestBody + { + ConditionGroups = new List() + { + new CreateOrUpdateConditionGroupRequestBody + { + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + }, + }, + Conditions = new List() + { + new CreateOrUpdateConditionRequestBody + { + ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + ResourceIds = new List() { "resource_ids" }, + }, + }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planAudienceId:** `string` — plan_audience_id + +
+
+ +
+
+ +**request:** `UpdateAudienceRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Plans.DeleteAudienceAsync(planAudienceId) -> DeleteAudienceResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plans.DeleteAudienceAsync("plan_audience_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planAudienceId:** `string` — plan_audience_id + +
+
+
+
+ + +
+
+
+ +
client.Plans.ListPlansAsync(ListPlansRequest { ... }) -> ListPlansResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plans.ListPlansAsync(new ListPlansRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListPlansRequest` + +
+
+
+
+ + +
+
+
+ +
client.Plans.CreatePlanAsync(CreatePlanRequestBody { ... }) -> CreatePlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plans.CreatePlanAsync( + new CreatePlanRequestBody + { + Description = "description", + Name = "name", + PlanType = CreatePlanRequestBodyPlanType.Plan, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreatePlanRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Plans.GetPlanAsync(planId) -> GetPlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plans.GetPlanAsync("plan_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `string` — plan_id + +
+
+
+
+ + +
+
+
+ +
client.Plans.UpdatePlanAsync(planId, UpdatePlanRequestBody { ... }) -> UpdatePlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plans.UpdatePlanAsync("plan_id", new UpdatePlanRequestBody { Name = "name" }); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `string` — plan_id + +
+
+ +
+
+ +**request:** `UpdatePlanRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Plans.DeletePlanAsync(planId) -> DeletePlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plans.DeletePlanAsync("plan_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `string` — plan_id + +
+
+
+
+ + +
+
+
+ +
client.Plans.UpsertBillingProductPlanAsync(planId, UpsertBillingProductRequestBody { ... }) -> UpsertBillingProductPlanResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plans.UpsertBillingProductPlanAsync( + "plan_id", + new UpsertBillingProductRequestBody { IsFreePlan = true, IsTrialable = true } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planId:** `string` — plan_id + +
+
+ +
+
+ +**request:** `UpsertBillingProductRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Plans.CountPlansAsync(CountPlansRequest { ... }) -> CountPlansResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plans.CountPlansAsync(new CountPlansRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountPlansRequest` + +
+
+
+
+ + +
+
+
+ +## plangroups +
client.Plangroups.GetPlanGroupAsync() -> GetPlanGroupResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plangroups.GetPlanGroupAsync(); +``` +
+
+
+
+ + +
+
+
+ +
client.Plangroups.CreatePlanGroupAsync(CreatePlanGroupRequestBody { ... }) -> CreatePlanGroupResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plangroups.CreatePlanGroupAsync( + new CreatePlanGroupRequestBody + { + AddOnIds = new List() { "add_on_ids" }, + PlanIds = new List() { "plan_ids" }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreatePlanGroupRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Plangroups.UpdatePlanGroupAsync(planGroupId, UpdatePlanGroupRequestBody { ... }) -> UpdatePlanGroupResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Plangroups.UpdatePlanGroupAsync( + "plan_group_id", + new UpdatePlanGroupRequestBody + { + AddOnIds = new List() { "add_on_ids" }, + PlanIds = new List() { "plan_ids" }, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**planGroupId:** `string` — plan_group_id + +
+
+ +
+
+ +**request:** `UpdatePlanGroupRequestBody` + +
+
+
+
+ + +
+
+
+ +## accesstokens +
client.Accesstokens.IssueTemporaryAccessTokenAsync(IssueTemporaryAccessTokenRequestBody { ... }) -> IssueTemporaryAccessTokenResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Accesstokens.IssueTemporaryAccessTokenAsync( + new IssueTemporaryAccessTokenRequestBody + { + Lookup = new Dictionary() { { "key", "value" } }, + ResourceType = "resource_type", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `IssueTemporaryAccessTokenRequestBody` + +
+
+
+
+ + +
+
+
+ +## webhooks +
client.Webhooks.ListWebhookEventsAsync(ListWebhookEventsRequest { ... }) -> ListWebhookEventsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Webhooks.ListWebhookEventsAsync(new ListWebhookEventsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListWebhookEventsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Webhooks.GetWebhookEventAsync(webhookEventId) -> GetWebhookEventResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Webhooks.GetWebhookEventAsync("webhook_event_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookEventId:** `string` — webhook_event_id + +
+
+
+
+ + +
+
+
+ +
client.Webhooks.CountWebhookEventsAsync(CountWebhookEventsRequest { ... }) -> CountWebhookEventsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Webhooks.CountWebhookEventsAsync(new CountWebhookEventsRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountWebhookEventsRequest` + +
+
+
+
+ + +
+
+
+ +
client.Webhooks.ListWebhooksAsync(ListWebhooksRequest { ... }) -> ListWebhooksResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Webhooks.ListWebhooksAsync(new ListWebhooksRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListWebhooksRequest` + +
+
+
+
+ + +
+
+
+ +
client.Webhooks.CreateWebhookAsync(CreateWebhookRequestBody { ... }) -> CreateWebhookResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Webhooks.CreateWebhookAsync( + new CreateWebhookRequestBody + { + Name = "name", + RequestTypes = new List() + { + CreateWebhookRequestBodyRequestTypesItem.CompanyUpdated, + }, + Url = "url", + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CreateWebhookRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Webhooks.GetWebhookAsync(webhookId) -> GetWebhookResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Webhooks.GetWebhookAsync("webhook_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookId:** `string` — webhook_id + +
+
+
+
+ + +
+
+
+ +
client.Webhooks.UpdateWebhookAsync(webhookId, UpdateWebhookRequestBody { ... }) -> UpdateWebhookResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Webhooks.UpdateWebhookAsync("webhook_id", new UpdateWebhookRequestBody()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookId:** `string` — webhook_id + +
+
+ +
+
+ +**request:** `UpdateWebhookRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Webhooks.DeleteWebhookAsync(webhookId) -> DeleteWebhookResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Webhooks.DeleteWebhookAsync("webhook_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**webhookId:** `string` — webhook_id + +
+
+
+
+ + +
+
+
+ +
client.Webhooks.CountWebhooksAsync(CountWebhooksRequest { ... }) -> CountWebhooksResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Webhooks.CountWebhooksAsync(new CountWebhooksRequest()); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `CountWebhooksRequest` + +
+
+
+
+ + +
+
+
diff --git a/src/SchematicHQ.Client.Test/Core/EnumSerializerTests.cs b/src/SchematicHQ.Client.Test/Core/EnumSerializerTests.cs new file mode 100644 index 0000000..f131c16 --- /dev/null +++ b/src/SchematicHQ.Client.Test/Core/EnumSerializerTests.cs @@ -0,0 +1,61 @@ +using System; +using System.Runtime.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; +using NUnit.Framework; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client.Test.Core +{ + [TestFixture] + public class StringEnumSerializerTests + { + private static readonly JsonSerializerOptions JsonOptions = new() { WriteIndented = true }; + + private const DummyEnum KnownEnumValue2 = DummyEnum.KnownValue2; + private const string KnownEnumValue2String = "known_value2"; + + private static readonly string JsonWithKnownEnum2 = $$""" + { + "enum_property": "{{KnownEnumValue2String}}" + } + """; + + [Test] + public void ShouldParseKnownEnumValue2() + { + var obj = JsonSerializer.Deserialize(JsonWithKnownEnum2, JsonOptions); + Assert.That(obj, Is.Not.Null); + Assert.That(obj.EnumProperty, Is.EqualTo(KnownEnumValue2)); + } + + [Test] + public void ShouldSerializeKnownEnumValue2() + { + var json = JsonSerializer.SerializeToElement( + new DummyObject { EnumProperty = KnownEnumValue2 }, + JsonOptions + ); + TestContext.WriteLine("Serialized JSON: \n" + json); + var enumString = json.GetProperty("enum_property").GetString(); + Assert.That(enumString, Is.Not.Null); + Assert.That(enumString, Is.EqualTo(KnownEnumValue2String)); + } + } + + public class DummyObject + { + [JsonPropertyName("enum_property")] + public DummyEnum EnumProperty { get; set; } + } + + [JsonConverter(typeof(EnumSerializer))] + public enum DummyEnum + { + [EnumMember(Value = "known_value1")] + KnownValue1, + + [EnumMember(Value = "known_value2")] + KnownValue2, + } +} diff --git a/src/SchematicHQ.Client.Test/Core/RawClientTests.cs b/src/SchematicHQ.Client.Test/Core/RawClientTests.cs new file mode 100644 index 0000000..4675999 --- /dev/null +++ b/src/SchematicHQ.Client.Test/Core/RawClientTests.cs @@ -0,0 +1,113 @@ +using System; +using System.Net.Http; +using FluentAssertions; +using NUnit.Framework; +using SchematicHQ.Client.Core; +using WireMock.Server; +using SystemTask = System.Threading.Tasks.Task; +using WireMockRequest = WireMock.RequestBuilders.Request; +using WireMockResponse = WireMock.ResponseBuilders.Response; + +namespace SchematicHQ.Client.Test.Core +{ + [TestFixture] + public class RawClientTests + { + private WireMockServer _server; + private HttpClient _httpClient; + private RawClient _rawClient; + private string _baseUrl; + private const int _maxRetries = 3; + + [SetUp] + public void SetUp() + { + _server = WireMockServer.Start(); + _baseUrl = _server.Url ?? ""; + _httpClient = new HttpClient { BaseAddress = new Uri(_baseUrl) }; + _rawClient = new RawClient( + new ClientOptions() { HttpClient = _httpClient, MaxRetries = _maxRetries } + ); + } + + [Test] + [TestCase(408)] + [TestCase(429)] + [TestCase(500)] + [TestCase(504)] + public async SystemTask MakeRequestAsync_ShouldRetry_OnRetryableStatusCodes(int statusCode) + { + _server + .Given(WireMockRequest.Create().WithPath("/test").UsingGet()) + .InScenario("Retry") + .WillSetStateTo("Server Error") + .RespondWith(WireMockResponse.Create().WithStatusCode(statusCode)); + + _server + .Given(WireMockRequest.Create().WithPath("/test").UsingGet()) + .InScenario("Retry") + .WhenStateIs("Server Error") + .WillSetStateTo("Success") + .RespondWith(WireMockResponse.Create().WithStatusCode(statusCode)); + + _server + .Given(WireMockRequest.Create().WithPath("/test").UsingGet()) + .InScenario("Retry") + .WhenStateIs("Success") + .RespondWith(WireMockResponse.Create().WithStatusCode(200).WithBody("Success")); + + var request = new RawClient.BaseApiRequest + { + BaseUrl = _baseUrl, + Method = HttpMethod.Get, + Path = "/test", + }; + + var response = await _rawClient.MakeRequestAsync(request); + Assert.That(response.StatusCode, Is.EqualTo(200)); + + var content = await response.Raw.Content.ReadAsStringAsync(); + Assert.That(content, Is.EqualTo("Success")); + + Assert.That(_server.LogEntries.Count, Is.EqualTo(_maxRetries)); + } + + [Test] + [TestCase(400)] + [TestCase(409)] + public async SystemTask MakeRequestAsync_ShouldRetry_OnNonRetryableStatusCodes( + int statusCode + ) + { + _server + .Given(WireMockRequest.Create().WithPath("/test").UsingGet()) + .InScenario("Retry") + .WillSetStateTo("Server Error") + .RespondWith( + WireMockResponse.Create().WithStatusCode(statusCode).WithBody("Failure") + ); + + var request = new RawClient.BaseApiRequest + { + BaseUrl = _baseUrl, + Method = HttpMethod.Get, + Path = "/test", + }; + + var response = await _rawClient.MakeRequestAsync(request); + Assert.That(response.StatusCode, Is.EqualTo(statusCode)); + + var content = await response.Raw.Content.ReadAsStringAsync(); + Assert.That(content, Is.EqualTo("Failure")); + + Assert.That(_server.LogEntries.Count, Is.EqualTo(1)); + } + + [TearDown] + public void TearDown() + { + _server.Dispose(); + _httpClient.Dispose(); + } + } +} diff --git a/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.Custom.props b/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.Custom.props new file mode 100644 index 0000000..55e683b --- /dev/null +++ b/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.Custom.props @@ -0,0 +1,7 @@ + + + \ No newline at end of file diff --git a/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.csproj b/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.csproj index 48a5bcf..2a2d56a 100644 --- a/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.csproj +++ b/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.csproj @@ -15,10 +15,13 @@ + + - + + \ No newline at end of file diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ApiErrorTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ApiErrorTest.cs deleted file mode 100644 index f028972..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ApiErrorTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ApiErrorTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyCreateResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyCreateResponseDataTest.cs deleted file mode 100644 index 12d1f51..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyCreateResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ApiKeyCreateResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyRequestListResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyRequestListResponseDataTest.cs deleted file mode 100644 index ceb3632..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyRequestListResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ApiKeyRequestListResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyRequestResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyRequestResponseDataTest.cs deleted file mode 100644 index e927303..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyRequestResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ApiKeyRequestResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyResponseDataTest.cs deleted file mode 100644 index f47d9f3..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ApiKeyResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ApiKeyResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/AudienceRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/AudienceRequestBodyTest.cs deleted file mode 100644 index c797a5c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/AudienceRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class AudienceRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingCustomerResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingCustomerResponseDataTest.cs deleted file mode 100644 index ef8479f..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingCustomerResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingCustomerResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingCustomerSubscriptionTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingCustomerSubscriptionTest.cs deleted file mode 100644 index a1faae2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingCustomerSubscriptionTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingCustomerSubscriptionTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingCustomerWithSubscriptionsResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingCustomerWithSubscriptionsResponseDataTest.cs deleted file mode 100644 index b945837..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingCustomerWithSubscriptionsResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingCustomerWithSubscriptionsResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingPlanGroupResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingPlanGroupResponseDataTest.cs deleted file mode 100644 index 3bf6ae8..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingPlanGroupResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingPlanGroupResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingPlanTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingPlanTest.cs deleted file mode 100644 index 95027f1..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingPlanTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingPlanTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingPriceResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingPriceResponseDataTest.cs deleted file mode 100644 index 175953b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingPriceResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingPriceResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductDetailResponseDataTest.cs deleted file mode 100644 index 6075d71..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingProductDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductForSubscriptionResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductForSubscriptionResponseDataTest.cs deleted file mode 100644 index 1b8e29b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductForSubscriptionResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingProductForSubscriptionResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductPlanResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductPlanResponseDataTest.cs deleted file mode 100644 index 2c33422..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductPlanResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingProductPlanResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductPricingTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductPricingTest.cs deleted file mode 100644 index 94ebcb8..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductPricingTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingProductPricingTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductResponseDataTest.cs deleted file mode 100644 index 2847bcd..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingProductResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingProductResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingSubscriptionResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/BillingSubscriptionResponseDataTest.cs deleted file mode 100644 index 5a92b6c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/BillingSubscriptionResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class BillingSubscriptionResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagOutputWithFlagKeyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagOutputWithFlagKeyTest.cs deleted file mode 100644 index 9d10b5b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagOutputWithFlagKeyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CheckFlagOutputWithFlagKeyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagRequestBodyTest.cs deleted file mode 100644 index c10f7b2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CheckFlagRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagResponseDataTest.cs deleted file mode 100644 index 41f6530..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CheckFlagResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagResponseTest.cs deleted file mode 100644 index 323fb6d..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CheckFlagResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagsResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagsResponseDataTest.cs deleted file mode 100644 index f6d90b5..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagsResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CheckFlagsResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagsResponseTest.cs deleted file mode 100644 index c4b4a33..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CheckFlagsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CheckFlagsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyCrmDealsResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyCrmDealsResponseDataTest.cs deleted file mode 100644 index 7dcd24a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyCrmDealsResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CompanyCrmDealsResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyDetailResponseDataTest.cs deleted file mode 100644 index 2d9998a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CompanyDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyMembershipDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyMembershipDetailResponseDataTest.cs deleted file mode 100644 index dbb1ccc..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyMembershipDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CompanyMembershipDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyMembershipResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyMembershipResponseDataTest.cs deleted file mode 100644 index 5b1fc1a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyMembershipResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CompanyMembershipResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyOverrideResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyOverrideResponseDataTest.cs deleted file mode 100644 index cea1932..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyOverrideResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CompanyOverrideResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyResponseDataTest.cs deleted file mode 100644 index 9474cdf..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanyResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CompanyResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanySubscriptionResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CompanySubscriptionResponseDataTest.cs deleted file mode 100644 index 10d47ee..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CompanySubscriptionResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CompanySubscriptionResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ComponentResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ComponentResponseDataTest.cs deleted file mode 100644 index e137d9e..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ComponentResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ComponentResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiKeysParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiKeysParamsTest.cs deleted file mode 100644 index da876e9..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiKeysParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountApiKeysParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiKeysResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiKeysResponseTest.cs deleted file mode 100644 index b401cc9..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiKeysResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountApiKeysResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiRequestsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiRequestsParamsTest.cs deleted file mode 100644 index a4dfc52..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiRequestsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountApiRequestsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiRequestsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiRequestsResponseTest.cs deleted file mode 100644 index e33c199..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountApiRequestsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountApiRequestsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountAudienceCompaniesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountAudienceCompaniesResponseTest.cs deleted file mode 100644 index fa28caa..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountAudienceCompaniesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountAudienceCompaniesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountAudienceUsersResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountAudienceUsersResponseTest.cs deleted file mode 100644 index c24e2e3..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountAudienceUsersResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountAudienceUsersResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompaniesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompaniesParamsTest.cs deleted file mode 100644 index 3c6c576..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompaniesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountCompaniesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompaniesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompaniesResponseTest.cs deleted file mode 100644 index b7e5ba3..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompaniesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountCompaniesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompanyOverridesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompanyOverridesParamsTest.cs deleted file mode 100644 index 8744c8e..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompanyOverridesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountCompanyOverridesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompanyOverridesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompanyOverridesResponseTest.cs deleted file mode 100644 index d019727..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCompanyOverridesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountCompanyOverridesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountComponentsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountComponentsParamsTest.cs deleted file mode 100644 index ce7f7f2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountComponentsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountComponentsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountComponentsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountComponentsResponseTest.cs deleted file mode 100644 index 0dd51cf..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountComponentsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountComponentsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCustomersParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountCustomersParamsTest.cs deleted file mode 100644 index 0a07554..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCustomersParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountCustomersParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCustomersResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountCustomersResponseTest.cs deleted file mode 100644 index 2594328..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountCustomersResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountCustomersResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityKeyDefinitionsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityKeyDefinitionsParamsTest.cs deleted file mode 100644 index 79d4de1..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityKeyDefinitionsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountEntityKeyDefinitionsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityKeyDefinitionsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityKeyDefinitionsResponseTest.cs deleted file mode 100644 index 35ead7c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityKeyDefinitionsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountEntityKeyDefinitionsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityTraitDefinitionsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityTraitDefinitionsParamsTest.cs deleted file mode 100644 index 9e03dfb..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityTraitDefinitionsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountEntityTraitDefinitionsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityTraitDefinitionsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityTraitDefinitionsResponseTest.cs deleted file mode 100644 index 3c12753..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountEntityTraitDefinitionsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountEntityTraitDefinitionsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureCompaniesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureCompaniesParamsTest.cs deleted file mode 100644 index abe8e34..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureCompaniesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountFeatureCompaniesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureCompaniesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureCompaniesResponseTest.cs deleted file mode 100644 index eefcbc5..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureCompaniesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountFeatureCompaniesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsageParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsageParamsTest.cs deleted file mode 100644 index 5d2e72a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsageParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountFeatureUsageParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsageResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsageResponseTest.cs deleted file mode 100644 index 4059ec0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsageResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountFeatureUsageResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsersParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsersParamsTest.cs deleted file mode 100644 index 5c12966..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsersParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountFeatureUsersParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsersResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsersResponseTest.cs deleted file mode 100644 index e0844cd..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeatureUsersResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountFeatureUsersResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeaturesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeaturesParamsTest.cs deleted file mode 100644 index a15c0f7..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeaturesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountFeaturesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeaturesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeaturesResponseTest.cs deleted file mode 100644 index 4eb34e0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFeaturesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountFeaturesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFlagsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountFlagsParamsTest.cs deleted file mode 100644 index e538afb..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFlagsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountFlagsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFlagsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountFlagsResponseTest.cs deleted file mode 100644 index b9d8f57..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountFlagsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountFlagsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlanEntitlementsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlanEntitlementsParamsTest.cs deleted file mode 100644 index 86fd154..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlanEntitlementsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountPlanEntitlementsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlanEntitlementsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlanEntitlementsResponseTest.cs deleted file mode 100644 index f64521a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlanEntitlementsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountPlanEntitlementsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlansParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlansParamsTest.cs deleted file mode 100644 index b68b5f9..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlansParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountPlansParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlansResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlansResponseTest.cs deleted file mode 100644 index 83975b9..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountPlansResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountPlansResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountResponseTest.cs deleted file mode 100644 index 8b98c68..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountUsersParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountUsersParamsTest.cs deleted file mode 100644 index be2126c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountUsersParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountUsersParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountUsersResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountUsersResponseTest.cs deleted file mode 100644 index 9249332..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountUsersResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountUsersResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhookEventsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhookEventsParamsTest.cs deleted file mode 100644 index df4496a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhookEventsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountWebhookEventsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhookEventsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhookEventsResponseTest.cs deleted file mode 100644 index 95cb9e1..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhookEventsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountWebhookEventsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhooksParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhooksParamsTest.cs deleted file mode 100644 index 56a1728..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhooksParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountWebhooksParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhooksResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhooksResponseTest.cs deleted file mode 100644 index 9565f6f..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CountWebhooksResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CountWebhooksResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateApiKeyResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateApiKeyResponseTest.cs deleted file mode 100644 index 16defdc..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateApiKeyResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateApiKeyResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateBillingPlanGroupResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateBillingPlanGroupResponseTest.cs deleted file mode 100644 index 188e132..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateBillingPlanGroupResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateBillingPlanGroupResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateCompanyOverrideResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateCompanyOverrideResponseTest.cs deleted file mode 100644 index 475da1b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateCompanyOverrideResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateCompanyOverrideResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateCompanyResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateCompanyResponseTest.cs deleted file mode 100644 index 637bf78..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateCompanyResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateCompanyResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateComponentResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateComponentResponseTest.cs deleted file mode 100644 index f3292a8..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateComponentResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateComponentResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEnvironmentResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEnvironmentResponseTest.cs deleted file mode 100644 index e335ccc..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEnvironmentResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateEnvironmentResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEventBatchResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEventBatchResponseTest.cs deleted file mode 100644 index ce15d1f..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEventBatchResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateEventBatchResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEventRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEventRequestBodyTest.cs deleted file mode 100644 index 5565d4d..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEventRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateEventRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEventResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEventResponseTest.cs deleted file mode 100644 index ac6d73a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateEventResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateEventResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateFeatureResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateFeatureResponseTest.cs deleted file mode 100644 index d27bb6f..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateFeatureResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateFeatureResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateFlagRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateFlagRequestBodyTest.cs deleted file mode 100644 index 850b208..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateFlagRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateFlagRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateFlagResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateFlagResponseTest.cs deleted file mode 100644 index 04af4a0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateFlagResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateFlagResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateConditionGroupRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateConditionGroupRequestBodyTest.cs deleted file mode 100644 index d684b9a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateConditionGroupRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateOrUpdateConditionGroupRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateConditionRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateConditionRequestBodyTest.cs deleted file mode 100644 index 26da7d3..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateConditionRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateOrUpdateConditionRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateFlagRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateFlagRequestBodyTest.cs deleted file mode 100644 index 43e2b03..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateFlagRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateOrUpdateFlagRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateRuleRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateRuleRequestBodyTest.cs deleted file mode 100644 index cccf053..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateOrUpdateRuleRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateOrUpdateRuleRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreatePlanEntitlementResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreatePlanEntitlementResponseTest.cs deleted file mode 100644 index 30a606d..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreatePlanEntitlementResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreatePlanEntitlementResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreatePlanResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreatePlanResponseTest.cs deleted file mode 100644 index 0d6c159..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreatePlanResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreatePlanResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateReqCommonTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateReqCommonTest.cs deleted file mode 100644 index 2e94097..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateReqCommonTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateReqCommonTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateUserResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateUserResponseTest.cs deleted file mode 100644 index a5cbeaa..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateUserResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateUserResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateWebhookResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CreateWebhookResponseTest.cs deleted file mode 100644 index 0dac35b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CreateWebhookResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CreateWebhookResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CrmDealLineItemTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CrmDealLineItemTest.cs deleted file mode 100644 index 079202e..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CrmDealLineItemTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CrmDealLineItemTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CrmDealResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CrmDealResponseDataTest.cs deleted file mode 100644 index 2066302..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CrmDealResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CrmDealResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CrmLineItemResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CrmLineItemResponseDataTest.cs deleted file mode 100644 index 467242e..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CrmLineItemResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CrmLineItemResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/CrmProductResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/CrmProductResponseDataTest.cs deleted file mode 100644 index 7f203d6..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/CrmProductResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class CrmProductResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteApiKeyResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteApiKeyResponseTest.cs deleted file mode 100644 index a3e446c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteApiKeyResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteApiKeyResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteAudienceResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteAudienceResponseTest.cs deleted file mode 100644 index efe2f7a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteAudienceResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteAudienceResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyByKeysResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyByKeysResponseTest.cs deleted file mode 100644 index 875e67a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyByKeysResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteCompanyByKeysResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyMembershipResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyMembershipResponseTest.cs deleted file mode 100644 index 46b6b16..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyMembershipResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteCompanyMembershipResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyOverrideResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyOverrideResponseTest.cs deleted file mode 100644 index 944920a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyOverrideResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteCompanyOverrideResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyResponseTest.cs deleted file mode 100644 index 7858f50..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteCompanyResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteCompanyResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteComponentResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteComponentResponseTest.cs deleted file mode 100644 index 81e69fe..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteComponentResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteComponentResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteEnvironmentResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteEnvironmentResponseTest.cs deleted file mode 100644 index 973495a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteEnvironmentResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteEnvironmentResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteFeatureResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteFeatureResponseTest.cs deleted file mode 100644 index 61d66e0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteFeatureResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteFeatureResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteFlagResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteFlagResponseTest.cs deleted file mode 100644 index dfd1014..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteFlagResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteFlagResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeletePlanEntitlementResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeletePlanEntitlementResponseTest.cs deleted file mode 100644 index 6a3c623..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeletePlanEntitlementResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeletePlanEntitlementResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeletePlanResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeletePlanResponseTest.cs deleted file mode 100644 index 514779a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeletePlanResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeletePlanResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteResponseTest.cs deleted file mode 100644 index 681878c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteUserByKeysResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteUserByKeysResponseTest.cs deleted file mode 100644 index b393cb0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteUserByKeysResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteUserByKeysResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteUserResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteUserResponseTest.cs deleted file mode 100644 index 8582dbd..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteUserResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteUserResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteWebhookResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteWebhookResponseTest.cs deleted file mode 100644 index c641714..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/DeleteWebhookResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class DeleteWebhookResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityKeyDefinitionResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EntityKeyDefinitionResponseDataTest.cs deleted file mode 100644 index 440bbd6..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityKeyDefinitionResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EntityKeyDefinitionResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityKeyDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EntityKeyDetailResponseDataTest.cs deleted file mode 100644 index 96818aa..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityKeyDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EntityKeyDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityKeyResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EntityKeyResponseDataTest.cs deleted file mode 100644 index 7f680da..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityKeyResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EntityKeyResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitDefinitionResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitDefinitionResponseDataTest.cs deleted file mode 100644 index 75c0d38..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitDefinitionResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EntityTraitDefinitionResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitDetailResponseDataTest.cs deleted file mode 100644 index 3e77541..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EntityTraitDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitResponseDataTest.cs deleted file mode 100644 index ef78941..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EntityTraitResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitValueTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitValueTest.cs deleted file mode 100644 index 7531263..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EntityTraitValueTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EntityTraitValueTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EnvironmentDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EnvironmentDetailResponseDataTest.cs deleted file mode 100644 index 3f40715..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EnvironmentDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EnvironmentDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EnvironmentResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EnvironmentResponseDataTest.cs deleted file mode 100644 index e89160b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EnvironmentResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EnvironmentResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyFlagCheckTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyFlagCheckTest.cs deleted file mode 100644 index b517bf0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyFlagCheckTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EventBodyFlagCheckTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyIdentifyCompanyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyIdentifyCompanyTest.cs deleted file mode 100644 index 23135d5..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyIdentifyCompanyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EventBodyIdentifyCompanyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyIdentifyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyIdentifyTest.cs deleted file mode 100644 index abb09f6..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyIdentifyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EventBodyIdentifyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyTrackTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyTrackTest.cs deleted file mode 100644 index 083ca2d..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EventBodyTrackTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EventBodyTrackTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EventDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EventDetailResponseDataTest.cs deleted file mode 100644 index f6e6cd8..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EventDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EventDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EventResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EventResponseDataTest.cs deleted file mode 100644 index b66d214..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EventResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EventResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/EventSummaryResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/EventSummaryResponseDataTest.cs deleted file mode 100644 index a78000c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/EventSummaryResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class EventSummaryResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureCompanyResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureCompanyResponseDataTest.cs deleted file mode 100644 index 015ef66..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureCompanyResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class FeatureCompanyResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureCompanyUserResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureCompanyUserResponseDataTest.cs deleted file mode 100644 index 9a3228a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureCompanyUserResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class FeatureCompanyUserResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureDetailResponseDataTest.cs deleted file mode 100644 index aa55474..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class FeatureDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureResponseDataTest.cs deleted file mode 100644 index 4fb1d62..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class FeatureResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureUsageDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureUsageDetailResponseDataTest.cs deleted file mode 100644 index bc7be5d..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureUsageDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class FeatureUsageDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureUsageResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureUsageResponseDataTest.cs deleted file mode 100644 index ebb8616..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/FeatureUsageResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class FeatureUsageResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/FlagDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/FlagDetailResponseDataTest.cs deleted file mode 100644 index 39f6062..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/FlagDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class FlagDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/FlagResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/FlagResponseDataTest.cs deleted file mode 100644 index e94bfd0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/FlagResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class FlagResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveCompanySubscriptionParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveCompanySubscriptionParamsTest.cs deleted file mode 100644 index 7eb035f..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveCompanySubscriptionParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetActiveCompanySubscriptionParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveCompanySubscriptionResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveCompanySubscriptionResponseTest.cs deleted file mode 100644 index 4ae0b32..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveCompanySubscriptionResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetActiveCompanySubscriptionResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveDealsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveDealsParamsTest.cs deleted file mode 100644 index 23a0a24..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveDealsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetActiveDealsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveDealsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveDealsResponseTest.cs deleted file mode 100644 index ad6a5d1..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetActiveDealsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetActiveDealsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetApiKeyResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetApiKeyResponseTest.cs deleted file mode 100644 index 747ec42..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetApiKeyResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetApiKeyResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetApiRequestResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetApiRequestResponseTest.cs deleted file mode 100644 index d88aa7b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetApiRequestResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetApiRequestResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetAudienceResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetAudienceResponseTest.cs deleted file mode 100644 index 8f5841b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetAudienceResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetAudienceResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetBillingPlanGroupByAccountIdResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetBillingPlanGroupByAccountIdResponseTest.cs deleted file mode 100644 index e726e50..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetBillingPlanGroupByAccountIdResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetBillingPlanGroupByAccountIdResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetCompanyOverrideResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetCompanyOverrideResponseTest.cs deleted file mode 100644 index 563a67e..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetCompanyOverrideResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetCompanyOverrideResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetCompanyResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetCompanyResponseTest.cs deleted file mode 100644 index f934242..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetCompanyResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetCompanyResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetComponentResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetComponentResponseTest.cs deleted file mode 100644 index 88154fb..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetComponentResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetComponentResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEntityTraitDefinitionResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetEntityTraitDefinitionResponseTest.cs deleted file mode 100644 index 058a78f..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEntityTraitDefinitionResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetEntityTraitDefinitionResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEntityTraitValuesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetEntityTraitValuesParamsTest.cs deleted file mode 100644 index 64e6444..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEntityTraitValuesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetEntityTraitValuesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEntityTraitValuesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetEntityTraitValuesResponseTest.cs deleted file mode 100644 index f2efbe9..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEntityTraitValuesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetEntityTraitValuesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEnvironmentResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetEnvironmentResponseTest.cs deleted file mode 100644 index 3461d2b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEnvironmentResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetEnvironmentResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventResponseTest.cs deleted file mode 100644 index 4c2c407..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetEventResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventSummariesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventSummariesParamsTest.cs deleted file mode 100644 index 75dd5dd..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventSummariesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetEventSummariesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventSummariesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventSummariesResponseTest.cs deleted file mode 100644 index 5c8345a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventSummariesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetEventSummariesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventSummaryBySubtypeResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventSummaryBySubtypeResponseTest.cs deleted file mode 100644 index eda436b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetEventSummaryBySubtypeResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetEventSummaryBySubtypeResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetFeatureResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetFeatureResponseTest.cs deleted file mode 100644 index 47bcc0c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetFeatureResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetFeatureResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetFeatureUsageByCompanyParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetFeatureUsageByCompanyParamsTest.cs deleted file mode 100644 index 6fa0c05..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetFeatureUsageByCompanyParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetFeatureUsageByCompanyParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetFeatureUsageByCompanyResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetFeatureUsageByCompanyResponseTest.cs deleted file mode 100644 index 99abc53..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetFeatureUsageByCompanyResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetFeatureUsageByCompanyResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetFlagResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetFlagResponseTest.cs deleted file mode 100644 index 1e1c0b9..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetFlagResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetFlagResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetOrCreateCompanyMembershipResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetOrCreateCompanyMembershipResponseTest.cs deleted file mode 100644 index 4686ed7..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetOrCreateCompanyMembershipResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetOrCreateCompanyMembershipResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetOrCreateEntityTraitDefinitionResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetOrCreateEntityTraitDefinitionResponseTest.cs deleted file mode 100644 index c792d27..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetOrCreateEntityTraitDefinitionResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetOrCreateEntityTraitDefinitionResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetPlanEntitlementResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetPlanEntitlementResponseTest.cs deleted file mode 100644 index 5e69945..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetPlanEntitlementResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetPlanEntitlementResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetPlanResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetPlanResponseTest.cs deleted file mode 100644 index 53121cf..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetPlanResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetPlanResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetSegmentIntegrationStatusResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetSegmentIntegrationStatusResponseTest.cs deleted file mode 100644 index f925c88..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetSegmentIntegrationStatusResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetSegmentIntegrationStatusResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetUserResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetUserResponseTest.cs deleted file mode 100644 index 684a2df..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetUserResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetUserResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetWebhookEventResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetWebhookEventResponseTest.cs deleted file mode 100644 index 0d6677d..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetWebhookEventResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetWebhookEventResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/GetWebhookResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/GetWebhookResponseTest.cs deleted file mode 100644 index 285ed01..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/GetWebhookResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class GetWebhookResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/IssueTemporaryAccessTokenResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/IssueTemporaryAccessTokenResponseDataTest.cs deleted file mode 100644 index 4083887..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/IssueTemporaryAccessTokenResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class IssueTemporaryAccessTokenResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/IssueTemporaryAccessTokenResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/IssueTemporaryAccessTokenResponseTest.cs deleted file mode 100644 index 5c8f19d..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/IssueTemporaryAccessTokenResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class IssueTemporaryAccessTokenResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/KeysRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/KeysRequestBodyTest.cs deleted file mode 100644 index 8c4034d..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/KeysRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class KeysRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiKeysParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiKeysParamsTest.cs deleted file mode 100644 index 3887640..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiKeysParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListApiKeysParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiKeysResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiKeysResponseTest.cs deleted file mode 100644 index c5d8d5a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiKeysResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListApiKeysResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiRequestsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiRequestsParamsTest.cs deleted file mode 100644 index e04285e..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiRequestsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListApiRequestsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiRequestsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiRequestsResponseTest.cs deleted file mode 100644 index 5e8f4ef..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListApiRequestsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListApiRequestsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListAudienceCompaniesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListAudienceCompaniesResponseTest.cs deleted file mode 100644 index c4ff124..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListAudienceCompaniesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListAudienceCompaniesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListAudienceUsersResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListAudienceUsersResponseTest.cs deleted file mode 100644 index 01f726b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListAudienceUsersResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListAudienceUsersResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListBillingProductsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListBillingProductsParamsTest.cs deleted file mode 100644 index 72eae05..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListBillingProductsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListBillingProductsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListBillingProductsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListBillingProductsResponseTest.cs deleted file mode 100644 index c5420b8..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListBillingProductsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListBillingProductsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompaniesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompaniesParamsTest.cs deleted file mode 100644 index a19046a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompaniesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListCompaniesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompaniesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompaniesResponseTest.cs deleted file mode 100644 index 5c820c2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompaniesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListCompaniesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyMembershipsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyMembershipsParamsTest.cs deleted file mode 100644 index 9eacfa2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyMembershipsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListCompanyMembershipsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyMembershipsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyMembershipsResponseTest.cs deleted file mode 100644 index f6fd704..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyMembershipsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListCompanyMembershipsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyOverridesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyOverridesParamsTest.cs deleted file mode 100644 index f12150d..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyOverridesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListCompanyOverridesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyOverridesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyOverridesResponseTest.cs deleted file mode 100644 index 41428c4..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCompanyOverridesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListCompanyOverridesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListComponentsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListComponentsParamsTest.cs deleted file mode 100644 index c14bd2c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListComponentsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListComponentsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListComponentsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListComponentsResponseTest.cs deleted file mode 100644 index b15be21..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListComponentsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListComponentsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCrmProductsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListCrmProductsParamsTest.cs deleted file mode 100644 index 4cd34e2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCrmProductsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListCrmProductsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCrmProductsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListCrmProductsResponseTest.cs deleted file mode 100644 index aed157b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCrmProductsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListCrmProductsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCustomersParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListCustomersParamsTest.cs deleted file mode 100644 index f28b139..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCustomersParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListCustomersParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCustomersResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListCustomersResponseTest.cs deleted file mode 100644 index e4defff..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListCustomersResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListCustomersResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityKeyDefinitionsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityKeyDefinitionsParamsTest.cs deleted file mode 100644 index a90ef02..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityKeyDefinitionsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListEntityKeyDefinitionsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityKeyDefinitionsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityKeyDefinitionsResponseTest.cs deleted file mode 100644 index 30acb80..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityKeyDefinitionsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListEntityKeyDefinitionsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityTraitDefinitionsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityTraitDefinitionsParamsTest.cs deleted file mode 100644 index 3d0f112..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityTraitDefinitionsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListEntityTraitDefinitionsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityTraitDefinitionsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityTraitDefinitionsResponseTest.cs deleted file mode 100644 index 23dffff..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEntityTraitDefinitionsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListEntityTraitDefinitionsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEnvironmentsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListEnvironmentsParamsTest.cs deleted file mode 100644 index 454028c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEnvironmentsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListEnvironmentsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEnvironmentsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListEnvironmentsResponseTest.cs deleted file mode 100644 index 405c7e2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEnvironmentsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListEnvironmentsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEventsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListEventsParamsTest.cs deleted file mode 100644 index c15da6a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEventsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListEventsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEventsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListEventsResponseTest.cs deleted file mode 100644 index f35d48c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListEventsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListEventsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureCompaniesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureCompaniesParamsTest.cs deleted file mode 100644 index 4355e2b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureCompaniesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListFeatureCompaniesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureCompaniesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureCompaniesResponseTest.cs deleted file mode 100644 index 946e717..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureCompaniesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListFeatureCompaniesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsageParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsageParamsTest.cs deleted file mode 100644 index 566c1b6..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsageParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListFeatureUsageParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsageResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsageResponseTest.cs deleted file mode 100644 index 28a76e7..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsageResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListFeatureUsageResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsersParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsersParamsTest.cs deleted file mode 100644 index 5cfb779..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsersParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListFeatureUsersParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsersResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsersResponseTest.cs deleted file mode 100644 index 85a1af0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeatureUsersResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListFeatureUsersResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeaturesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeaturesParamsTest.cs deleted file mode 100644 index c2e867c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeaturesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListFeaturesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeaturesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeaturesResponseTest.cs deleted file mode 100644 index 69c7710..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFeaturesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListFeaturesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFlagsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListFlagsParamsTest.cs deleted file mode 100644 index ede1e55..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFlagsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListFlagsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFlagsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListFlagsResponseTest.cs deleted file mode 100644 index e94ef62..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListFlagsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListFlagsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListMetricCountsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListMetricCountsParamsTest.cs deleted file mode 100644 index ecd1749..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListMetricCountsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListMetricCountsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListMetricCountsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListMetricCountsResponseTest.cs deleted file mode 100644 index 0921dd5..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListMetricCountsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListMetricCountsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlanEntitlementsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlanEntitlementsParamsTest.cs deleted file mode 100644 index 82e1cd1..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlanEntitlementsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListPlanEntitlementsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlanEntitlementsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlanEntitlementsResponseTest.cs deleted file mode 100644 index b19565a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlanEntitlementsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListPlanEntitlementsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlansParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlansParamsTest.cs deleted file mode 100644 index 8c9e9d5..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlansParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListPlansParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlansResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlansResponseTest.cs deleted file mode 100644 index cd04ef0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListPlansResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListPlansResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListProductPricesParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListProductPricesParamsTest.cs deleted file mode 100644 index 0fdc6bd..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListProductPricesParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListProductPricesParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListProductPricesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListProductPricesResponseTest.cs deleted file mode 100644 index d0759ae..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListProductPricesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListProductPricesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListUsersParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListUsersParamsTest.cs deleted file mode 100644 index 4bd1f8b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListUsersParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListUsersParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListUsersResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListUsersResponseTest.cs deleted file mode 100644 index db40ea3..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListUsersResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListUsersResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhookEventsParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhookEventsParamsTest.cs deleted file mode 100644 index 5231f04..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhookEventsParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListWebhookEventsParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhookEventsResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhookEventsResponseTest.cs deleted file mode 100644 index c31d697..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhookEventsResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListWebhookEventsResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhooksParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhooksParamsTest.cs deleted file mode 100644 index 47a614c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhooksParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListWebhooksParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhooksResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhooksResponseTest.cs deleted file mode 100644 index af55a24..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/ListWebhooksResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class ListWebhooksResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/LookupCompanyParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/LookupCompanyParamsTest.cs deleted file mode 100644 index e5bf386..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/LookupCompanyParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class LookupCompanyParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/LookupCompanyResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/LookupCompanyResponseTest.cs deleted file mode 100644 index 20ccd55..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/LookupCompanyResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class LookupCompanyResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/LookupUserParamsTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/LookupUserParamsTest.cs deleted file mode 100644 index 9d90512..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/LookupUserParamsTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class LookupUserParamsTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/LookupUserResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/LookupUserResponseTest.cs deleted file mode 100644 index b08a120..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/LookupUserResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class LookupUserResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/MetricCountsHourlyResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/MetricCountsHourlyResponseDataTest.cs deleted file mode 100644 index de95497..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/MetricCountsHourlyResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class MetricCountsHourlyResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/PaginationFilterTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/PaginationFilterTest.cs deleted file mode 100644 index 0e7e93b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/PaginationFilterTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class PaginationFilterTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/PlanAudienceDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/PlanAudienceDetailResponseDataTest.cs deleted file mode 100644 index a77eed7..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/PlanAudienceDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class PlanAudienceDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/PlanAudienceResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/PlanAudienceResponseDataTest.cs deleted file mode 100644 index 53f203e..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/PlanAudienceResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class PlanAudienceResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/PlanDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/PlanDetailResponseDataTest.cs deleted file mode 100644 index 920e504..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/PlanDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class PlanDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/PlanEntitlementResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/PlanEntitlementResponseDataTest.cs deleted file mode 100644 index 79fc076..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/PlanEntitlementResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class PlanEntitlementResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/PlanResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/PlanResponseDataTest.cs deleted file mode 100644 index cc3921e..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/PlanResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class PlanResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/PreviewObjectTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/PreviewObjectTest.cs deleted file mode 100644 index bb61299..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/PreviewObjectTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class PreviewObjectTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/RawEventBatchResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/RawEventBatchResponseDataTest.cs deleted file mode 100644 index fb73e3a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/RawEventBatchResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class RawEventBatchResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/RawEventResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/RawEventResponseDataTest.cs deleted file mode 100644 index 1e376b1..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/RawEventResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class RawEventResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionDetailResponseDataTest.cs deleted file mode 100644 index 7ae7f8b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class RuleConditionDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionGroupDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionGroupDetailResponseDataTest.cs deleted file mode 100644 index f3105ea..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionGroupDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class RuleConditionGroupDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionGroupResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionGroupResponseDataTest.cs deleted file mode 100644 index 74bd3c2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionGroupResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class RuleConditionGroupResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionResourceResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionResourceResponseDataTest.cs deleted file mode 100644 index f7a2c89..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionResourceResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class RuleConditionResourceResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionResponseDataTest.cs deleted file mode 100644 index 6460827..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleConditionResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class RuleConditionResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/RuleDetailResponseDataTest.cs deleted file mode 100644 index 024f07a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class RuleDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/RuleResponseDataTest.cs deleted file mode 100644 index 89507f0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/RuleResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class RuleResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/RulesDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/RulesDetailResponseDataTest.cs deleted file mode 100644 index a85d125..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/RulesDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class RulesDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/SegmentStatusRespTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/SegmentStatusRespTest.cs deleted file mode 100644 index 8eb56cb..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/SegmentStatusRespTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class SegmentStatusRespTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/TemporaryAccessTokenResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/TemporaryAccessTokenResponseDataTest.cs deleted file mode 100644 index 6244a47..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/TemporaryAccessTokenResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class TemporaryAccessTokenResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateApiKeyResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateApiKeyResponseTest.cs deleted file mode 100644 index f1946da..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateApiKeyResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateApiKeyResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateAudienceResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateAudienceResponseTest.cs deleted file mode 100644 index 8b07ef6..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateAudienceResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateAudienceResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateBillingPlanGroupResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateBillingPlanGroupResponseTest.cs deleted file mode 100644 index d4847e8..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateBillingPlanGroupResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateBillingPlanGroupResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateCompanyOverrideResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateCompanyOverrideResponseTest.cs deleted file mode 100644 index d2e945c..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateCompanyOverrideResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateCompanyOverrideResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateComponentResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateComponentResponseTest.cs deleted file mode 100644 index 6d2ae98..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateComponentResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateComponentResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateEntityTraitDefinitionResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateEntityTraitDefinitionResponseTest.cs deleted file mode 100644 index 7825f0b..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateEntityTraitDefinitionResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateEntityTraitDefinitionResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateEnvironmentResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateEnvironmentResponseTest.cs deleted file mode 100644 index 5cfc591..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateEnvironmentResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateEnvironmentResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateFeatureResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateFeatureResponseTest.cs deleted file mode 100644 index 4e42a46..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateFeatureResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateFeatureResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateFlagResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateFlagResponseTest.cs deleted file mode 100644 index 974c169..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateFlagResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateFlagResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateFlagRulesResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateFlagRulesResponseTest.cs deleted file mode 100644 index 21597f2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateFlagRulesResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateFlagRulesResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdatePlanEntitlementResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdatePlanEntitlementResponseTest.cs deleted file mode 100644 index 02aa60a..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdatePlanEntitlementResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdatePlanEntitlementResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdatePlanResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdatePlanResponseTest.cs deleted file mode 100644 index e8b9d05..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdatePlanResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdatePlanResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateReqCommonTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateReqCommonTest.cs deleted file mode 100644 index 04360c2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateReqCommonTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateReqCommonTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateRuleRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateRuleRequestBodyTest.cs deleted file mode 100644 index ee3a12e..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateRuleRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateRuleRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateWebhookResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateWebhookResponseTest.cs deleted file mode 100644 index 6654af4..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpdateWebhookResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpdateWebhookResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingCustomerResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingCustomerResponseTest.cs deleted file mode 100644 index 88284e8..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingCustomerResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertBillingCustomerResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingPriceResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingPriceResponseTest.cs deleted file mode 100644 index 436112e..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingPriceResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertBillingPriceResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingProductPlanResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingProductPlanResponseTest.cs deleted file mode 100644 index 6228047..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingProductPlanResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertBillingProductPlanResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingProductResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingProductResponseTest.cs deleted file mode 100644 index 6fb6945..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingProductResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertBillingProductResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingSubscriptionResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingSubscriptionResponseTest.cs deleted file mode 100644 index 63c5504..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertBillingSubscriptionResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertBillingSubscriptionResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCompanyRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCompanyRequestBodyTest.cs deleted file mode 100644 index ff899a4..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCompanyRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertCompanyRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCompanyResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCompanyResponseTest.cs deleted file mode 100644 index 2d6e250..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCompanyResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertCompanyResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCompanyTraitResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCompanyTraitResponseTest.cs deleted file mode 100644 index b518824..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCompanyTraitResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertCompanyTraitResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCrmDealResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCrmDealResponseTest.cs deleted file mode 100644 index b73fe32..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCrmDealResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertCrmDealResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCrmProductResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCrmProductResponseTest.cs deleted file mode 100644 index 5526e65..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertCrmProductResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertCrmProductResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertDealLineItemAssociationResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertDealLineItemAssociationResponseTest.cs deleted file mode 100644 index 72697db..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertDealLineItemAssociationResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertDealLineItemAssociationResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertLineItemResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertLineItemResponseTest.cs deleted file mode 100644 index 4eb2714..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertLineItemResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertLineItemResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertTraitRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertTraitRequestBodyTest.cs deleted file mode 100644 index 40e0a12..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertTraitRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertTraitRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserRequestBodyTest.cs deleted file mode 100644 index 4a16a91..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertUserRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserResponseTest.cs deleted file mode 100644 index 5b4c8f2..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertUserResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserSubRequestBodyTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserSubRequestBodyTest.cs deleted file mode 100644 index bc99cb0..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserSubRequestBodyTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertUserSubRequestBodyTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserTraitResponseTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserTraitResponseTest.cs deleted file mode 100644 index a5f98cd..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UpsertUserTraitResponseTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UpsertUserTraitResponseTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UserDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UserDetailResponseDataTest.cs deleted file mode 100644 index 7ad6037..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UserDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UserDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/UserResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/UserResponseDataTest.cs deleted file mode 100644 index 29dc7ca..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/UserResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class UserResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/WebhookEventDetailResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/WebhookEventDetailResponseDataTest.cs deleted file mode 100644 index f0ec741..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/WebhookEventDetailResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class WebhookEventDetailResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/WebhookEventResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/WebhookEventResponseDataTest.cs deleted file mode 100644 index 821efea..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/WebhookEventResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class WebhookEventResponseDataTest { } diff --git a/src/SchematicHQ.Client.Test/Unit/Serialization/WebhookResponseDataTest.cs b/src/SchematicHQ.Client.Test/Unit/Serialization/WebhookResponseDataTest.cs deleted file mode 100644 index 19f6294..0000000 --- a/src/SchematicHQ.Client.Test/Unit/Serialization/WebhookResponseDataTest.cs +++ /dev/null @@ -1,8 +0,0 @@ -using NUnit.Framework; - -#nullable enable - -namespace SchematicHQ.Client.Test; - -[TestFixture] -public class WebhookResponseDataTest { } diff --git a/src/SchematicHQ.Client.sln b/src/SchematicHQ.Client.sln index 1215d84..3bef0ed 100644 --- a/src/SchematicHQ.Client.sln +++ b/src/SchematicHQ.Client.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client", "SchematicHQ.Client\SchematicHQ.Client.csproj", "{F9CD1DE1-BFD1-43D5-A3A4-6D1CFCFA4337}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client", "SchematicHQ.Client\SchematicHQ.Client.csproj", "{3EBC960B-56BD-4554-98D5-6453169063C6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client.Test", "SchematicHQ.Client.Test\SchematicHQ.Client.Test.csproj", "{1FCA9B08-C3B5-4F1D-BEBD-36BFBB619D34}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client.Test", "SchematicHQ.Client.Test\SchematicHQ.Client.Test.csproj", "{E53A0888-A1A1-4E6B-B88E-98E74632F1F6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -16,13 +16,13 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F9CD1DE1-BFD1-43D5-A3A4-6D1CFCFA4337}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F9CD1DE1-BFD1-43D5-A3A4-6D1CFCFA4337}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F9CD1DE1-BFD1-43D5-A3A4-6D1CFCFA4337}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F9CD1DE1-BFD1-43D5-A3A4-6D1CFCFA4337}.Release|Any CPU.Build.0 = Release|Any CPU - {1FCA9B08-C3B5-4F1D-BEBD-36BFBB619D34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1FCA9B08-C3B5-4F1D-BEBD-36BFBB619D34}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1FCA9B08-C3B5-4F1D-BEBD-36BFBB619D34}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1FCA9B08-C3B5-4F1D-BEBD-36BFBB619D34}.Release|Any CPU.Build.0 = Release|Any CPU + {3EBC960B-56BD-4554-98D5-6453169063C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3EBC960B-56BD-4554-98D5-6453169063C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3EBC960B-56BD-4554-98D5-6453169063C6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3EBC960B-56BD-4554-98D5-6453169063C6}.Release|Any CPU.Build.0 = Release|Any CPU + {E53A0888-A1A1-4E6B-B88E-98E74632F1F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E53A0888-A1A1-4E6B-B88E-98E74632F1F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E53A0888-A1A1-4E6B-B88E-98E74632F1F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E53A0888-A1A1-4E6B-B88E-98E74632F1F6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/SchematicHQ.Client/Accesstokens/AccesstokensClient.cs b/src/SchematicHQ.Client/Accesstokens/AccesstokensClient.cs index 63af912..ed08a71 100644 --- a/src/SchematicHQ.Client/Accesstokens/AccesstokensClient.cs +++ b/src/SchematicHQ.Client/Accesstokens/AccesstokensClient.cs @@ -1,38 +1,85 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class AccesstokensClient +public partial class AccesstokensClient { private RawClient _client; - public AccesstokensClient(RawClient client) + internal AccesstokensClient(RawClient client) { _client = client; } + /// + /// + /// await client.Accesstokens.IssueTemporaryAccessTokenAsync( + /// new IssueTemporaryAccessTokenRequestBody + /// { + /// Lookup = new Dictionary<string, string>() { { "key", "value" } }, + /// ResourceType = "resource_type", + /// } + /// ); + /// + /// public async Task IssueTemporaryAccessTokenAsync( - IssueTemporaryAccessTokenRequestBody request + IssueTemporaryAccessTokenRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "temporary-access-tokens", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } } diff --git a/src/SchematicHQ.Client/Accesstokens/Requests/IssueTemporaryAccessTokenRequestBody.cs b/src/SchematicHQ.Client/Accesstokens/Requests/IssueTemporaryAccessTokenRequestBody.cs index 4da6c57..1a69e4b 100644 --- a/src/SchematicHQ.Client/Accesstokens/Requests/IssueTemporaryAccessTokenRequestBody.cs +++ b/src/SchematicHQ.Client/Accesstokens/Requests/IssueTemporaryAccessTokenRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,8 +8,13 @@ namespace SchematicHQ.Client; public record IssueTemporaryAccessTokenRequestBody { [JsonPropertyName("lookup")] - public Dictionary Lookup { get; init; } = new Dictionary(); + public Dictionary Lookup { get; set; } = new Dictionary(); [JsonPropertyName("resource_type")] - public required string ResourceType { get; init; } + public required string ResourceType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accesstokens/Types/IssueTemporaryAccessTokenResponse.cs b/src/SchematicHQ.Client/Accesstokens/Types/IssueTemporaryAccessTokenResponse.cs index 5a586f2..34fde73 100644 --- a/src/SchematicHQ.Client/Accesstokens/Types/IssueTemporaryAccessTokenResponse.cs +++ b/src/SchematicHQ.Client/Accesstokens/Types/IssueTemporaryAccessTokenResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record IssueTemporaryAccessTokenResponse { [JsonPropertyName("data")] - public required IssueTemporaryAccessTokenResponseData Data { get; init; } + public required IssueTemporaryAccessTokenResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/AccountsClient.cs b/src/SchematicHQ.Client/Accounts/AccountsClient.cs index 25a6754..8041265 100644 --- a/src/SchematicHQ.Client/Accounts/AccountsClient.cs +++ b/src/SchematicHQ.Client/Accounts/AccountsClient.cs @@ -1,27 +1,34 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class AccountsClient +public partial class AccountsClient { private RawClient _client; - public AccountsClient(RawClient client) + internal AccountsClient(RawClient client) { _client = client; } - public async Task ListApiKeysAsync(ListApiKeysRequest request) + /// + /// + /// await client.Accounts.ListApiKeysAsync(new ListApiKeysRequest { RequireEnvironment = true }); + /// + /// + public async Task ListApiKeysAsync( + ListApiKeysRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() - { - { "require_environment", request.RequireEnvironment.ToString() }, - }; + var _query = new Dictionary(); + _query["require_environment"] = request.RequireEnvironment.ToString(); if (request.EnvironmentId != null) { _query["environment_id"] = request.EnvironmentId; @@ -37,94 +44,308 @@ public async Task ListApiKeysAsync(ListApiKeysRequest reque var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "api-keys", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CreateApiKeyAsync(CreateApiKeyRequestBody request) + /// + /// + /// await client.Accounts.CreateApiKeyAsync(new CreateApiKeyRequestBody { Name = "name" }); + /// + /// + public async Task CreateApiKeyAsync( + CreateApiKeyRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "api-keys", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetApiKeyAsync(string apiKeyId) + /// + /// + /// await client.Accounts.GetApiKeyAsync("api_key_id"); + /// + /// + public async Task GetApiKeyAsync( + string apiKeyId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"api-keys/{apiKeyId}" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = $"api-keys/{apiKeyId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Accounts.UpdateApiKeyAsync("api_key_id", new UpdateApiKeyRequestBody()); + /// + /// public async Task UpdateApiKeyAsync( string apiKeyId, - UpdateApiKeyRequestBody request + UpdateApiKeyRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"api-keys/{apiKeyId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteApiKeyAsync(string apiKeyId) + /// + /// + /// await client.Accounts.DeleteApiKeyAsync("api_key_id"); + /// + /// + public async Task DeleteApiKeyAsync( + string apiKeyId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, - Path = $"api-keys/{apiKeyId}" - } + Path = $"api-keys/{apiKeyId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CountApiKeysAsync(CountApiKeysRequest request) + /// + /// + /// await client.Accounts.CountApiKeysAsync(new CountApiKeysRequest { RequireEnvironment = true }); + /// + /// + public async Task CountApiKeysAsync( + CountApiKeysRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() - { - { "require_environment", request.RequireEnvironment.ToString() }, - }; + var _query = new Dictionary(); + _query["require_environment"] = request.RequireEnvironment.ToString(); if (request.EnvironmentId != null) { _query["environment_id"] = request.EnvironmentId; @@ -140,22 +361,64 @@ public async Task CountApiKeysAsync(CountApiKeysRequest re var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "api-keys/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task ListApiRequestsAsync(ListApiRequestsRequest request) + /// + /// + /// await client.Accounts.ListApiRequestsAsync(new ListApiRequestsRequest()); + /// + /// + public async Task ListApiRequestsAsync( + ListApiRequestsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.Q != null) { _query["q"] = request.Q; @@ -179,41 +442,123 @@ public async Task ListApiRequestsAsync(ListApiRequestsR var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "api-requests", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetApiRequestAsync(string apiRequestId) + /// + /// + /// await client.Accounts.GetApiRequestAsync("api_request_id"); + /// + /// + public async Task GetApiRequestAsync( + string apiRequestId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"api-requests/{apiRequestId}" - } + Path = $"api-requests/{apiRequestId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Accounts.CountApiRequestsAsync(new CountApiRequestsRequest()); + /// + /// public async Task CountApiRequestsAsync( - CountApiRequestsRequest request + CountApiRequestsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.Q != null) { _query["q"] = request.Q; @@ -237,28 +582,65 @@ CountApiRequestsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "api-requests/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Accounts.ListEnvironmentsAsync(new ListEnvironmentsRequest()); + /// + /// public async Task ListEnvironmentsAsync( - ListEnvironmentsRequest request + ListEnvironmentsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -270,91 +652,298 @@ ListEnvironmentsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "environments", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Accounts.CreateEnvironmentAsync( + /// new CreateEnvironmentRequestBody + /// { + /// EnvironmentType = CreateEnvironmentRequestBodyEnvironmentType.Development, + /// Name = "name", + /// } + /// ); + /// + /// public async Task CreateEnvironmentAsync( - CreateEnvironmentRequestBody request + CreateEnvironmentRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "environments", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetEnvironmentAsync(string environmentId) + /// + /// + /// await client.Accounts.GetEnvironmentAsync("environment_id"); + /// + /// + public async Task GetEnvironmentAsync( + string environmentId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"environments/{environmentId}" - } + Path = $"environments/{environmentId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Accounts.UpdateEnvironmentAsync("environment_id", new UpdateEnvironmentRequestBody()); + /// + /// public async Task UpdateEnvironmentAsync( string environmentId, - UpdateEnvironmentRequestBody request + UpdateEnvironmentRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"environments/{environmentId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteEnvironmentAsync(string environmentId) + /// + /// + /// await client.Accounts.DeleteEnvironmentAsync("environment_id"); + /// + /// + public async Task DeleteEnvironmentAsync( + string environmentId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, - Path = $"environments/{environmentId}" - } + Path = $"environments/{environmentId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } } diff --git a/src/SchematicHQ.Client/Accounts/Requests/CountApiKeysRequest.cs b/src/SchematicHQ.Client/Accounts/Requests/CountApiKeysRequest.cs index 5874503..72dc38b 100644 --- a/src/SchematicHQ.Client/Accounts/Requests/CountApiKeysRequest.cs +++ b/src/SchematicHQ.Client/Accounts/Requests/CountApiKeysRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountApiKeysRequest { - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } - public required bool RequireEnvironment { get; init; } + public required bool RequireEnvironment { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Requests/CountApiRequestsRequest.cs b/src/SchematicHQ.Client/Accounts/Requests/CountApiRequestsRequest.cs index 38bb226..a0b3738 100644 --- a/src/SchematicHQ.Client/Accounts/Requests/CountApiRequestsRequest.cs +++ b/src/SchematicHQ.Client/Accounts/Requests/CountApiRequestsRequest.cs @@ -1,20 +1,29 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountApiRequestsRequest { - public string? Q { get; init; } + public string? Q { get; set; } - public string? RequestType { get; init; } + public string? RequestType { get; set; } - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Requests/CreateApiKeyRequestBody.cs b/src/SchematicHQ.Client/Accounts/Requests/CreateApiKeyRequestBody.cs index 8c724ec..fb6bdd5 100644 --- a/src/SchematicHQ.Client/Accounts/Requests/CreateApiKeyRequestBody.cs +++ b/src/SchematicHQ.Client/Accounts/Requests/CreateApiKeyRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateApiKeyRequestBody { [JsonPropertyName("description")] - public string? Description { get; init; } + public string? Description { get; set; } [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Requests/CreateEnvironmentRequestBody.cs b/src/SchematicHQ.Client/Accounts/Requests/CreateEnvironmentRequestBody.cs index fc9319a..2539971 100644 --- a/src/SchematicHQ.Client/Accounts/Requests/CreateEnvironmentRequestBody.cs +++ b/src/SchematicHQ.Client/Accounts/Requests/CreateEnvironmentRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,8 +8,13 @@ namespace SchematicHQ.Client; public record CreateEnvironmentRequestBody { [JsonPropertyName("environment_type")] - public required CreateEnvironmentRequestBodyEnvironmentType EnvironmentType { get; init; } + public required CreateEnvironmentRequestBodyEnvironmentType EnvironmentType { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Requests/ListApiKeysRequest.cs b/src/SchematicHQ.Client/Accounts/Requests/ListApiKeysRequest.cs index e1470d5..c51b7c8 100644 --- a/src/SchematicHQ.Client/Accounts/Requests/ListApiKeysRequest.cs +++ b/src/SchematicHQ.Client/Accounts/Requests/ListApiKeysRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListApiKeysRequest { - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } - public required bool RequireEnvironment { get; init; } + public required bool RequireEnvironment { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Requests/ListApiRequestsRequest.cs b/src/SchematicHQ.Client/Accounts/Requests/ListApiRequestsRequest.cs index 362490d..8c4bd2c 100644 --- a/src/SchematicHQ.Client/Accounts/Requests/ListApiRequestsRequest.cs +++ b/src/SchematicHQ.Client/Accounts/Requests/ListApiRequestsRequest.cs @@ -1,20 +1,29 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListApiRequestsRequest { - public string? Q { get; init; } + public string? Q { get; set; } - public string? RequestType { get; init; } + public string? RequestType { get; set; } - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Requests/ListEnvironmentsRequest.cs b/src/SchematicHQ.Client/Accounts/Requests/ListEnvironmentsRequest.cs index 66ec122..9e801ca 100644 --- a/src/SchematicHQ.Client/Accounts/Requests/ListEnvironmentsRequest.cs +++ b/src/SchematicHQ.Client/Accounts/Requests/ListEnvironmentsRequest.cs @@ -1,16 +1,25 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListEnvironmentsRequest { - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Requests/UpdateApiKeyRequestBody.cs b/src/SchematicHQ.Client/Accounts/Requests/UpdateApiKeyRequestBody.cs index b9ecfc4..0261790 100644 --- a/src/SchematicHQ.Client/Accounts/Requests/UpdateApiKeyRequestBody.cs +++ b/src/SchematicHQ.Client/Accounts/Requests/UpdateApiKeyRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,8 +8,13 @@ namespace SchematicHQ.Client; public record UpdateApiKeyRequestBody { [JsonPropertyName("description")] - public string? Description { get; init; } + public string? Description { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Requests/UpdateEnvironmentRequestBody.cs b/src/SchematicHQ.Client/Accounts/Requests/UpdateEnvironmentRequestBody.cs index 7dd3395..262c662 100644 --- a/src/SchematicHQ.Client/Accounts/Requests/UpdateEnvironmentRequestBody.cs +++ b/src/SchematicHQ.Client/Accounts/Requests/UpdateEnvironmentRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,8 +8,13 @@ namespace SchematicHQ.Client; public record UpdateEnvironmentRequestBody { [JsonPropertyName("environment_type")] - public UpdateEnvironmentRequestBodyEnvironmentType? EnvironmentType { get; init; } + public UpdateEnvironmentRequestBodyEnvironmentType? EnvironmentType { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/CountApiKeysParams.cs b/src/SchematicHQ.Client/Accounts/Types/CountApiKeysParams.cs index caeea5d..b8e6cdd 100644 --- a/src/SchematicHQ.Client/Accounts/Types/CountApiKeysParams.cs +++ b/src/SchematicHQ.Client/Accounts/Types/CountApiKeysParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record CountApiKeysParams { [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("require_environment")] - public bool? RequireEnvironment { get; init; } + public bool? RequireEnvironment { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/CountApiKeysResponse.cs b/src/SchematicHQ.Client/Accounts/Types/CountApiKeysResponse.cs index d4375ad..63b8fee 100644 --- a/src/SchematicHQ.Client/Accounts/Types/CountApiKeysResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/CountApiKeysResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountApiKeysResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountApiKeysParams Params { get; init; } + public required CountApiKeysParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/CountApiRequestsParams.cs b/src/SchematicHQ.Client/Accounts/Types/CountApiRequestsParams.cs index 5e3c6d3..126c6c0 100644 --- a/src/SchematicHQ.Client/Accounts/Types/CountApiRequestsParams.cs +++ b/src/SchematicHQ.Client/Accounts/Types/CountApiRequestsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record CountApiRequestsParams { [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } [JsonPropertyName("request_type")] - public string? RequestType { get; init; } + public string? RequestType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/CountApiRequestsResponse.cs b/src/SchematicHQ.Client/Accounts/Types/CountApiRequestsResponse.cs index b8d986b..eef7f6e 100644 --- a/src/SchematicHQ.Client/Accounts/Types/CountApiRequestsResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/CountApiRequestsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountApiRequestsResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountApiRequestsParams Params { get; init; } + public required CountApiRequestsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/CreateApiKeyResponse.cs b/src/SchematicHQ.Client/Accounts/Types/CreateApiKeyResponse.cs index 69cd96f..5306cda 100644 --- a/src/SchematicHQ.Client/Accounts/Types/CreateApiKeyResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/CreateApiKeyResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateApiKeyResponse { [JsonPropertyName("data")] - public required ApiKeyCreateResponseData Data { get; init; } + public required ApiKeyCreateResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/CreateEnvironmentRequestBodyEnvironmentType.cs b/src/SchematicHQ.Client/Accounts/Types/CreateEnvironmentRequestBodyEnvironmentType.cs index 2779160..e0b36da 100644 --- a/src/SchematicHQ.Client/Accounts/Types/CreateEnvironmentRequestBodyEnvironmentType.cs +++ b/src/SchematicHQ.Client/Accounts/Types/CreateEnvironmentRequestBodyEnvironmentType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateEnvironmentRequestBodyEnvironmentType { [EnumMember(Value = "development")] @@ -17,5 +16,5 @@ public enum CreateEnvironmentRequestBodyEnvironmentType Staging, [EnumMember(Value = "production")] - Production + Production, } diff --git a/src/SchematicHQ.Client/Accounts/Types/CreateEnvironmentResponse.cs b/src/SchematicHQ.Client/Accounts/Types/CreateEnvironmentResponse.cs index f65bfcb..508da0b 100644 --- a/src/SchematicHQ.Client/Accounts/Types/CreateEnvironmentResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/CreateEnvironmentResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateEnvironmentResponse { [JsonPropertyName("data")] - public required EnvironmentDetailResponseData Data { get; init; } + public required EnvironmentDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/DeleteApiKeyResponse.cs b/src/SchematicHQ.Client/Accounts/Types/DeleteApiKeyResponse.cs index c50099c..8b5bd48 100644 --- a/src/SchematicHQ.Client/Accounts/Types/DeleteApiKeyResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/DeleteApiKeyResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteApiKeyResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/DeleteEnvironmentResponse.cs b/src/SchematicHQ.Client/Accounts/Types/DeleteEnvironmentResponse.cs index 4cf5400..a83b88e 100644 --- a/src/SchematicHQ.Client/Accounts/Types/DeleteEnvironmentResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/DeleteEnvironmentResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteEnvironmentResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/GetApiKeyResponse.cs b/src/SchematicHQ.Client/Accounts/Types/GetApiKeyResponse.cs index 76d9e97..a167196 100644 --- a/src/SchematicHQ.Client/Accounts/Types/GetApiKeyResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/GetApiKeyResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetApiKeyResponse { [JsonPropertyName("data")] - public required ApiKeyResponseData Data { get; init; } + public required ApiKeyResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/GetApiRequestResponse.cs b/src/SchematicHQ.Client/Accounts/Types/GetApiRequestResponse.cs index fd3bb1c..c7f4b51 100644 --- a/src/SchematicHQ.Client/Accounts/Types/GetApiRequestResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/GetApiRequestResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetApiRequestResponse { [JsonPropertyName("data")] - public required ApiKeyRequestResponseData Data { get; init; } + public required ApiKeyRequestResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/GetEnvironmentResponse.cs b/src/SchematicHQ.Client/Accounts/Types/GetEnvironmentResponse.cs index cd5fa4a..abe72d0 100644 --- a/src/SchematicHQ.Client/Accounts/Types/GetEnvironmentResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/GetEnvironmentResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetEnvironmentResponse { [JsonPropertyName("data")] - public required EnvironmentResponseData Data { get; init; } + public required EnvironmentResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/ListApiKeysParams.cs b/src/SchematicHQ.Client/Accounts/Types/ListApiKeysParams.cs index aee702f..58e9018 100644 --- a/src/SchematicHQ.Client/Accounts/Types/ListApiKeysParams.cs +++ b/src/SchematicHQ.Client/Accounts/Types/ListApiKeysParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record ListApiKeysParams { [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("require_environment")] - public bool? RequireEnvironment { get; init; } + public bool? RequireEnvironment { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/ListApiKeysResponse.cs b/src/SchematicHQ.Client/Accounts/Types/ListApiKeysResponse.cs index 3fcbb12..55e9655 100644 --- a/src/SchematicHQ.Client/Accounts/Types/ListApiKeysResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/ListApiKeysResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,11 +11,16 @@ public record ListApiKeysResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = new List(); + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListApiKeysParams Params { get; init; } + public required ListApiKeysParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsParams.cs b/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsParams.cs index cb246ea..3e06028 100644 --- a/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsParams.cs +++ b/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record ListApiRequestsParams { [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } [JsonPropertyName("request_type")] - public string? RequestType { get; init; } + public string? RequestType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsResponse.cs b/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsResponse.cs index 6db024f..8cf6f39 100644 --- a/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListApiRequestsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListApiRequestsParams Params { get; init; } + public required ListApiRequestsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsParams.cs b/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsParams.cs index 7b0c08b..85db22b 100644 --- a/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsParams.cs +++ b/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,17 +8,22 @@ namespace SchematicHQ.Client; public record ListEnvironmentsParams { [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsResponse.cs b/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsResponse.cs index 4ab6b34..6968312 100644 --- a/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListEnvironmentsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListEnvironmentsParams Params { get; init; } + public required ListEnvironmentsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/UpdateApiKeyResponse.cs b/src/SchematicHQ.Client/Accounts/Types/UpdateApiKeyResponse.cs index 5859776..bdb484b 100644 --- a/src/SchematicHQ.Client/Accounts/Types/UpdateApiKeyResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/UpdateApiKeyResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdateApiKeyResponse { [JsonPropertyName("data")] - public required ApiKeyResponseData Data { get; init; } + public required ApiKeyResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Accounts/Types/UpdateEnvironmentRequestBodyEnvironmentType.cs b/src/SchematicHQ.Client/Accounts/Types/UpdateEnvironmentRequestBodyEnvironmentType.cs index 5f6de09..5c0b4dc 100644 --- a/src/SchematicHQ.Client/Accounts/Types/UpdateEnvironmentRequestBodyEnvironmentType.cs +++ b/src/SchematicHQ.Client/Accounts/Types/UpdateEnvironmentRequestBodyEnvironmentType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdateEnvironmentRequestBodyEnvironmentType { [EnumMember(Value = "development")] @@ -17,5 +16,5 @@ public enum UpdateEnvironmentRequestBodyEnvironmentType Staging, [EnumMember(Value = "production")] - Production + Production, } diff --git a/src/SchematicHQ.Client/Accounts/Types/UpdateEnvironmentResponse.cs b/src/SchematicHQ.Client/Accounts/Types/UpdateEnvironmentResponse.cs index 5a3e641..23d6746 100644 --- a/src/SchematicHQ.Client/Accounts/Types/UpdateEnvironmentResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/UpdateEnvironmentResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdateEnvironmentResponse { [JsonPropertyName("data")] - public required EnvironmentResponseData Data { get; init; } + public required EnvironmentResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/BillingClient.cs b/src/SchematicHQ.Client/Billing/BillingClient.cs index 6db2171..4122c1c 100644 --- a/src/SchematicHQ.Client/Billing/BillingClient.cs +++ b/src/SchematicHQ.Client/Billing/BillingClient.cs @@ -1,44 +1,176 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class BillingClient +public partial class BillingClient { private RawClient _client; - public BillingClient(RawClient client) + internal BillingClient(RawClient client) { _client = client; } + /// + /// + /// await client.Billing.UpsertBillingCouponAsync( + /// new CreateCouponRequestBody + /// { + /// AmountOff = 1, + /// Duration = "duration", + /// DurationInMonths = 1, + /// ExternalId = "external_id", + /// MaxRedemptions = 1, + /// Name = "name", + /// PercentOff = 1.1, + /// TimesRedeemed = 1, + /// } + /// ); + /// + /// + public async Task UpsertBillingCouponAsync( + CreateCouponRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Post, + Path = "billing/coupons", + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Billing.UpsertBillingCustomerAsync( + /// new CreateBillingCustomerRequestBody + /// { + /// Email = "email", + /// ExternalId = "external_id", + /// FailedToImport = true, + /// Meta = new Dictionary<string, string>() { { "key", "value" } }, + /// Name = "name", + /// } + /// ); + /// + /// public async Task UpsertBillingCustomerAsync( - CreateBillingCustomerRequestBody request + CreateBillingCustomerRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "billing/customer/upsert", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task ListCustomersAsync(ListCustomersRequest request) + /// + /// + /// await client.Billing.ListCustomersAsync(new ListCustomersRequest()); + /// + /// + public async Task ListCustomersAsync( + ListCustomersRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.Name != null) { _query["name"] = request.Name; @@ -62,22 +194,64 @@ public async Task ListCustomersAsync(ListCustomersRequest var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "billing/customers", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CountCustomersAsync(CountCustomersRequest request) + /// + /// + /// await client.Billing.CountCustomersAsync(new CountCustomersRequest()); + /// + /// + public async Task CountCustomersAsync( + CountCustomersRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.Name != null) { _query["name"] = request.Name; @@ -101,104 +275,660 @@ public async Task CountCustomersAsync(CountCustomersRequ var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "billing/customers/count", - Query = _query + Query = _query, + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Billing.ListInvoicesAsync( + /// new ListInvoicesRequest { CustomerExternalId = "customer_external_id" } + /// ); + /// + /// + public async Task ListInvoicesAsync( + ListInvoicesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _query = new Dictionary(); + _query["customer_external_id"] = request.CustomerExternalId; + if (request.CompanyId != null) + { + _query["company_id"] = request.CompanyId; + } + if (request.SubscriptionExternalId != null) + { + _query["subscription_external_id"] = request.SubscriptionExternalId; + } + if (request.Limit != null) + { + _query["limit"] = request.Limit.ToString(); + } + if (request.Offset != null) + { + _query["offset"] = request.Offset.ToString(); + } + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = "billing/invoices", + Query = _query, + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Billing.UpsertInvoiceAsync( + /// new CreateInvoiceRequestBody + /// { + /// AmountDue = 1, + /// AmountPaid = 1, + /// AmountRemaining = 1, + /// CollectionMethod = "collection_method", + /// Currency = "currency", + /// CustomerExternalId = "customer_external_id", + /// Subtotal = 1, + /// } + /// ); + /// + /// + public async Task UpsertInvoiceAsync( + CreateInvoiceRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Post, + Path = "billing/invoices", + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetBillingPlanGroupByAccountIdAsync() + /// + /// + /// await client.Billing.ListMetersAsync(new ListMetersRequest()); + /// + /// + public async Task ListMetersAsync( + ListMetersRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { + var _query = new Dictionary(); + if (request.DisplayName != null) + { + _query["display_name"] = request.DisplayName; + } + if (request.Limit != null) + { + _query["limit"] = request.Limit.ToString(); + } + if (request.Offset != null) + { + _query["offset"] = request.Offset.ToString(); + } var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = "billing/plan-group" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = "billing/meter", + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize( - responseBody - )!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CreateBillingPlanGroupAsync( - CreateBillingPlanGroupRequestBody request + /// + /// + /// await client.Billing.UpsertBillingMeterAsync( + /// new CreateMeterRequestBody + /// { + /// DisplayName = "display_name", + /// EventName = "event_name", + /// EventPayloadKey = "event_payload_key", + /// ExternalId = "external_id", + /// } + /// ); + /// + /// + public async Task UpsertBillingMeterAsync( + CreateMeterRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, - Path = "billing/plan-group", - Body = request + Path = "billing/meter/upsert", + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Billing.ListPaymentMethodsAsync( + /// new ListPaymentMethodsRequest { CustomerExternalId = "customer_external_id" } + /// ); + /// + /// + public async Task ListPaymentMethodsAsync( + ListPaymentMethodsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _query = new Dictionary(); + _query["customer_external_id"] = request.CustomerExternalId; + if (request.CompanyId != null) + { + _query["company_id"] = request.CompanyId; + } + if (request.SubscriptionExternalId != null) + { + _query["subscription_external_id"] = request.SubscriptionExternalId; + } + if (request.Limit != null) + { + _query["limit"] = request.Limit.ToString(); + } + if (request.Offset != null) + { + _query["offset"] = request.Offset.ToString(); + } + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = "billing/payment-methods", + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task UpdateBillingPlanGroupAsync( - string billingId, - UpdateBillingPlanGroupRequestBody request + /// + /// + /// await client.Billing.UpsertPaymentMethodAsync( + /// new CreatePaymentMethodRequestBody + /// { + /// CustomerExternalId = "customer_external_id", + /// ExternalId = "external_id", + /// PaymentMethodType = "payment_method_type", + /// } + /// ); + /// + /// + public async Task UpsertPaymentMethodAsync( + CreatePaymentMethodRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { - Method = HttpMethod.Put, - Path = $"billing/plan-group/{billingId}", - Body = request + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Post, + Path = "billing/payment-methods", + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Billing.SearchBillingPricesAsync(new SearchBillingPricesRequest()); + /// + /// + public async Task SearchBillingPricesAsync( + SearchBillingPricesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _query = new Dictionary(); + _query["ids"] = request.Ids; + if (request.Interval != null) + { + _query["interval"] = request.Interval; + } + if (request.UsageType != null) + { + _query["usage_type"] = request.UsageType; + } + if (request.Price != null) + { + _query["price"] = request.Price.ToString(); + } + if (request.Limit != null) + { + _query["limit"] = request.Limit.ToString(); + } + if (request.Offset != null) + { + _query["offset"] = request.Offset.ToString(); + } + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = "billing/price", + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Billing.UpsertBillingPriceAsync( + /// new CreateBillingPriceRequestBody + /// { + /// Currency = "currency", + /// Interval = "interval", + /// Price = 1, + /// PriceExternalId = "price_external_id", + /// ProductExternalId = "product_external_id", + /// UsageType = "usage_type", + /// } + /// ); + /// + /// public async Task UpsertBillingPriceAsync( - CreateBillingPriceRequestBody request + CreateBillingPriceRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "billing/price/upsert", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Billing.ListProductPricesAsync(new ListProductPricesRequest()); + /// + /// public async Task ListProductPricesAsync( - ListProductPricesRequest request + ListProductPricesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.Name != null) { _query["name"] = request.Name; @@ -207,6 +937,22 @@ ListProductPricesRequest request { _query["q"] = request.Q; } + if (request.PriceUsageType != null) + { + _query["price_usage_type"] = request.PriceUsageType; + } + if (request.WithoutLinkedToPlan != null) + { + _query["without_linked_to_plan"] = request.WithoutLinkedToPlan.ToString(); + } + if (request.WithZeroPrice != null) + { + _query["with_zero_price"] = request.WithZeroPrice.ToString(); + } + if (request.WithPricesOnly != null) + { + _query["with_prices_only"] = request.WithPricesOnly.ToString(); + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -218,48 +964,194 @@ ListProductPricesRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "billing/product/prices", - Query = _query + Query = _query, + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Billing.DeleteProductPriceAsync("billing_id"); + /// + /// + public async Task DeleteProductPriceAsync( + string billingId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Delete, + Path = $"billing/product/prices/{billingId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Billing.UpsertBillingProductAsync( + /// new CreateBillingProductRequestBody + /// { + /// Currency = "currency", + /// ExternalId = "external_id", + /// Name = "name", + /// Price = 1.1, + /// Quantity = 1, + /// } + /// ); + /// + /// public async Task UpsertBillingProductAsync( - CreateBillingProductRequestBody request + CreateBillingProductRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "billing/product/upsert", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Billing.ListBillingProductsAsync(new ListBillingProductsRequest()); + /// + /// public async Task ListBillingProductsAsync( - ListBillingProductsRequest request + ListBillingProductsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.Name != null) { _query["name"] = request.Name; @@ -268,6 +1160,22 @@ ListBillingProductsRequest request { _query["q"] = request.Q; } + if (request.PriceUsageType != null) + { + _query["price_usage_type"] = request.PriceUsageType; + } + if (request.WithoutLinkedToPlan != null) + { + _query["without_linked_to_plan"] = request.WithoutLinkedToPlan.ToString(); + } + if (request.WithZeroPrice != null) + { + _query["with_zero_price"] = request.WithZeroPrice.ToString(); + } + if (request.WithPricesOnly != null) + { + _query["with_prices_only"] = request.WithPricesOnly.ToString(); + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -279,36 +1187,236 @@ ListBillingProductsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "billing/products", - Query = _query + Query = _query, + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Billing.CountBillingProductsAsync(new CountBillingProductsRequest()); + /// + /// + public async Task CountBillingProductsAsync( + CountBillingProductsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _query = new Dictionary(); + _query["ids"] = request.Ids; + if (request.Name != null) + { + _query["name"] = request.Name; + } + if (request.Q != null) + { + _query["q"] = request.Q; + } + if (request.PriceUsageType != null) + { + _query["price_usage_type"] = request.PriceUsageType; + } + if (request.WithoutLinkedToPlan != null) + { + _query["without_linked_to_plan"] = request.WithoutLinkedToPlan.ToString(); + } + if (request.WithZeroPrice != null) + { + _query["with_zero_price"] = request.WithZeroPrice.ToString(); + } + if (request.WithPricesOnly != null) + { + _query["with_prices_only"] = request.WithPricesOnly.ToString(); + } + if (request.Limit != null) + { + _query["limit"] = request.Limit.ToString(); + } + if (request.Offset != null) + { + _query["offset"] = request.Offset.ToString(); + } + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = "billing/products/count", + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Billing.UpsertBillingSubscriptionAsync( + /// new CreateBillingSubscriptionsRequestBody + /// { + /// Currency = "currency", + /// CustomerExternalId = "customer_external_id", + /// Discounts = new List<BillingSubscriptionDiscount>() + /// { + /// new BillingSubscriptionDiscount + /// { + /// CouponExternalId = "coupon_external_id", + /// ExternalId = "external_id", + /// IsActive = true, + /// StartedAt = new DateTime(2024, 01, 15, 09, 30, 00, 000), + /// }, + /// }, + /// ExpiredAt = new DateTime(2024, 01, 15, 09, 30, 00, 000), + /// ProductExternalIds = new List<BillingProductPricing>() + /// { + /// new BillingProductPricing + /// { + /// Currency = "currency", + /// Interval = "interval", + /// Price = 1, + /// PriceExternalId = "price_external_id", + /// ProductExternalId = "product_external_id", + /// Quantity = 1, + /// UsageType = "usage_type", + /// }, + /// }, + /// SubscriptionExternalId = "subscription_external_id", + /// TotalPrice = 1, + /// } + /// ); + /// + /// public async Task UpsertBillingSubscriptionAsync( - CreateBillingSubscriptionsRequestBody request + CreateBillingSubscriptionsRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "billing/subscription/upsert", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } } diff --git a/src/SchematicHQ.Client/Billing/Requests/CountBillingProductsRequest.cs b/src/SchematicHQ.Client/Billing/Requests/CountBillingProductsRequest.cs new file mode 100644 index 0000000..e9bbd1f --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Requests/CountBillingProductsRequest.cs @@ -0,0 +1,46 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CountBillingProductsRequest +{ + public IEnumerable Ids { get; set; } = new List(); + + public string? Name { get; set; } + + public string? Q { get; set; } + + public string? PriceUsageType { get; set; } + + /// + /// Filter products that are not linked to any plan + /// + public bool? WithoutLinkedToPlan { get; set; } + + /// + /// Filter products that have zero price for free subscription type + /// + public bool? WithZeroPrice { get; set; } + + /// + /// Filter products that have prices + /// + public bool? WithPricesOnly { get; set; } + + /// + /// Page limit (default 100) + /// + public int? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Requests/CountCustomersRequest.cs b/src/SchematicHQ.Client/Billing/Requests/CountCustomersRequest.cs index b9952ac..1d542d3 100644 --- a/src/SchematicHQ.Client/Billing/Requests/CountCustomersRequest.cs +++ b/src/SchematicHQ.Client/Billing/Requests/CountCustomersRequest.cs @@ -1,20 +1,29 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountCustomersRequest { - public string? Name { get; init; } + public string? Name { get; set; } - public bool? FailedToImport { get; init; } + public bool? FailedToImport { get; set; } - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Requests/CreateBillingCustomerRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/CreateBillingCustomerRequestBody.cs index d514ba1..6a87661 100644 --- a/src/SchematicHQ.Client/Billing/Requests/CreateBillingCustomerRequestBody.cs +++ b/src/SchematicHQ.Client/Billing/Requests/CreateBillingCustomerRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record CreateBillingCustomerRequestBody { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("email")] - public required string Email { get; init; } + public required string Email { get; set; } [JsonPropertyName("external_id")] - public required string ExternalId { get; init; } + public required string ExternalId { get; set; } [JsonPropertyName("failed_to_import")] - public required bool FailedToImport { get; init; } + public required bool FailedToImport { get; set; } [JsonPropertyName("meta")] - public Dictionary Meta { get; init; } = new Dictionary(); + public Dictionary Meta { get; set; } = new Dictionary(); [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Requests/CreateBillingPlanGroupRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/CreateBillingPlanGroupRequestBody.cs deleted file mode 100644 index 7a4272d..0000000 --- a/src/SchematicHQ.Client/Billing/Requests/CreateBillingPlanGroupRequestBody.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Text.Json.Serialization; - -#nullable enable - -namespace SchematicHQ.Client; - -public record CreateBillingPlanGroupRequestBody -{ - [JsonPropertyName("default_plan_id")] - public string? DefaultPlanId { get; init; } - - [JsonPropertyName("plan_ids")] - public IEnumerable PlanIds { get; init; } = new List(); -} diff --git a/src/SchematicHQ.Client/Billing/Requests/CreateBillingPriceRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/CreateBillingPriceRequestBody.cs index 61f7de8..fbc760d 100644 --- a/src/SchematicHQ.Client/Billing/Requests/CreateBillingPriceRequestBody.cs +++ b/src/SchematicHQ.Client/Billing/Requests/CreateBillingPriceRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,15 +7,29 @@ namespace SchematicHQ.Client; public record CreateBillingPriceRequestBody { + [JsonPropertyName("currency")] + public required string Currency { get; set; } + [JsonPropertyName("interval")] - public required string Interval { get; init; } + public required string Interval { get; set; } + + [JsonPropertyName("meter_id")] + public string? MeterId { get; set; } [JsonPropertyName("price")] - public required int Price { get; init; } + public required int Price { get; set; } [JsonPropertyName("price_external_id")] - public required string PriceExternalId { get; init; } + public required string PriceExternalId { get; set; } [JsonPropertyName("product_external_id")] - public required string ProductExternalId { get; init; } + public required string ProductExternalId { get; set; } + + [JsonPropertyName("usage_type")] + public required string UsageType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Requests/CreateBillingProductRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/CreateBillingProductRequestBody.cs index f6218cf..e303466 100644 --- a/src/SchematicHQ.Client/Billing/Requests/CreateBillingProductRequestBody.cs +++ b/src/SchematicHQ.Client/Billing/Requests/CreateBillingProductRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,17 +8,22 @@ namespace SchematicHQ.Client; public record CreateBillingProductRequestBody { [JsonPropertyName("currency")] - public required string Currency { get; init; } + public required string Currency { get; set; } [JsonPropertyName("external_id")] - public required string ExternalId { get; init; } + public required string ExternalId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("price")] - public required double Price { get; init; } + public required double Price { get; set; } [JsonPropertyName("quantity")] - public required int Quantity { get; init; } + public required int Quantity { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Requests/CreateBillingSubscriptionsRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/CreateBillingSubscriptionsRequestBody.cs index dcaca86..30c80bd 100644 --- a/src/SchematicHQ.Client/Billing/Requests/CreateBillingSubscriptionsRequestBody.cs +++ b/src/SchematicHQ.Client/Billing/Requests/CreateBillingSubscriptionsRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -7,28 +7,52 @@ namespace SchematicHQ.Client; public record CreateBillingSubscriptionsRequestBody { + [JsonPropertyName("currency")] + public required string Currency { get; set; } + [JsonPropertyName("customer_external_id")] - public required string CustomerExternalId { get; init; } + public required string CustomerExternalId { get; set; } + + [JsonPropertyName("discounts")] + public IEnumerable Discounts { get; set; } = + new List(); [JsonPropertyName("expired_at")] - public required DateTime ExpiredAt { get; init; } + public required DateTime ExpiredAt { get; set; } [JsonPropertyName("interval")] - public string? Interval { get; init; } + public string? Interval { get; set; } [JsonPropertyName("metadata")] - public Dictionary? Metadata { get; init; } + public Dictionary? Metadata { get; set; } + + [JsonPropertyName("period_end")] + public int? PeriodEnd { get; set; } + + [JsonPropertyName("period_start")] + public int? PeriodStart { get; set; } [JsonPropertyName("product_external_ids")] - public IEnumerable ProductExternalIds { get; init; } = + public IEnumerable ProductExternalIds { get; set; } = new List(); [JsonPropertyName("status")] - public string? Status { get; init; } + public string? Status { get; set; } [JsonPropertyName("subscription_external_id")] - public required string SubscriptionExternalId { get; init; } + public required string SubscriptionExternalId { get; set; } [JsonPropertyName("total_price")] - public required int TotalPrice { get; init; } + public required int TotalPrice { get; set; } + + [JsonPropertyName("trial_end")] + public int? TrialEnd { get; set; } + + [JsonPropertyName("trial_end_setting")] + public string? TrialEndSetting { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Requests/CreateCouponRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/CreateCouponRequestBody.cs new file mode 100644 index 0000000..91b798f --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Requests/CreateCouponRequestBody.cs @@ -0,0 +1,41 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CreateCouponRequestBody +{ + [JsonPropertyName("amount_off")] + public required int AmountOff { get; set; } + + [JsonPropertyName("currency")] + public string? Currency { get; set; } + + [JsonPropertyName("duration")] + public required string Duration { get; set; } + + [JsonPropertyName("duration_in_months")] + public required int DurationInMonths { get; set; } + + [JsonPropertyName("external_id")] + public required string ExternalId { get; set; } + + [JsonPropertyName("max_redemptions")] + public required int MaxRedemptions { get; set; } + + [JsonPropertyName("name")] + public required string Name { get; set; } + + [JsonPropertyName("percent_off")] + public required double PercentOff { get; set; } + + [JsonPropertyName("times_redeemed")] + public required int TimesRedeemed { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Requests/CreateInvoiceRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/CreateInvoiceRequestBody.cs new file mode 100644 index 0000000..93b4f3b --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Requests/CreateInvoiceRequestBody.cs @@ -0,0 +1,50 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CreateInvoiceRequestBody +{ + [JsonPropertyName("amount_due")] + public required int AmountDue { get; set; } + + [JsonPropertyName("amount_paid")] + public required int AmountPaid { get; set; } + + [JsonPropertyName("amount_remaining")] + public required int AmountRemaining { get; set; } + + [JsonPropertyName("collection_method")] + public required string CollectionMethod { get; set; } + + [JsonPropertyName("currency")] + public required string Currency { get; set; } + + [JsonPropertyName("customer_external_id")] + public required string CustomerExternalId { get; set; } + + [JsonPropertyName("due_date")] + public DateTime? DueDate { get; set; } + + [JsonPropertyName("external_id")] + public string? ExternalId { get; set; } + + [JsonPropertyName("payment_method_external_id")] + public string? PaymentMethodExternalId { get; set; } + + [JsonPropertyName("subscription_external_id")] + public string? SubscriptionExternalId { get; set; } + + [JsonPropertyName("subtotal")] + public required int Subtotal { get; set; } + + [JsonPropertyName("url")] + public string? Url { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Requests/CreateMeterRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/CreateMeterRequestBody.cs new file mode 100644 index 0000000..ac595ab --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Requests/CreateMeterRequestBody.cs @@ -0,0 +1,26 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CreateMeterRequestBody +{ + [JsonPropertyName("display_name")] + public required string DisplayName { get; set; } + + [JsonPropertyName("event_name")] + public required string EventName { get; set; } + + [JsonPropertyName("event_payload_key")] + public required string EventPayloadKey { get; set; } + + [JsonPropertyName("external_id")] + public required string ExternalId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Requests/CreatePaymentMethodRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/CreatePaymentMethodRequestBody.cs new file mode 100644 index 0000000..0bea1c4 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Requests/CreatePaymentMethodRequestBody.cs @@ -0,0 +1,53 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CreatePaymentMethodRequestBody +{ + [JsonPropertyName("account_last4")] + public string? AccountLast4 { get; set; } + + [JsonPropertyName("account_name")] + public string? AccountName { get; set; } + + [JsonPropertyName("bank_name")] + public string? BankName { get; set; } + + [JsonPropertyName("billing_email")] + public string? BillingEmail { get; set; } + + [JsonPropertyName("billing_name")] + public string? BillingName { get; set; } + + [JsonPropertyName("card_brand")] + public string? CardBrand { get; set; } + + [JsonPropertyName("card_exp_month")] + public int? CardExpMonth { get; set; } + + [JsonPropertyName("card_exp_year")] + public int? CardExpYear { get; set; } + + [JsonPropertyName("card_last4")] + public string? CardLast4 { get; set; } + + [JsonPropertyName("customer_external_id")] + public required string CustomerExternalId { get; set; } + + [JsonPropertyName("external_id")] + public required string ExternalId { get; set; } + + [JsonPropertyName("payment_method_type")] + public required string PaymentMethodType { get; set; } + + [JsonPropertyName("subscription_external_id")] + public string? SubscriptionExternalId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Requests/ListBillingProductsRequest.cs b/src/SchematicHQ.Client/Billing/Requests/ListBillingProductsRequest.cs index c050194..54d0895 100644 --- a/src/SchematicHQ.Client/Billing/Requests/ListBillingProductsRequest.cs +++ b/src/SchematicHQ.Client/Billing/Requests/ListBillingProductsRequest.cs @@ -1,20 +1,46 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListBillingProductsRequest { - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Name { get; init; } + public string? Name { get; set; } - public string? Q { get; init; } + public string? Q { get; set; } + + public string? PriceUsageType { get; set; } + + /// + /// Filter products that are not linked to any plan + /// + public bool? WithoutLinkedToPlan { get; set; } + + /// + /// Filter products that have zero price for free subscription type + /// + public bool? WithZeroPrice { get; set; } + + /// + /// Filter products that have prices + /// + public bool? WithPricesOnly { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Requests/ListCustomersRequest.cs b/src/SchematicHQ.Client/Billing/Requests/ListCustomersRequest.cs index 78d5ee6..92ab64d 100644 --- a/src/SchematicHQ.Client/Billing/Requests/ListCustomersRequest.cs +++ b/src/SchematicHQ.Client/Billing/Requests/ListCustomersRequest.cs @@ -1,20 +1,29 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListCustomersRequest { - public string? Name { get; init; } + public string? Name { get; set; } - public bool? FailedToImport { get; init; } + public bool? FailedToImport { get; set; } - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Requests/ListInvoicesRequest.cs b/src/SchematicHQ.Client/Billing/Requests/ListInvoicesRequest.cs new file mode 100644 index 0000000..dcaf835 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Requests/ListInvoicesRequest.cs @@ -0,0 +1,29 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ListInvoicesRequest +{ + public string? CompanyId { get; set; } + + public required string CustomerExternalId { get; set; } + + public string? SubscriptionExternalId { get; set; } + + /// + /// Page limit (default 100) + /// + public int? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Requests/ListMetersRequest.cs b/src/SchematicHQ.Client/Billing/Requests/ListMetersRequest.cs new file mode 100644 index 0000000..bb5db5f --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Requests/ListMetersRequest.cs @@ -0,0 +1,25 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ListMetersRequest +{ + public string? DisplayName { get; set; } + + /// + /// Page limit (default 100) + /// + public int? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Requests/ListPaymentMethodsRequest.cs b/src/SchematicHQ.Client/Billing/Requests/ListPaymentMethodsRequest.cs new file mode 100644 index 0000000..e6beb5c --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Requests/ListPaymentMethodsRequest.cs @@ -0,0 +1,29 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ListPaymentMethodsRequest +{ + public string? CompanyId { get; set; } + + public required string CustomerExternalId { get; set; } + + public string? SubscriptionExternalId { get; set; } + + /// + /// Page limit (default 100) + /// + public int? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Requests/ListProductPricesRequest.cs b/src/SchematicHQ.Client/Billing/Requests/ListProductPricesRequest.cs index 1eeb28a..6294160 100644 --- a/src/SchematicHQ.Client/Billing/Requests/ListProductPricesRequest.cs +++ b/src/SchematicHQ.Client/Billing/Requests/ListProductPricesRequest.cs @@ -1,20 +1,46 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListProductPricesRequest { - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Name { get; init; } + public string? Name { get; set; } - public string? Q { get; init; } + public string? Q { get; set; } + + public string? PriceUsageType { get; set; } + + /// + /// Filter products that are not linked to any plan + /// + public bool? WithoutLinkedToPlan { get; set; } + + /// + /// Filter products that have zero price for free subscription type + /// + public bool? WithZeroPrice { get; set; } + + /// + /// Filter products that have prices + /// + public bool? WithPricesOnly { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Requests/SearchBillingPricesRequest.cs b/src/SchematicHQ.Client/Billing/Requests/SearchBillingPricesRequest.cs new file mode 100644 index 0000000..0f84c5a --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Requests/SearchBillingPricesRequest.cs @@ -0,0 +1,31 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record SearchBillingPricesRequest +{ + public IEnumerable Ids { get; set; } = new List(); + + public string? Interval { get; set; } + + public string? UsageType { get; set; } + + public int? Price { get; set; } + + /// + /// Page limit (default 100) + /// + public int? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Requests/UpdateBillingPlanGroupRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/UpdateBillingPlanGroupRequestBody.cs deleted file mode 100644 index 03c8eb5..0000000 --- a/src/SchematicHQ.Client/Billing/Requests/UpdateBillingPlanGroupRequestBody.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Text.Json.Serialization; - -#nullable enable - -namespace SchematicHQ.Client; - -public record UpdateBillingPlanGroupRequestBody -{ - [JsonPropertyName("default_plan_id")] - public string? DefaultPlanId { get; init; } - - [JsonPropertyName("plan_ids")] - public IEnumerable PlanIds { get; init; } = new List(); -} diff --git a/src/SchematicHQ.Client/Billing/Types/CountBillingProductsParams.cs b/src/SchematicHQ.Client/Billing/Types/CountBillingProductsParams.cs new file mode 100644 index 0000000..345090d --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/CountBillingProductsParams.cs @@ -0,0 +1,56 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CountBillingProductsParams +{ + [JsonPropertyName("ids")] + public IEnumerable? Ids { get; set; } + + /// + /// Page limit (default 100) + /// + [JsonPropertyName("limit")] + public int? Limit { get; set; } + + [JsonPropertyName("name")] + public string? Name { get; set; } + + /// + /// Page offset (default 0) + /// + [JsonPropertyName("offset")] + public int? Offset { get; set; } + + [JsonPropertyName("price_usage_type")] + public string? PriceUsageType { get; set; } + + [JsonPropertyName("q")] + public string? Q { get; set; } + + /// + /// Filter products that have prices + /// + [JsonPropertyName("with_prices_only")] + public bool? WithPricesOnly { get; set; } + + /// + /// Filter products that have zero price for free subscription type + /// + [JsonPropertyName("with_zero_price")] + public bool? WithZeroPrice { get; set; } + + /// + /// Filter products that are not linked to any plan + /// + [JsonPropertyName("without_linked_to_plan")] + public bool? WithoutLinkedToPlan { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/CountBillingProductsResponse.cs b/src/SchematicHQ.Client/Billing/Types/CountBillingProductsResponse.cs new file mode 100644 index 0000000..fbaf60c --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/CountBillingProductsResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CountBillingProductsResponse +{ + [JsonPropertyName("data")] + public required CountResponse Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public required CountBillingProductsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/CountCustomersParams.cs b/src/SchematicHQ.Client/Billing/Types/CountCustomersParams.cs index eed656c..c705875 100644 --- a/src/SchematicHQ.Client/Billing/Types/CountCustomersParams.cs +++ b/src/SchematicHQ.Client/Billing/Types/CountCustomersParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record CountCustomersParams { [JsonPropertyName("failed_to_import")] - public bool? FailedToImport { get; init; } + public bool? FailedToImport { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/CountCustomersResponse.cs b/src/SchematicHQ.Client/Billing/Types/CountCustomersResponse.cs index 3d23553..d9d19e5 100644 --- a/src/SchematicHQ.Client/Billing/Types/CountCustomersResponse.cs +++ b/src/SchematicHQ.Client/Billing/Types/CountCustomersResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountCustomersResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountCustomersParams Params { get; init; } + public required CountCustomersParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/CreateBillingPlanGroupResponse.cs b/src/SchematicHQ.Client/Billing/Types/CreateBillingPlanGroupResponse.cs deleted file mode 100644 index 3a00501..0000000 --- a/src/SchematicHQ.Client/Billing/Types/CreateBillingPlanGroupResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Text.Json.Serialization; -using SchematicHQ.Client; - -#nullable enable - -namespace SchematicHQ.Client; - -public record CreateBillingPlanGroupResponse -{ - [JsonPropertyName("data")] - public required BillingPlanGroupResponseData Data { get; init; } - - /// - /// Input parameters - /// - [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); -} diff --git a/src/SchematicHQ.Client/Billing/Types/DeleteProductPriceResponse.cs b/src/SchematicHQ.Client/Billing/Types/DeleteProductPriceResponse.cs new file mode 100644 index 0000000..6647ba0 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/DeleteProductPriceResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record DeleteProductPriceResponse +{ + [JsonPropertyName("data")] + public required DeleteResponse Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/GetBillingPlanGroupByAccountIdResponse.cs b/src/SchematicHQ.Client/Billing/Types/GetBillingPlanGroupByAccountIdResponse.cs deleted file mode 100644 index e71bfec..0000000 --- a/src/SchematicHQ.Client/Billing/Types/GetBillingPlanGroupByAccountIdResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Text.Json.Serialization; -using SchematicHQ.Client; - -#nullable enable - -namespace SchematicHQ.Client; - -public record GetBillingPlanGroupByAccountIdResponse -{ - [JsonPropertyName("data")] - public required BillingPlanGroupResponseData Data { get; init; } - - /// - /// Input parameters - /// - [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); -} diff --git a/src/SchematicHQ.Client/Billing/Types/ListBillingProductsParams.cs b/src/SchematicHQ.Client/Billing/Types/ListBillingProductsParams.cs index 479642d..e5566d7 100644 --- a/src/SchematicHQ.Client/Billing/Types/ListBillingProductsParams.cs +++ b/src/SchematicHQ.Client/Billing/Types/ListBillingProductsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,49 @@ namespace SchematicHQ.Client; public record ListBillingProductsParams { [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + + [JsonPropertyName("price_usage_type")] + public string? PriceUsageType { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + /// + /// Filter products that have prices + /// + [JsonPropertyName("with_prices_only")] + public bool? WithPricesOnly { get; set; } + + /// + /// Filter products that have zero price for free subscription type + /// + [JsonPropertyName("with_zero_price")] + public bool? WithZeroPrice { get; set; } + + /// + /// Filter products that are not linked to any plan + /// + [JsonPropertyName("without_linked_to_plan")] + public bool? WithoutLinkedToPlan { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/ListBillingProductsResponse.cs b/src/SchematicHQ.Client/Billing/Types/ListBillingProductsResponse.cs index 952127a..b1657d3 100644 --- a/src/SchematicHQ.Client/Billing/Types/ListBillingProductsResponse.cs +++ b/src/SchematicHQ.Client/Billing/Types/ListBillingProductsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListBillingProductsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListBillingProductsParams Params { get; init; } + public required ListBillingProductsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/ListCustomersParams.cs b/src/SchematicHQ.Client/Billing/Types/ListCustomersParams.cs index 15a6780..92a73cf 100644 --- a/src/SchematicHQ.Client/Billing/Types/ListCustomersParams.cs +++ b/src/SchematicHQ.Client/Billing/Types/ListCustomersParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record ListCustomersParams { [JsonPropertyName("failed_to_import")] - public bool? FailedToImport { get; init; } + public bool? FailedToImport { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/ListCustomersResponse.cs b/src/SchematicHQ.Client/Billing/Types/ListCustomersResponse.cs index adac147..bfebdde 100644 --- a/src/SchematicHQ.Client/Billing/Types/ListCustomersResponse.cs +++ b/src/SchematicHQ.Client/Billing/Types/ListCustomersResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListCustomersResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListCustomersParams Params { get; init; } + public required ListCustomersParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/ListInvoicesParams.cs b/src/SchematicHQ.Client/Billing/Types/ListInvoicesParams.cs new file mode 100644 index 0000000..4a8f385 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/ListInvoicesParams.cs @@ -0,0 +1,35 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ListInvoicesParams +{ + [JsonPropertyName("company_id")] + public string? CompanyId { get; set; } + + [JsonPropertyName("customer_external_id")] + public string? CustomerExternalId { get; set; } + + /// + /// Page limit (default 100) + /// + [JsonPropertyName("limit")] + public int? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + [JsonPropertyName("offset")] + public int? Offset { get; set; } + + [JsonPropertyName("subscription_external_id")] + public string? SubscriptionExternalId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/ListInvoicesResponse.cs b/src/SchematicHQ.Client/Billing/Types/ListInvoicesResponse.cs new file mode 100644 index 0000000..81e7484 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/ListInvoicesResponse.cs @@ -0,0 +1,26 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ListInvoicesResponse +{ + /// + /// The returned resources + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = new List(); + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public required ListInvoicesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/ListMetersParams.cs b/src/SchematicHQ.Client/Billing/Types/ListMetersParams.cs new file mode 100644 index 0000000..e35d637 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/ListMetersParams.cs @@ -0,0 +1,29 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ListMetersParams +{ + [JsonPropertyName("display_name")] + public string? DisplayName { get; set; } + + /// + /// Page limit (default 100) + /// + [JsonPropertyName("limit")] + public int? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + [JsonPropertyName("offset")] + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/ListMetersResponse.cs b/src/SchematicHQ.Client/Billing/Types/ListMetersResponse.cs new file mode 100644 index 0000000..ea23cda --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/ListMetersResponse.cs @@ -0,0 +1,27 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ListMetersResponse +{ + /// + /// The returned resources + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = + new List(); + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public required ListMetersParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/ListPaymentMethodsParams.cs b/src/SchematicHQ.Client/Billing/Types/ListPaymentMethodsParams.cs new file mode 100644 index 0000000..989d7dc --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/ListPaymentMethodsParams.cs @@ -0,0 +1,35 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ListPaymentMethodsParams +{ + [JsonPropertyName("company_id")] + public string? CompanyId { get; set; } + + [JsonPropertyName("customer_external_id")] + public string? CustomerExternalId { get; set; } + + /// + /// Page limit (default 100) + /// + [JsonPropertyName("limit")] + public int? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + [JsonPropertyName("offset")] + public int? Offset { get; set; } + + [JsonPropertyName("subscription_external_id")] + public string? SubscriptionExternalId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/ListPaymentMethodsResponse.cs b/src/SchematicHQ.Client/Billing/Types/ListPaymentMethodsResponse.cs new file mode 100644 index 0000000..040bb01 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/ListPaymentMethodsResponse.cs @@ -0,0 +1,27 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ListPaymentMethodsResponse +{ + /// + /// The returned resources + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = + new List(); + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public required ListPaymentMethodsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/ListProductPricesParams.cs b/src/SchematicHQ.Client/Billing/Types/ListProductPricesParams.cs index 0bfc512..73c0bf7 100644 --- a/src/SchematicHQ.Client/Billing/Types/ListProductPricesParams.cs +++ b/src/SchematicHQ.Client/Billing/Types/ListProductPricesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,49 @@ namespace SchematicHQ.Client; public record ListProductPricesParams { [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + + [JsonPropertyName("price_usage_type")] + public string? PriceUsageType { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + /// + /// Filter products that have prices + /// + [JsonPropertyName("with_prices_only")] + public bool? WithPricesOnly { get; set; } + + /// + /// Filter products that have zero price for free subscription type + /// + [JsonPropertyName("with_zero_price")] + public bool? WithZeroPrice { get; set; } + + /// + /// Filter products that are not linked to any plan + /// + [JsonPropertyName("without_linked_to_plan")] + public bool? WithoutLinkedToPlan { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/ListProductPricesResponse.cs b/src/SchematicHQ.Client/Billing/Types/ListProductPricesResponse.cs index 7ed59d1..8e692d7 100644 --- a/src/SchematicHQ.Client/Billing/Types/ListProductPricesResponse.cs +++ b/src/SchematicHQ.Client/Billing/Types/ListProductPricesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListProductPricesResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListProductPricesParams Params { get; init; } + public required ListProductPricesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/SearchBillingPricesParams.cs b/src/SchematicHQ.Client/Billing/Types/SearchBillingPricesParams.cs new file mode 100644 index 0000000..f5c8310 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/SearchBillingPricesParams.cs @@ -0,0 +1,38 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record SearchBillingPricesParams +{ + [JsonPropertyName("ids")] + public IEnumerable? Ids { get; set; } + + [JsonPropertyName("interval")] + public string? Interval { get; set; } + + /// + /// Page limit (default 100) + /// + [JsonPropertyName("limit")] + public int? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + [JsonPropertyName("offset")] + public int? Offset { get; set; } + + [JsonPropertyName("price")] + public int? Price { get; set; } + + [JsonPropertyName("usage_type")] + public string? UsageType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/SearchBillingPricesResponse.cs b/src/SchematicHQ.Client/Billing/Types/SearchBillingPricesResponse.cs new file mode 100644 index 0000000..8aade30 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/SearchBillingPricesResponse.cs @@ -0,0 +1,26 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record SearchBillingPricesResponse +{ + /// + /// The returned resources + /// + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = new List(); + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public required SearchBillingPricesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/UpdateBillingPlanGroupResponse.cs b/src/SchematicHQ.Client/Billing/Types/UpdateBillingPlanGroupResponse.cs deleted file mode 100644 index c7f3ebe..0000000 --- a/src/SchematicHQ.Client/Billing/Types/UpdateBillingPlanGroupResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Text.Json.Serialization; -using SchematicHQ.Client; - -#nullable enable - -namespace SchematicHQ.Client; - -public record UpdateBillingPlanGroupResponse -{ - [JsonPropertyName("data")] - public required BillingPlanGroupResponseData Data { get; init; } - - /// - /// Input parameters - /// - [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); -} diff --git a/src/SchematicHQ.Client/Billing/Types/UpsertBillingCouponResponse.cs b/src/SchematicHQ.Client/Billing/Types/UpsertBillingCouponResponse.cs new file mode 100644 index 0000000..d3f48e5 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/UpsertBillingCouponResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpsertBillingCouponResponse +{ + [JsonPropertyName("data")] + public required BillingCouponResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/UpsertBillingCustomerResponse.cs b/src/SchematicHQ.Client/Billing/Types/UpsertBillingCustomerResponse.cs index 7686f1f..a286b1f 100644 --- a/src/SchematicHQ.Client/Billing/Types/UpsertBillingCustomerResponse.cs +++ b/src/SchematicHQ.Client/Billing/Types/UpsertBillingCustomerResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertBillingCustomerResponse { [JsonPropertyName("data")] - public required BillingCustomerResponseData Data { get; init; } + public required BillingCustomerResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/UpsertBillingMeterResponse.cs b/src/SchematicHQ.Client/Billing/Types/UpsertBillingMeterResponse.cs new file mode 100644 index 0000000..11fc40a --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/UpsertBillingMeterResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpsertBillingMeterResponse +{ + [JsonPropertyName("data")] + public required BillingMeterResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/UpsertBillingPriceResponse.cs b/src/SchematicHQ.Client/Billing/Types/UpsertBillingPriceResponse.cs index 2285c3e..6fd939f 100644 --- a/src/SchematicHQ.Client/Billing/Types/UpsertBillingPriceResponse.cs +++ b/src/SchematicHQ.Client/Billing/Types/UpsertBillingPriceResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertBillingPriceResponse { [JsonPropertyName("data")] - public required BillingPriceResponseData Data { get; init; } + public required BillingPriceResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/UpsertBillingProductResponse.cs b/src/SchematicHQ.Client/Billing/Types/UpsertBillingProductResponse.cs index 705bea1..ed932d2 100644 --- a/src/SchematicHQ.Client/Billing/Types/UpsertBillingProductResponse.cs +++ b/src/SchematicHQ.Client/Billing/Types/UpsertBillingProductResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertBillingProductResponse { [JsonPropertyName("data")] - public required BillingProductResponseData Data { get; init; } + public required BillingProductResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/UpsertBillingSubscriptionResponse.cs b/src/SchematicHQ.Client/Billing/Types/UpsertBillingSubscriptionResponse.cs index 3fd15c7..6a4460b 100644 --- a/src/SchematicHQ.Client/Billing/Types/UpsertBillingSubscriptionResponse.cs +++ b/src/SchematicHQ.Client/Billing/Types/UpsertBillingSubscriptionResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertBillingSubscriptionResponse { [JsonPropertyName("data")] - public required BillingSubscriptionResponseData Data { get; init; } + public required BillingSubscriptionResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Billing/Types/UpsertInvoiceResponse.cs b/src/SchematicHQ.Client/Billing/Types/UpsertInvoiceResponse.cs new file mode 100644 index 0000000..7999cf1 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/UpsertInvoiceResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpsertInvoiceResponse +{ + [JsonPropertyName("data")] + public required InvoiceResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Billing/Types/UpsertPaymentMethodResponse.cs b/src/SchematicHQ.Client/Billing/Types/UpsertPaymentMethodResponse.cs new file mode 100644 index 0000000..a0ebc26 --- /dev/null +++ b/src/SchematicHQ.Client/Billing/Types/UpsertPaymentMethodResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpsertPaymentMethodResponse +{ + [JsonPropertyName("data")] + public required PaymentMethodResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Checkout/CheckoutClient.cs b/src/SchematicHQ.Client/Checkout/CheckoutClient.cs new file mode 100644 index 0000000..03d5e84 --- /dev/null +++ b/src/SchematicHQ.Client/Checkout/CheckoutClient.cs @@ -0,0 +1,239 @@ +using System.Net.Http; +using System.Text.Json; +using System.Threading; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public partial class CheckoutClient +{ + private RawClient _client; + + internal CheckoutClient(RawClient client) + { + _client = client; + } + + /// + /// + /// await client.Checkout.InternalAsync( + /// new ChangeSubscriptionInternalRequestBody + /// { + /// AddOnIds = new List<UpdateAddOnRequestBody>() + /// { + /// new UpdateAddOnRequestBody { AddOnId = "add_on_id", PriceId = "price_id" }, + /// }, + /// CompanyId = "company_id", + /// NewPlanId = "new_plan_id", + /// NewPriceId = "new_price_id", + /// PayInAdvance = new List<UpdatePayInAdvanceRequestBody>() + /// { + /// new UpdatePayInAdvanceRequestBody { PriceId = "price_id", Quantity = 1 }, + /// }, + /// } + /// ); + /// + /// + public async Task InternalAsync( + ChangeSubscriptionInternalRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Post, + Path = "checkout-internal", + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Checkout.PreviewCheckoutInternalAsync( + /// new ChangeSubscriptionInternalRequestBody + /// { + /// AddOnIds = new List<UpdateAddOnRequestBody>() + /// { + /// new UpdateAddOnRequestBody { AddOnId = "add_on_id", PriceId = "price_id" }, + /// }, + /// CompanyId = "company_id", + /// NewPlanId = "new_plan_id", + /// NewPriceId = "new_price_id", + /// PayInAdvance = new List<UpdatePayInAdvanceRequestBody>() + /// { + /// new UpdatePayInAdvanceRequestBody { PriceId = "price_id", Quantity = 1 }, + /// }, + /// } + /// ); + /// + /// + public async Task PreviewCheckoutInternalAsync( + ChangeSubscriptionInternalRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Post, + Path = "checkout-internal/preview", + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Checkout.UpdateCustomerSubscriptionTrialEndAsync( + /// "subscription_id", + /// new UpdateTrialEndRequestBody() + /// ); + /// + /// + public async Task UpdateCustomerSubscriptionTrialEndAsync( + string subscriptionId, + UpdateTrialEndRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Put, + Path = $"subscription/{subscriptionId}/edit-trial-end", + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize( + responseBody + )!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } +} diff --git a/src/SchematicHQ.Client/Checkout/Requests/UpdateTrialEndRequestBody.cs b/src/SchematicHQ.Client/Checkout/Requests/UpdateTrialEndRequestBody.cs new file mode 100644 index 0000000..39cf175 --- /dev/null +++ b/src/SchematicHQ.Client/Checkout/Requests/UpdateTrialEndRequestBody.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpdateTrialEndRequestBody +{ + [JsonPropertyName("trial_end")] + public DateTime? TrialEnd { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Checkout/Types/CheckoutInternalResponse.cs b/src/SchematicHQ.Client/Checkout/Types/CheckoutInternalResponse.cs new file mode 100644 index 0000000..a3c7df3 --- /dev/null +++ b/src/SchematicHQ.Client/Checkout/Types/CheckoutInternalResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CheckoutInternalResponse +{ + [JsonPropertyName("data")] + public required BillingSubscriptionResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Checkout/Types/PreviewCheckoutInternalResponse.cs b/src/SchematicHQ.Client/Checkout/Types/PreviewCheckoutInternalResponse.cs new file mode 100644 index 0000000..5d4ed2a --- /dev/null +++ b/src/SchematicHQ.Client/Checkout/Types/PreviewCheckoutInternalResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PreviewCheckoutInternalResponse +{ + [JsonPropertyName("data")] + public required PreviewSubscriptionChangeResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Checkout/Types/UpdateCustomerSubscriptionTrialEndResponse.cs b/src/SchematicHQ.Client/Checkout/Types/UpdateCustomerSubscriptionTrialEndResponse.cs new file mode 100644 index 0000000..e509779 --- /dev/null +++ b/src/SchematicHQ.Client/Checkout/Types/UpdateCustomerSubscriptionTrialEndResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpdateCustomerSubscriptionTrialEndResponse +{ + [JsonPropertyName("data")] + public required BillingSubscriptionView Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Companies/CompaniesClient.cs b/src/SchematicHQ.Client/Companies/CompaniesClient.cs index aef9939..3f34736 100644 --- a/src/SchematicHQ.Client/Companies/CompaniesClient.cs +++ b/src/SchematicHQ.Client/Companies/CompaniesClient.cs @@ -1,28 +1,34 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class CompaniesClient +public partial class CompaniesClient { private RawClient _client; - public CompaniesClient(RawClient client) + internal CompaniesClient(RawClient client) { _client = client; } - public async Task ListCompaniesAsync(ListCompaniesRequest request) + /// + /// + /// await client.Companies.ListCompaniesAsync(new ListCompaniesRequest()); + /// + /// + public async Task ListCompaniesAsync( + ListCompaniesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.PlanId != null) { _query["plan_id"] = request.PlanId; @@ -35,6 +41,10 @@ public async Task ListCompaniesAsync(ListCompaniesRequest { _query["without_feature_override_for"] = request.WithoutFeatureOverrideFor; } + if (request.WithoutPlan != null) + { + _query["without_plan"] = request.WithoutPlan.ToString(); + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -46,78 +56,246 @@ public async Task ListCompaniesAsync(ListCompaniesRequest var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "companies", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task UpsertCompanyAsync(UpsertCompanyRequestBody request) + /// + /// + /// await client.Companies.UpsertCompanyAsync( + /// new UpsertCompanyRequestBody { Keys = new Dictionary<string, string>() { { "key", "value" } } } + /// ); + /// + /// + public async Task UpsertCompanyAsync( + UpsertCompanyRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "companies", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetCompanyAsync(string companyId) + /// + /// + /// await client.Companies.GetCompanyAsync("company_id"); + /// + /// + public async Task GetCompanyAsync( + string companyId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"companies/{companyId}" - } + Path = $"companies/{companyId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteCompanyAsync(string companyId) + /// + /// + /// await client.Companies.DeleteCompanyAsync("company_id"); + /// + /// + public async Task DeleteCompanyAsync( + string companyId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, - Path = $"companies/{companyId}" - } + Path = $"companies/{companyId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); - } - public async Task CountCompaniesAsync(CountCompaniesRequest request) - { - var _query = new Dictionary() { }; - if (request.Ids != null) + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) { - _query["ids"] = request.Ids; + // unable to map error response, throwing generic error } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Companies.CountCompaniesAsync(new CountCompaniesRequest()); + /// + /// + public async Task CountCompaniesAsync( + CountCompaniesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.PlanId != null) { _query["plan_id"] = request.PlanId; @@ -130,6 +308,10 @@ public async Task CountCompaniesAsync(CountCompaniesRequ { _query["without_feature_override_for"] = request.WithoutFeatureOverrideFor; } + if (request.WithoutPlan != null) + { + _query["without_plan"] = request.WithoutPlan.ToString(); + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -141,81 +323,267 @@ public async Task CountCompaniesAsync(CountCompaniesRequ var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "companies/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CreateCompanyAsync(UpsertCompanyRequestBody request) + /// + /// + /// await client.Companies.CreateCompanyAsync( + /// new UpsertCompanyRequestBody { Keys = new Dictionary<string, string>() { { "key", "value" } } } + /// ); + /// + /// + public async Task CreateCompanyAsync( + UpsertCompanyRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "companies/create", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteCompanyByKeysAsync(KeysRequestBody request) + /// + /// + /// await client.Companies.DeleteCompanyByKeysAsync( + /// new KeysRequestBody { Keys = new Dictionary<string, string>() { { "key", "value" } } } + /// ); + /// + /// + public async Task DeleteCompanyByKeysAsync( + KeysRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "companies/delete", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task LookupCompanyAsync(LookupCompanyRequest request) + /// + /// + /// await client.Companies.LookupCompanyAsync( + /// new LookupCompanyRequest + /// { + /// Keys = new Dictionary<string, object>() + /// { + /// { + /// "keys", + /// new Dictionary<object, object?>() { { "key", "value" } } + /// }, + /// }, + /// } + /// ); + /// + /// + public async Task LookupCompanyAsync( + LookupCompanyRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { { "keys", request.Keys.ToString() }, }; + var _query = new Dictionary(); + _query["keys"] = request.Keys.ToString(); var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "companies/lookup", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetActiveDealsAsync(GetActiveDealsRequest request) + /// + /// + /// await client.Companies.GetActiveDealsAsync( + /// new GetActiveDealsRequest { CompanyId = "company_id", DealStage = "deal_stage" } + /// ); + /// + /// + public async Task GetActiveDealsAsync( + GetActiveDealsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() - { - { "company_id", request.CompanyId }, - { "deal_stage", request.DealStage }, - }; + var _query = new Dictionary(); + _query["company_id"] = request.CompanyId; + _query["deal_stage"] = request.DealStage; if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -227,24 +595,64 @@ public async Task GetActiveDealsAsync(GetActiveDealsRequ var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "company-crm-deals", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.ListCompanyMembershipsAsync(new ListCompanyMembershipsRequest()); + /// + /// public async Task ListCompanyMembershipsAsync( - ListCompanyMembershipsRequest request + ListCompanyMembershipsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.CompanyId != null) { _query["company_id"] = request.CompanyId; @@ -264,63 +672,191 @@ ListCompanyMembershipsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "company-memberships", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.GetOrCreateCompanyMembershipAsync( + /// new GetOrCreateCompanyMembershipRequestBody { CompanyId = "company_id", UserId = "user_id" } + /// ); + /// + /// public async Task GetOrCreateCompanyMembershipAsync( - GetOrCreateCompanyMembershipRequestBody request + GetOrCreateCompanyMembershipRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "company-memberships", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.DeleteCompanyMembershipAsync("company_membership_id"); + /// + /// public async Task DeleteCompanyMembershipAsync( - string companyMembershipId + string companyMembershipId, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, - Path = $"company-memberships/{companyMembershipId}" - } + Path = $"company-memberships/{companyMembershipId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.GetActiveCompanySubscriptionAsync(new GetActiveCompanySubscriptionRequest()); + /// + /// public async Task GetActiveCompanySubscriptionAsync( - GetActiveCompanySubscriptionRequest request + GetActiveCompanySubscriptionRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { { "company_id", request.CompanyId }, }; + var _query = new Dictionary(); + _query["company_ids"] = request.CompanyIds; + if (request.CompanyId != null) + { + _query["company_id"] = request.CompanyId; + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -332,51 +868,135 @@ GetActiveCompanySubscriptionRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "company-subscriptions", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.UpsertCompanyTraitAsync( + /// new UpsertTraitRequestBody + /// { + /// Keys = new Dictionary<string, string>() { { "key", "value" } }, + /// Trait = "trait", + /// } + /// ); + /// + /// public async Task UpsertCompanyTraitAsync( - UpsertTraitRequestBody request + UpsertTraitRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "company-traits", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.ListEntityKeyDefinitionsAsync(new ListEntityKeyDefinitionsRequest()); + /// + /// public async Task ListEntityKeyDefinitionsAsync( - ListEntityKeyDefinitionsRequest request + ListEntityKeyDefinitionsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.EntityType != null) { - _query["entity_type"] = JsonSerializer.Serialize(request.EntityType.Value); - } - if (request.Ids != null) - { - _query["ids"] = request.Ids; + _query["entity_type"] = request.EntityType.Value.Stringify(); } if (request.Q != null) { @@ -393,31 +1013,68 @@ ListEntityKeyDefinitionsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "entity-key-definitions", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.CountEntityKeyDefinitionsAsync(new CountEntityKeyDefinitionsRequest()); + /// + /// public async Task CountEntityKeyDefinitionsAsync( - CountEntityKeyDefinitionsRequest request + CountEntityKeyDefinitionsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.EntityType != null) { - _query["entity_type"] = JsonSerializer.Serialize(request.EntityType.Value); - } - if (request.Ids != null) - { - _query["ids"] = request.Ids; + _query["entity_type"] = request.EntityType.Value.Stringify(); } if (request.Q != null) { @@ -434,39 +1091,76 @@ CountEntityKeyDefinitionsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "entity-key-definitions/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.ListEntityTraitDefinitionsAsync(new ListEntityTraitDefinitionsRequest()); + /// + /// public async Task ListEntityTraitDefinitionsAsync( - ListEntityTraitDefinitionsRequest request + ListEntityTraitDefinitionsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.EntityType != null) { - _query["entity_type"] = JsonSerializer.Serialize(request.EntityType.Value); + _query["entity_type"] = request.EntityType.Value.Stringify(); } - if (request.Ids != null) + if (request.Q != null) { - _query["ids"] = request.Ids; + _query["q"] = request.Q; } if (request.TraitType != null) { - _query["trait_type"] = JsonSerializer.Serialize(request.TraitType.Value); - } - if (request.Q != null) - { - _query["q"] = request.Q; + _query["trait_type"] = request.TraitType.Value.Stringify(); } if (request.Limit != null) { @@ -479,101 +1173,275 @@ ListEntityTraitDefinitionsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "entity-trait-definitions", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.GetOrCreateEntityTraitDefinitionAsync( + /// new CreateEntityTraitDefinitionRequestBody + /// { + /// EntityType = CreateEntityTraitDefinitionRequestBodyEntityType.Company, + /// Hierarchy = new List<string>() { "hierarchy" }, + /// TraitType = CreateEntityTraitDefinitionRequestBodyTraitType.Boolean, + /// } + /// ); + /// + /// public async Task GetOrCreateEntityTraitDefinitionAsync( - CreateEntityTraitDefinitionRequestBody request + CreateEntityTraitDefinitionRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "entity-trait-definitions", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize( - responseBody - )!; + try + { + return JsonUtils.Deserialize( + responseBody + )!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.GetEntityTraitDefinitionAsync("entity_trait_definition_id"); + /// + /// public async Task GetEntityTraitDefinitionAsync( - string entityTraitDefinitionId + string entityTraitDefinitionId, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"entity-trait-definitions/{entityTraitDefinitionId}" - } + Path = $"entity-trait-definitions/{entityTraitDefinitionId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.UpdateEntityTraitDefinitionAsync( + /// "entity_trait_definition_id", + /// new UpdateEntityTraitDefinitionRequestBody + /// { + /// TraitType = UpdateEntityTraitDefinitionRequestBodyTraitType.Boolean, + /// } + /// ); + /// + /// public async Task UpdateEntityTraitDefinitionAsync( string entityTraitDefinitionId, - UpdateEntityTraitDefinitionRequestBody request + UpdateEntityTraitDefinitionRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"entity-trait-definitions/{entityTraitDefinitionId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.CountEntityTraitDefinitionsAsync(new CountEntityTraitDefinitionsRequest()); + /// + /// public async Task CountEntityTraitDefinitionsAsync( - CountEntityTraitDefinitionsRequest request + CountEntityTraitDefinitionsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.EntityType != null) { - _query["entity_type"] = JsonSerializer.Serialize(request.EntityType.Value); + _query["entity_type"] = request.EntityType.Value.Stringify(); } - if (request.Ids != null) + if (request.Q != null) { - _query["ids"] = request.Ids; + _query["q"] = request.Q; } if (request.TraitType != null) { - _query["trait_type"] = JsonSerializer.Serialize(request.TraitType.Value); - } - if (request.Q != null) - { - _query["q"] = request.Q; + _query["trait_type"] = request.TraitType.Value.Stringify(); } if (request.Limit != null) { @@ -586,27 +1454,67 @@ CountEntityTraitDefinitionsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "entity-trait-definitions/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Companies.GetEntityTraitValuesAsync( + /// new GetEntityTraitValuesRequest { DefinitionId = "definition_id" } + /// ); + /// + /// public async Task GetEntityTraitValuesAsync( - GetEntityTraitValuesRequest request + GetEntityTraitValuesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() - { - { "definition_id", request.DefinitionId }, - }; + var _query = new Dictionary(); + _query["definition_id"] = request.DefinitionId; if (request.Q != null) { _query["q"] = request.Q; @@ -622,48 +1530,136 @@ GetEntityTraitValuesRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "entity-trait-values", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task UpsertUserTraitAsync(UpsertTraitRequestBody request) + /// + /// + /// await client.Companies.UpsertUserTraitAsync( + /// new UpsertTraitRequestBody + /// { + /// Keys = new Dictionary<string, string>() { { "key", "value" } }, + /// Trait = "trait", + /// } + /// ); + /// + /// + public async Task UpsertUserTraitAsync( + UpsertTraitRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "user-traits", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task ListUsersAsync(ListUsersRequest request) + /// + /// + /// await client.Companies.ListUsersAsync(new ListUsersRequest()); + /// + /// + public async Task ListUsersAsync( + ListUsersRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.CompanyId != null) { _query["company_id"] = request.CompanyId; } - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } if (request.PlanId != null) { _query["plan_id"] = request.PlanId; @@ -683,74 +1679,254 @@ public async Task ListUsersAsync(ListUsersRequest request) var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "users", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task UpsertUserAsync(UpsertUserRequestBody request) + /// + /// + /// await client.Companies.UpsertUserAsync( + /// new UpsertUserRequestBody + /// { + /// Company = new Dictionary<string, string>() { { "key", "value" } }, + /// Keys = new Dictionary<string, string>() { { "key", "value" } }, + /// } + /// ); + /// + /// + public async Task UpsertUserAsync( + UpsertUserRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "users", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetUserAsync(string userId) + /// + /// + /// await client.Companies.GetUserAsync("user_id"); + /// + /// + public async Task GetUserAsync( + string userId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"users/{userId}" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = $"users/{userId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteUserAsync(string userId) + /// + /// + /// await client.Companies.DeleteUserAsync("user_id"); + /// + /// + public async Task DeleteUserAsync( + string userId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Delete, Path = $"users/{userId}" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Delete, + Path = $"users/{userId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CountUsersAsync(CountUsersRequest request) + /// + /// + /// await client.Companies.CountUsersAsync(new CountUsersRequest()); + /// + /// + public async Task CountUsersAsync( + CountUsersRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.CompanyId != null) { _query["company_id"] = request.CompanyId; } - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } if (request.PlanId != null) { _query["plan_id"] = request.PlanId; @@ -770,71 +1946,252 @@ public async Task CountUsersAsync(CountUsersRequest request) var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "users/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CreateUserAsync(UpsertUserRequestBody request) + /// + /// + /// await client.Companies.CreateUserAsync( + /// new UpsertUserRequestBody + /// { + /// Company = new Dictionary<string, string>() { { "key", "value" } }, + /// Keys = new Dictionary<string, string>() { { "key", "value" } }, + /// } + /// ); + /// + /// + public async Task CreateUserAsync( + UpsertUserRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "users/create", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteUserByKeysAsync(KeysRequestBody request) + /// + /// + /// await client.Companies.DeleteUserByKeysAsync( + /// new KeysRequestBody { Keys = new Dictionary<string, string>() { { "key", "value" } } } + /// ); + /// + /// + public async Task DeleteUserByKeysAsync( + KeysRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "users/delete", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task LookupUserAsync(LookupUserRequest request) + /// + /// + /// await client.Companies.LookupUserAsync( + /// new LookupUserRequest + /// { + /// Keys = new Dictionary<string, object>() + /// { + /// { + /// "keys", + /// new Dictionary<object, object?>() { { "key", "value" } } + /// }, + /// }, + /// } + /// ); + /// + /// + public async Task LookupUserAsync( + LookupUserRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { { "keys", request.Keys.ToString() }, }; + var _query = new Dictionary(); + _query["keys"] = request.Keys.ToString(); var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "users/lookup", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } } diff --git a/src/SchematicHQ.Client/Companies/Requests/CountCompaniesRequest.cs b/src/SchematicHQ.Client/Companies/Requests/CountCompaniesRequest.cs index d0c9e7c..84f03bc 100644 --- a/src/SchematicHQ.Client/Companies/Requests/CountCompaniesRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/CountCompaniesRequest.cs @@ -1,28 +1,48 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountCompaniesRequest { - public string? Ids { get; init; } + /// + /// Filter companies by multiple company IDs (starts with comp_) + /// + public IEnumerable Ids { get; set; } = new List(); - public string? PlanId { get; init; } + /// + /// Filter companies by plan ID (starts with plan_) + /// + public string? PlanId { get; set; } /// - /// Search filter + /// Search for companies by name, keys or string traits /// - public string? Q { get; init; } + public string? Q { get; set; } /// /// Filter out companies that already have a company override for the specified feature ID /// - public string? WithoutFeatureOverrideFor { get; init; } + public string? WithoutFeatureOverrideFor { get; set; } + + /// + /// Filter out companies that have a plan + /// + public bool? WithoutPlan { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/CountEntityKeyDefinitionsRequest.cs b/src/SchematicHQ.Client/Companies/Requests/CountEntityKeyDefinitionsRequest.cs index c3dcf96..82aa82d 100644 --- a/src/SchematicHQ.Client/Companies/Requests/CountEntityKeyDefinitionsRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/CountEntityKeyDefinitionsRequest.cs @@ -1,4 +1,4 @@ -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -6,19 +6,24 @@ namespace SchematicHQ.Client; public record CountEntityKeyDefinitionsRequest { - public CountEntityKeyDefinitionsRequestEntityType? EntityType { get; init; } + public CountEntityKeyDefinitionsRequestEntityType? EntityType { get; set; } - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/CountEntityTraitDefinitionsRequest.cs b/src/SchematicHQ.Client/Companies/Requests/CountEntityTraitDefinitionsRequest.cs index 0cbad0b..b573d98 100644 --- a/src/SchematicHQ.Client/Companies/Requests/CountEntityTraitDefinitionsRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/CountEntityTraitDefinitionsRequest.cs @@ -1,4 +1,4 @@ -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -6,21 +6,26 @@ namespace SchematicHQ.Client; public record CountEntityTraitDefinitionsRequest { - public CountEntityTraitDefinitionsRequestEntityType? EntityType { get; init; } + public CountEntityTraitDefinitionsRequestEntityType? EntityType { get; set; } - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public CountEntityTraitDefinitionsRequestTraitType? TraitType { get; init; } + public string? Q { get; set; } - public string? Q { get; init; } + public CountEntityTraitDefinitionsRequestTraitType? TraitType { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/CountUsersRequest.cs b/src/SchematicHQ.Client/Companies/Requests/CountUsersRequest.cs index 36c19e4..fa015d1 100644 --- a/src/SchematicHQ.Client/Companies/Requests/CountUsersRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/CountUsersRequest.cs @@ -1,25 +1,43 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountUsersRequest { - public string? CompanyId { get; init; } + /// + /// Filter users by company ID (starts with comp_) + /// + public string? CompanyId { get; set; } - public string? Ids { get; init; } + /// + /// Filter users by multiple user IDs (starts with user_) + /// + public IEnumerable Ids { get; set; } = new List(); - public string? PlanId { get; init; } + /// + /// Filter users by plan ID (starts with plan_) + /// + public string? PlanId { get; set; } /// - /// Search filter + /// Search for users by name, keys or string traits /// - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/CreateEntityTraitDefinitionRequestBody.cs b/src/SchematicHQ.Client/Companies/Requests/CreateEntityTraitDefinitionRequestBody.cs index 114cbd6..6412bff 100644 --- a/src/SchematicHQ.Client/Companies/Requests/CreateEntityTraitDefinitionRequestBody.cs +++ b/src/SchematicHQ.Client/Companies/Requests/CreateEntityTraitDefinitionRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,14 +8,19 @@ namespace SchematicHQ.Client; public record CreateEntityTraitDefinitionRequestBody { [JsonPropertyName("display_name")] - public string? DisplayName { get; init; } + public string? DisplayName { get; set; } [JsonPropertyName("entity_type")] - public required CreateEntityTraitDefinitionRequestBodyEntityType EntityType { get; init; } + public required CreateEntityTraitDefinitionRequestBodyEntityType EntityType { get; set; } [JsonPropertyName("hierarchy")] - public IEnumerable Hierarchy { get; init; } = new List(); + public IEnumerable Hierarchy { get; set; } = new List(); [JsonPropertyName("trait_type")] - public required CreateEntityTraitDefinitionRequestBodyTraitType TraitType { get; init; } + public required CreateEntityTraitDefinitionRequestBodyTraitType TraitType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/GetActiveCompanySubscriptionRequest.cs b/src/SchematicHQ.Client/Companies/Requests/GetActiveCompanySubscriptionRequest.cs index e1ccb86..9179006 100644 --- a/src/SchematicHQ.Client/Companies/Requests/GetActiveCompanySubscriptionRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/GetActiveCompanySubscriptionRequest.cs @@ -1,16 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record GetActiveCompanySubscriptionRequest { - public required string CompanyId { get; init; } + public string? CompanyId { get; set; } + + public IEnumerable CompanyIds { get; set; } = new List(); /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/GetActiveDealsRequest.cs b/src/SchematicHQ.Client/Companies/Requests/GetActiveDealsRequest.cs index 3b94845..2fb46c0 100644 --- a/src/SchematicHQ.Client/Companies/Requests/GetActiveDealsRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/GetActiveDealsRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record GetActiveDealsRequest { - public required string CompanyId { get; init; } + public required string CompanyId { get; set; } - public required string DealStage { get; init; } + public required string DealStage { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/GetEntityTraitValuesRequest.cs b/src/SchematicHQ.Client/Companies/Requests/GetEntityTraitValuesRequest.cs index 87a4b9d..cc98bb7 100644 --- a/src/SchematicHQ.Client/Companies/Requests/GetEntityTraitValuesRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/GetEntityTraitValuesRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record GetEntityTraitValuesRequest { - public required string DefinitionId { get; init; } + public required string DefinitionId { get; set; } - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/GetOrCreateCompanyMembershipRequestBody.cs b/src/SchematicHQ.Client/Companies/Requests/GetOrCreateCompanyMembershipRequestBody.cs index 58b2a6d..5a6ea8b 100644 --- a/src/SchematicHQ.Client/Companies/Requests/GetOrCreateCompanyMembershipRequestBody.cs +++ b/src/SchematicHQ.Client/Companies/Requests/GetOrCreateCompanyMembershipRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,8 +8,13 @@ namespace SchematicHQ.Client; public record GetOrCreateCompanyMembershipRequestBody { [JsonPropertyName("company_id")] - public required string CompanyId { get; init; } + public required string CompanyId { get; set; } [JsonPropertyName("user_id")] - public required string UserId { get; init; } + public required string UserId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/ListCompaniesRequest.cs b/src/SchematicHQ.Client/Companies/Requests/ListCompaniesRequest.cs index 164ab9b..eca0276 100644 --- a/src/SchematicHQ.Client/Companies/Requests/ListCompaniesRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/ListCompaniesRequest.cs @@ -1,28 +1,48 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListCompaniesRequest { - public string? Ids { get; init; } + /// + /// Filter companies by multiple company IDs (starts with comp_) + /// + public IEnumerable Ids { get; set; } = new List(); - public string? PlanId { get; init; } + /// + /// Filter companies by plan ID (starts with plan_) + /// + public string? PlanId { get; set; } /// - /// Search filter + /// Search for companies by name, keys or string traits /// - public string? Q { get; init; } + public string? Q { get; set; } /// /// Filter out companies that already have a company override for the specified feature ID /// - public string? WithoutFeatureOverrideFor { get; init; } + public string? WithoutFeatureOverrideFor { get; set; } + + /// + /// Filter out companies that have a plan + /// + public bool? WithoutPlan { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/ListCompanyMembershipsRequest.cs b/src/SchematicHQ.Client/Companies/Requests/ListCompanyMembershipsRequest.cs index be29590..f4ff1a2 100644 --- a/src/SchematicHQ.Client/Companies/Requests/ListCompanyMembershipsRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/ListCompanyMembershipsRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListCompanyMembershipsRequest { - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } - public string? UserId { get; init; } + public string? UserId { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/ListEntityKeyDefinitionsRequest.cs b/src/SchematicHQ.Client/Companies/Requests/ListEntityKeyDefinitionsRequest.cs index 6456ad0..22590cd 100644 --- a/src/SchematicHQ.Client/Companies/Requests/ListEntityKeyDefinitionsRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/ListEntityKeyDefinitionsRequest.cs @@ -1,4 +1,4 @@ -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -6,19 +6,24 @@ namespace SchematicHQ.Client; public record ListEntityKeyDefinitionsRequest { - public ListEntityKeyDefinitionsRequestEntityType? EntityType { get; init; } + public ListEntityKeyDefinitionsRequestEntityType? EntityType { get; set; } - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/ListEntityTraitDefinitionsRequest.cs b/src/SchematicHQ.Client/Companies/Requests/ListEntityTraitDefinitionsRequest.cs index 9655846..aac6ed3 100644 --- a/src/SchematicHQ.Client/Companies/Requests/ListEntityTraitDefinitionsRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/ListEntityTraitDefinitionsRequest.cs @@ -1,4 +1,4 @@ -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -6,21 +6,26 @@ namespace SchematicHQ.Client; public record ListEntityTraitDefinitionsRequest { - public ListEntityTraitDefinitionsRequestEntityType? EntityType { get; init; } + public ListEntityTraitDefinitionsRequestEntityType? EntityType { get; set; } - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public ListEntityTraitDefinitionsRequestTraitType? TraitType { get; init; } + public string? Q { get; set; } - public string? Q { get; init; } + public ListEntityTraitDefinitionsRequestTraitType? TraitType { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/ListUsersRequest.cs b/src/SchematicHQ.Client/Companies/Requests/ListUsersRequest.cs index 3cbb221..6923ad4 100644 --- a/src/SchematicHQ.Client/Companies/Requests/ListUsersRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/ListUsersRequest.cs @@ -1,25 +1,43 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListUsersRequest { - public string? CompanyId { get; init; } + /// + /// Filter users by company ID (starts with comp_) + /// + public string? CompanyId { get; set; } - public string? Ids { get; init; } + /// + /// Filter users by multiple user IDs (starts with user_) + /// + public IEnumerable Ids { get; set; } = new List(); - public string? PlanId { get; init; } + /// + /// Filter users by plan ID (starts with plan_) + /// + public string? PlanId { get; set; } /// - /// Search filter + /// Search for users by name, keys or string traits /// - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/LookupCompanyRequest.cs b/src/SchematicHQ.Client/Companies/Requests/LookupCompanyRequest.cs index e5e41d1..5e3d9e4 100644 --- a/src/SchematicHQ.Client/Companies/Requests/LookupCompanyRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/LookupCompanyRequest.cs @@ -1,3 +1,7 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record LookupCompanyRequest @@ -5,5 +9,10 @@ public record LookupCompanyRequest /// /// Key/value pairs /// - public Dictionary Keys { get; init; } = new Dictionary(); + public Dictionary Keys { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/LookupUserRequest.cs b/src/SchematicHQ.Client/Companies/Requests/LookupUserRequest.cs index ff8a459..fe20c3d 100644 --- a/src/SchematicHQ.Client/Companies/Requests/LookupUserRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/LookupUserRequest.cs @@ -1,3 +1,7 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record LookupUserRequest @@ -5,5 +9,10 @@ public record LookupUserRequest /// /// Key/value pairs /// - public Dictionary Keys { get; init; } = new Dictionary(); + public Dictionary Keys { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Requests/UpdateEntityTraitDefinitionRequestBody.cs b/src/SchematicHQ.Client/Companies/Requests/UpdateEntityTraitDefinitionRequestBody.cs index 0eeee0c..52fcccf 100644 --- a/src/SchematicHQ.Client/Companies/Requests/UpdateEntityTraitDefinitionRequestBody.cs +++ b/src/SchematicHQ.Client/Companies/Requests/UpdateEntityTraitDefinitionRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,8 +8,13 @@ namespace SchematicHQ.Client; public record UpdateEntityTraitDefinitionRequestBody { [JsonPropertyName("display_name")] - public string? DisplayName { get; init; } + public string? DisplayName { get; set; } [JsonPropertyName("trait_type")] - public required UpdateEntityTraitDefinitionRequestBodyTraitType TraitType { get; init; } + public required UpdateEntityTraitDefinitionRequestBodyTraitType TraitType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/CountCompaniesParams.cs b/src/SchematicHQ.Client/Companies/Types/CountCompaniesParams.cs index 43a0c33..9b16a90 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountCompaniesParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountCompaniesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,33 +7,50 @@ namespace SchematicHQ.Client; public record CountCompaniesParams { + /// + /// Filter companies by multiple company IDs (starts with comp_) + /// [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + /// + /// Filter companies by plan ID (starts with plan_) + /// [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } /// - /// Search filter + /// Search for companies by name, keys or string traits /// [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } /// /// Filter out companies that already have a company override for the specified feature ID /// [JsonPropertyName("without_feature_override_for")] - public string? WithoutFeatureOverrideFor { get; init; } + public string? WithoutFeatureOverrideFor { get; set; } + + /// + /// Filter out companies that have a plan + /// + [JsonPropertyName("without_plan")] + public bool? WithoutPlan { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/CountCompaniesResponse.cs b/src/SchematicHQ.Client/Companies/Types/CountCompaniesResponse.cs index e647a94..5702ed3 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountCompaniesResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountCompaniesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountCompaniesResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountCompaniesParams Params { get; init; } + public required CountCompaniesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsParams.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsParams.cs index b5bf83f..017dc77 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsParams.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,23 +8,28 @@ namespace SchematicHQ.Client; public record CountEntityKeyDefinitionsParams { [JsonPropertyName("entity_type")] - public CountEntityKeyDefinitionsResponseParamsEntityType? EntityType { get; init; } + public CountEntityKeyDefinitionsResponseParamsEntityType? EntityType { get; set; } [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsRequestEntityType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsRequestEntityType.cs index dbff765..a9a0c75 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsRequestEntityType.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsRequestEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CountEntityKeyDefinitionsRequestEntityType { [EnumMember(Value = "company")] Company, [EnumMember(Value = "user")] - User + User, } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponse.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponse.cs index 8d84591..8a511af 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountEntityKeyDefinitionsResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountEntityKeyDefinitionsParams Params { get; init; } + public required CountEntityKeyDefinitionsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponseParamsEntityType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponseParamsEntityType.cs index e2488a5..24b428e 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponseParamsEntityType.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponseParamsEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CountEntityKeyDefinitionsResponseParamsEntityType { [EnumMember(Value = "company")] Company, [EnumMember(Value = "user")] - User + User, } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsParams.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsParams.cs index 990818a..434b19a 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsParams.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,26 +8,31 @@ namespace SchematicHQ.Client; public record CountEntityTraitDefinitionsParams { [JsonPropertyName("entity_type")] - public CountEntityTraitDefinitionsResponseParamsEntityType? EntityType { get; init; } + public CountEntityTraitDefinitionsResponseParamsEntityType? EntityType { get; set; } [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } [JsonPropertyName("trait_type")] - public CountEntityTraitDefinitionsResponseParamsTraitType? TraitType { get; init; } + public CountEntityTraitDefinitionsResponseParamsTraitType? TraitType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestEntityType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestEntityType.cs index ace1a09..2516201 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestEntityType.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CountEntityTraitDefinitionsRequestEntityType { [EnumMember(Value = "company")] Company, [EnumMember(Value = "user")] - User + User, } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestTraitType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestTraitType.cs index e1a1d2a..bd5c8f8 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestTraitType.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestTraitType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CountEntityTraitDefinitionsRequestTraitType { [EnumMember(Value = "boolean")] @@ -26,5 +25,5 @@ public enum CountEntityTraitDefinitionsRequestTraitType String, [EnumMember(Value = "url")] - Url + Url, } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponse.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponse.cs index f1868d8..412630d 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountEntityTraitDefinitionsResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountEntityTraitDefinitionsParams Params { get; init; } + public required CountEntityTraitDefinitionsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsEntityType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsEntityType.cs index 5aa0158..2c0fafa 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsEntityType.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CountEntityTraitDefinitionsResponseParamsEntityType { [EnumMember(Value = "company")] Company, [EnumMember(Value = "user")] - User + User, } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsTraitType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsTraitType.cs index 74a4cb3..c9f1fd2 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsTraitType.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsTraitType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CountEntityTraitDefinitionsResponseParamsTraitType { [EnumMember(Value = "boolean")] @@ -26,5 +25,5 @@ public enum CountEntityTraitDefinitionsResponseParamsTraitType String, [EnumMember(Value = "url")] - Url + Url, } diff --git a/src/SchematicHQ.Client/Companies/Types/CountUsersParams.cs b/src/SchematicHQ.Client/Companies/Types/CountUsersParams.cs index c1247a5..7b7261a 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountUsersParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountUsersParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,30 +7,44 @@ namespace SchematicHQ.Client; public record CountUsersParams { + /// + /// Filter users by company ID (starts with comp_) + /// [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } + /// + /// Filter users by multiple user IDs (starts with user_) + /// [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + /// + /// Filter users by plan ID (starts with plan_) + /// [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } /// - /// Search filter + /// Search for users by name, keys or string traits /// [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/CountUsersResponse.cs b/src/SchematicHQ.Client/Companies/Types/CountUsersResponse.cs index 4fc97b6..fd4005e 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountUsersResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountUsersResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountUsersResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountUsersParams Params { get; init; } + public required CountUsersParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/CreateCompanyResponse.cs b/src/SchematicHQ.Client/Companies/Types/CreateCompanyResponse.cs index 80756b7..f464c93 100644 --- a/src/SchematicHQ.Client/Companies/Types/CreateCompanyResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/CreateCompanyResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateCompanyResponse { [JsonPropertyName("data")] - public required CompanyDetailResponseData Data { get; init; } + public required CompanyDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/CreateEntityTraitDefinitionRequestBodyEntityType.cs b/src/SchematicHQ.Client/Companies/Types/CreateEntityTraitDefinitionRequestBodyEntityType.cs index a0fe1fc..123cd75 100644 --- a/src/SchematicHQ.Client/Companies/Types/CreateEntityTraitDefinitionRequestBodyEntityType.cs +++ b/src/SchematicHQ.Client/Companies/Types/CreateEntityTraitDefinitionRequestBodyEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateEntityTraitDefinitionRequestBodyEntityType { [EnumMember(Value = "company")] Company, [EnumMember(Value = "user")] - User + User, } diff --git a/src/SchematicHQ.Client/Companies/Types/CreateEntityTraitDefinitionRequestBodyTraitType.cs b/src/SchematicHQ.Client/Companies/Types/CreateEntityTraitDefinitionRequestBodyTraitType.cs index 2440022..4666da0 100644 --- a/src/SchematicHQ.Client/Companies/Types/CreateEntityTraitDefinitionRequestBodyTraitType.cs +++ b/src/SchematicHQ.Client/Companies/Types/CreateEntityTraitDefinitionRequestBodyTraitType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateEntityTraitDefinitionRequestBodyTraitType { [EnumMember(Value = "boolean")] @@ -26,5 +25,5 @@ public enum CreateEntityTraitDefinitionRequestBodyTraitType String, [EnumMember(Value = "url")] - Url + Url, } diff --git a/src/SchematicHQ.Client/Companies/Types/CreateUserResponse.cs b/src/SchematicHQ.Client/Companies/Types/CreateUserResponse.cs index b4eb2b1..2c0a887 100644 --- a/src/SchematicHQ.Client/Companies/Types/CreateUserResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/CreateUserResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateUserResponse { [JsonPropertyName("data")] - public required UserDetailResponseData Data { get; init; } + public required UserDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/DeleteCompanyByKeysResponse.cs b/src/SchematicHQ.Client/Companies/Types/DeleteCompanyByKeysResponse.cs index da78b3b..3ee8f43 100644 --- a/src/SchematicHQ.Client/Companies/Types/DeleteCompanyByKeysResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/DeleteCompanyByKeysResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteCompanyByKeysResponse { [JsonPropertyName("data")] - public required CompanyResponseData Data { get; init; } + public required CompanyResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/DeleteCompanyMembershipResponse.cs b/src/SchematicHQ.Client/Companies/Types/DeleteCompanyMembershipResponse.cs index f85ac43..d33df30 100644 --- a/src/SchematicHQ.Client/Companies/Types/DeleteCompanyMembershipResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/DeleteCompanyMembershipResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteCompanyMembershipResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/DeleteCompanyResponse.cs b/src/SchematicHQ.Client/Companies/Types/DeleteCompanyResponse.cs index 1b3236a..4330700 100644 --- a/src/SchematicHQ.Client/Companies/Types/DeleteCompanyResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/DeleteCompanyResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteCompanyResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/DeleteUserByKeysResponse.cs b/src/SchematicHQ.Client/Companies/Types/DeleteUserByKeysResponse.cs index 26fb42c..724ebc6 100644 --- a/src/SchematicHQ.Client/Companies/Types/DeleteUserByKeysResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/DeleteUserByKeysResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteUserByKeysResponse { [JsonPropertyName("data")] - public required UserResponseData Data { get; init; } + public required UserResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/DeleteUserResponse.cs b/src/SchematicHQ.Client/Companies/Types/DeleteUserResponse.cs index 048ca5a..8dfe3e6 100644 --- a/src/SchematicHQ.Client/Companies/Types/DeleteUserResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/DeleteUserResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteUserResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionParams.cs b/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionParams.cs index 99dc620..7b80bf2 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,17 +8,25 @@ namespace SchematicHQ.Client; public record GetActiveCompanySubscriptionParams { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } + + [JsonPropertyName("company_ids")] + public IEnumerable? CompanyIds { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionResponse.cs index fdbec91..480ab5d 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record GetActiveCompanySubscriptionResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required GetActiveCompanySubscriptionParams Params { get; init; } + public required GetActiveCompanySubscriptionParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetActiveDealsParams.cs b/src/SchematicHQ.Client/Companies/Types/GetActiveDealsParams.cs index 6715e47..754a9ac 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetActiveDealsParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetActiveDealsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record GetActiveDealsParams { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("deal_stage")] - public string? DealStage { get; init; } + public string? DealStage { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetActiveDealsResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetActiveDealsResponse.cs index 8a0cfab..1277f53 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetActiveDealsResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetActiveDealsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record GetActiveDealsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required GetActiveDealsParams Params { get; init; } + public required GetActiveDealsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetCompanyResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetCompanyResponse.cs index 4465eed..a48c6fe 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetCompanyResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetCompanyResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetCompanyResponse { [JsonPropertyName("data")] - public required CompanyDetailResponseData Data { get; init; } + public required CompanyDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetEntityTraitDefinitionResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetEntityTraitDefinitionResponse.cs index 1613c5e..2021b9f 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetEntityTraitDefinitionResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetEntityTraitDefinitionResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetEntityTraitDefinitionResponse { [JsonPropertyName("data")] - public required EntityTraitDefinitionResponseData Data { get; init; } + public required EntityTraitDefinitionResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesParams.cs b/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesParams.cs index e300409..6910960 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record GetEntityTraitValuesParams { [JsonPropertyName("definition_id")] - public string? DefinitionId { get; init; } + public string? DefinitionId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesResponse.cs index eb2ac63..33390a3 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,11 +11,16 @@ public record GetEntityTraitValuesResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = new List(); + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required GetEntityTraitValuesParams Params { get; init; } + public required GetEntityTraitValuesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetOrCreateCompanyMembershipResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetOrCreateCompanyMembershipResponse.cs index 8f6835d..00e7fc4 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetOrCreateCompanyMembershipResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetOrCreateCompanyMembershipResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetOrCreateCompanyMembershipResponse { [JsonPropertyName("data")] - public required CompanyMembershipDetailResponseData Data { get; init; } + public required CompanyMembershipDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetOrCreateEntityTraitDefinitionResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetOrCreateEntityTraitDefinitionResponse.cs index 773f13a..ea5dcee 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetOrCreateEntityTraitDefinitionResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetOrCreateEntityTraitDefinitionResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetOrCreateEntityTraitDefinitionResponse { [JsonPropertyName("data")] - public required EntityTraitDefinitionResponseData Data { get; init; } + public required EntityTraitDefinitionResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/GetUserResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetUserResponse.cs index 9f68162..0fd3a8a 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetUserResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetUserResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetUserResponse { [JsonPropertyName("data")] - public required UserDetailResponseData Data { get; init; } + public required UserDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListCompaniesParams.cs b/src/SchematicHQ.Client/Companies/Types/ListCompaniesParams.cs index cb787f5..60309e1 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListCompaniesParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListCompaniesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,33 +7,50 @@ namespace SchematicHQ.Client; public record ListCompaniesParams { + /// + /// Filter companies by multiple company IDs (starts with comp_) + /// [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + /// + /// Filter companies by plan ID (starts with plan_) + /// [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } /// - /// Search filter + /// Search for companies by name, keys or string traits /// [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } /// /// Filter out companies that already have a company override for the specified feature ID /// [JsonPropertyName("without_feature_override_for")] - public string? WithoutFeatureOverrideFor { get; init; } + public string? WithoutFeatureOverrideFor { get; set; } + + /// + /// Filter out companies that have a plan + /// + [JsonPropertyName("without_plan")] + public bool? WithoutPlan { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListCompaniesResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListCompaniesResponse.cs index ed6a1d5..e1a5183 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListCompaniesResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListCompaniesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListCompaniesResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListCompaniesParams Params { get; init; } + public required ListCompaniesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsParams.cs b/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsParams.cs index a7caa12..7608587 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record ListCompanyMembershipsParams { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("user_id")] - public string? UserId { get; init; } + public string? UserId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsResponse.cs index a56c644..06b5ca0 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListCompanyMembershipsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListCompanyMembershipsParams Params { get; init; } + public required ListCompanyMembershipsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsParams.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsParams.cs index e1f41ae..8baf74d 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsParams.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,23 +8,28 @@ namespace SchematicHQ.Client; public record ListEntityKeyDefinitionsParams { [JsonPropertyName("entity_type")] - public ListEntityKeyDefinitionsResponseParamsEntityType? EntityType { get; init; } + public ListEntityKeyDefinitionsResponseParamsEntityType? EntityType { get; set; } [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsRequestEntityType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsRequestEntityType.cs index f8685a1..e3ae243 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsRequestEntityType.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsRequestEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum ListEntityKeyDefinitionsRequestEntityType { [EnumMember(Value = "company")] Company, [EnumMember(Value = "user")] - User + User, } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponse.cs index 33a6cbe..41f2bc8 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListEntityKeyDefinitionsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListEntityKeyDefinitionsParams Params { get; init; } + public required ListEntityKeyDefinitionsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponseParamsEntityType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponseParamsEntityType.cs index a0369b8..32a9156 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponseParamsEntityType.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponseParamsEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum ListEntityKeyDefinitionsResponseParamsEntityType { [EnumMember(Value = "company")] Company, [EnumMember(Value = "user")] - User + User, } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsParams.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsParams.cs index bc9f9c1..e309005 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsParams.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,26 +8,31 @@ namespace SchematicHQ.Client; public record ListEntityTraitDefinitionsParams { [JsonPropertyName("entity_type")] - public ListEntityTraitDefinitionsResponseParamsEntityType? EntityType { get; init; } + public ListEntityTraitDefinitionsResponseParamsEntityType? EntityType { get; set; } [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } [JsonPropertyName("trait_type")] - public ListEntityTraitDefinitionsResponseParamsTraitType? TraitType { get; init; } + public ListEntityTraitDefinitionsResponseParamsTraitType? TraitType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestEntityType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestEntityType.cs index c27869a..9163dad 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestEntityType.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum ListEntityTraitDefinitionsRequestEntityType { [EnumMember(Value = "company")] Company, [EnumMember(Value = "user")] - User + User, } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestTraitType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestTraitType.cs index 8f9d93b..790bb1a 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestTraitType.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestTraitType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum ListEntityTraitDefinitionsRequestTraitType { [EnumMember(Value = "boolean")] @@ -26,5 +25,5 @@ public enum ListEntityTraitDefinitionsRequestTraitType String, [EnumMember(Value = "url")] - Url + Url, } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponse.cs index a3054ee..19dac34 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListEntityTraitDefinitionsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListEntityTraitDefinitionsParams Params { get; init; } + public required ListEntityTraitDefinitionsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsEntityType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsEntityType.cs index 45081aa..ed67431 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsEntityType.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum ListEntityTraitDefinitionsResponseParamsEntityType { [EnumMember(Value = "company")] Company, [EnumMember(Value = "user")] - User + User, } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsTraitType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsTraitType.cs index c9ad83f..706b00b 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsTraitType.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsTraitType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum ListEntityTraitDefinitionsResponseParamsTraitType { [EnumMember(Value = "boolean")] @@ -26,5 +25,5 @@ public enum ListEntityTraitDefinitionsResponseParamsTraitType String, [EnumMember(Value = "url")] - Url + Url, } diff --git a/src/SchematicHQ.Client/Companies/Types/ListUsersParams.cs b/src/SchematicHQ.Client/Companies/Types/ListUsersParams.cs index c2fc42b..8420f84 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListUsersParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListUsersParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,30 +7,44 @@ namespace SchematicHQ.Client; public record ListUsersParams { + /// + /// Filter users by company ID (starts with comp_) + /// [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } + /// + /// Filter users by multiple user IDs (starts with user_) + /// [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + /// + /// Filter users by plan ID (starts with plan_) + /// [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } /// - /// Search filter + /// Search for users by name, keys or string traits /// [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListUsersResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListUsersResponse.cs index fe89a99..a951ac3 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListUsersResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListUsersResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListUsersResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListUsersParams Params { get; init; } + public required ListUsersParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/LookupCompanyParams.cs b/src/SchematicHQ.Client/Companies/Types/LookupCompanyParams.cs index 6e30482..fd73891 100644 --- a/src/SchematicHQ.Client/Companies/Types/LookupCompanyParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/LookupCompanyParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,5 +8,10 @@ namespace SchematicHQ.Client; public record LookupCompanyParams { [JsonPropertyName("keys")] - public Dictionary? Keys { get; init; } + public Dictionary? Keys { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/LookupCompanyResponse.cs b/src/SchematicHQ.Client/Companies/Types/LookupCompanyResponse.cs index 802bb81..6513501 100644 --- a/src/SchematicHQ.Client/Companies/Types/LookupCompanyResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/LookupCompanyResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record LookupCompanyResponse { [JsonPropertyName("data")] - public required CompanyDetailResponseData Data { get; init; } + public required CompanyDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required LookupCompanyParams Params { get; init; } + public required LookupCompanyParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/LookupUserParams.cs b/src/SchematicHQ.Client/Companies/Types/LookupUserParams.cs index bf654f5..04252ad 100644 --- a/src/SchematicHQ.Client/Companies/Types/LookupUserParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/LookupUserParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,5 +8,10 @@ namespace SchematicHQ.Client; public record LookupUserParams { [JsonPropertyName("keys")] - public Dictionary? Keys { get; init; } + public Dictionary? Keys { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/LookupUserResponse.cs b/src/SchematicHQ.Client/Companies/Types/LookupUserResponse.cs index 9c95a83..4800350 100644 --- a/src/SchematicHQ.Client/Companies/Types/LookupUserResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/LookupUserResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record LookupUserResponse { [JsonPropertyName("data")] - public required UserDetailResponseData Data { get; init; } + public required UserDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required LookupUserParams Params { get; init; } + public required LookupUserParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/UpdateEntityTraitDefinitionRequestBodyTraitType.cs b/src/SchematicHQ.Client/Companies/Types/UpdateEntityTraitDefinitionRequestBodyTraitType.cs index 3b8ec57..608f2cc 100644 --- a/src/SchematicHQ.Client/Companies/Types/UpdateEntityTraitDefinitionRequestBodyTraitType.cs +++ b/src/SchematicHQ.Client/Companies/Types/UpdateEntityTraitDefinitionRequestBodyTraitType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdateEntityTraitDefinitionRequestBodyTraitType { [EnumMember(Value = "boolean")] @@ -26,5 +25,5 @@ public enum UpdateEntityTraitDefinitionRequestBodyTraitType String, [EnumMember(Value = "url")] - Url + Url, } diff --git a/src/SchematicHQ.Client/Companies/Types/UpdateEntityTraitDefinitionResponse.cs b/src/SchematicHQ.Client/Companies/Types/UpdateEntityTraitDefinitionResponse.cs index 967aa18..486bae3 100644 --- a/src/SchematicHQ.Client/Companies/Types/UpdateEntityTraitDefinitionResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/UpdateEntityTraitDefinitionResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdateEntityTraitDefinitionResponse { [JsonPropertyName("data")] - public required EntityTraitDefinitionResponseData Data { get; init; } + public required EntityTraitDefinitionResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/UpsertCompanyResponse.cs b/src/SchematicHQ.Client/Companies/Types/UpsertCompanyResponse.cs index c0c6d41..dff0d17 100644 --- a/src/SchematicHQ.Client/Companies/Types/UpsertCompanyResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/UpsertCompanyResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertCompanyResponse { [JsonPropertyName("data")] - public required CompanyDetailResponseData Data { get; init; } + public required CompanyDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/UpsertCompanyTraitResponse.cs b/src/SchematicHQ.Client/Companies/Types/UpsertCompanyTraitResponse.cs index 2059931..00cc4d9 100644 --- a/src/SchematicHQ.Client/Companies/Types/UpsertCompanyTraitResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/UpsertCompanyTraitResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertCompanyTraitResponse { [JsonPropertyName("data")] - public required CompanyDetailResponseData Data { get; init; } + public required CompanyDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/UpsertUserResponse.cs b/src/SchematicHQ.Client/Companies/Types/UpsertUserResponse.cs index 6af8964..c70b190 100644 --- a/src/SchematicHQ.Client/Companies/Types/UpsertUserResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/UpsertUserResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertUserResponse { [JsonPropertyName("data")] - public required UserDetailResponseData Data { get; init; } + public required UserDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Companies/Types/UpsertUserTraitResponse.cs b/src/SchematicHQ.Client/Companies/Types/UpsertUserTraitResponse.cs index a4652d1..3f6b163 100644 --- a/src/SchematicHQ.Client/Companies/Types/UpsertUserTraitResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/UpsertUserTraitResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertUserTraitResponse { [JsonPropertyName("data")] - public required UserDetailResponseData Data { get; init; } + public required UserDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/ComponentsClient.cs b/src/SchematicHQ.Client/Components/ComponentsClient.cs index 266f819..af62b5d 100644 --- a/src/SchematicHQ.Client/Components/ComponentsClient.cs +++ b/src/SchematicHQ.Client/Components/ComponentsClient.cs @@ -1,24 +1,33 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class ComponentsClient +public partial class ComponentsClient { private RawClient _client; - public ComponentsClient(RawClient client) + internal ComponentsClient(RawClient client) { _client = client; } - public async Task ListComponentsAsync(ListComponentsRequest request) + /// + /// + /// await client.Components.ListComponentsAsync(new ListComponentsRequest()); + /// + /// + public async Task ListComponentsAsync( + ListComponentsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.Q != null) { _query["q"] = request.Q; @@ -34,97 +43,313 @@ public async Task ListComponentsAsync(ListComponentsRequ var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "components", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Components.CreateComponentAsync( + /// new CreateComponentRequestBody + /// { + /// EntityType = CreateComponentRequestBodyEntityType.Entitlement, + /// Name = "name", + /// } + /// ); + /// + /// public async Task CreateComponentAsync( - CreateComponentRequestBody request + CreateComponentRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "components", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetComponentAsync(string componentId) + /// + /// + /// await client.Components.GetComponentAsync("component_id"); + /// + /// + public async Task GetComponentAsync( + string componentId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"components/{componentId}" - } + Path = $"components/{componentId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Components.UpdateComponentAsync("component_id", new UpdateComponentRequestBody()); + /// + /// public async Task UpdateComponentAsync( string componentId, - UpdateComponentRequestBody request + UpdateComponentRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"components/{componentId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteComponentAsync(string componentId) + /// + /// + /// await client.Components.DeleteComponentAsync("component_id"); + /// + /// + public async Task DeleteComponentAsync( + string componentId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, - Path = $"components/{componentId}" - } + Path = $"components/{componentId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CountComponentsAsync(CountComponentsRequest request) + /// + /// + /// await client.Components.CountComponentsAsync(new CountComponentsRequest()); + /// + /// + public async Task CountComponentsAsync( + CountComponentsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.Q != null) { _query["q"] = request.Q; @@ -140,16 +365,118 @@ public async Task CountComponentsAsync(CountComponentsR var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "components/count", - Query = _query + Query = _query, + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Components.PreviewComponentDataAsync(new PreviewComponentDataRequest()); + /// + /// + public async Task PreviewComponentDataAsync( + PreviewComponentDataRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _query = new Dictionary(); + if (request.CompanyId != null) + { + _query["company_id"] = request.CompanyId; + } + if (request.ComponentId != null) + { + _query["component_id"] = request.ComponentId; + } + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = "components/preview-data", + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } } diff --git a/src/SchematicHQ.Client/Components/Requests/CountComponentsRequest.cs b/src/SchematicHQ.Client/Components/Requests/CountComponentsRequest.cs index a6ce797..2c8615a 100644 --- a/src/SchematicHQ.Client/Components/Requests/CountComponentsRequest.cs +++ b/src/SchematicHQ.Client/Components/Requests/CountComponentsRequest.cs @@ -1,16 +1,25 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountComponentsRequest { - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Requests/CreateComponentRequestBody.cs b/src/SchematicHQ.Client/Components/Requests/CreateComponentRequestBody.cs index 2ab60f3..215aa42 100644 --- a/src/SchematicHQ.Client/Components/Requests/CreateComponentRequestBody.cs +++ b/src/SchematicHQ.Client/Components/Requests/CreateComponentRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateComponentRequestBody { [JsonPropertyName("ast")] - public Dictionary? Ast { get; init; } + public Dictionary? Ast { get; set; } [JsonPropertyName("entity_type")] - public required CreateComponentRequestBodyEntityType EntityType { get; init; } + public required CreateComponentRequestBodyEntityType EntityType { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Requests/ListComponentsRequest.cs b/src/SchematicHQ.Client/Components/Requests/ListComponentsRequest.cs index cf4d61d..f034975 100644 --- a/src/SchematicHQ.Client/Components/Requests/ListComponentsRequest.cs +++ b/src/SchematicHQ.Client/Components/Requests/ListComponentsRequest.cs @@ -1,16 +1,25 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListComponentsRequest { - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Requests/PreviewComponentDataRequest.cs b/src/SchematicHQ.Client/Components/Requests/PreviewComponentDataRequest.cs new file mode 100644 index 0000000..164362b --- /dev/null +++ b/src/SchematicHQ.Client/Components/Requests/PreviewComponentDataRequest.cs @@ -0,0 +1,17 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PreviewComponentDataRequest +{ + public string? CompanyId { get; set; } + + public string? ComponentId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Components/Requests/UpdateComponentRequestBody.cs b/src/SchematicHQ.Client/Components/Requests/UpdateComponentRequestBody.cs index 449667c..10f9333 100644 --- a/src/SchematicHQ.Client/Components/Requests/UpdateComponentRequestBody.cs +++ b/src/SchematicHQ.Client/Components/Requests/UpdateComponentRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,14 +8,19 @@ namespace SchematicHQ.Client; public record UpdateComponentRequestBody { [JsonPropertyName("ast")] - public Dictionary? Ast { get; init; } + public Dictionary? Ast { get; set; } [JsonPropertyName("entity_type")] - public UpdateComponentRequestBodyEntityType? EntityType { get; init; } + public UpdateComponentRequestBodyEntityType? EntityType { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } [JsonPropertyName("state")] - public UpdateComponentRequestBodyState? State { get; init; } + public UpdateComponentRequestBodyState? State { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Types/CountComponentsParams.cs b/src/SchematicHQ.Client/Components/Types/CountComponentsParams.cs index 305812e..8982395 100644 --- a/src/SchematicHQ.Client/Components/Types/CountComponentsParams.cs +++ b/src/SchematicHQ.Client/Components/Types/CountComponentsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,14 +11,19 @@ public record CountComponentsParams /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Types/CountComponentsResponse.cs b/src/SchematicHQ.Client/Components/Types/CountComponentsResponse.cs index 8ba914a..b94168a 100644 --- a/src/SchematicHQ.Client/Components/Types/CountComponentsResponse.cs +++ b/src/SchematicHQ.Client/Components/Types/CountComponentsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountComponentsResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountComponentsParams Params { get; init; } + public required CountComponentsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Types/CreateComponentRequestBodyEntityType.cs b/src/SchematicHQ.Client/Components/Types/CreateComponentRequestBodyEntityType.cs index dbc8258..75ca62e 100644 --- a/src/SchematicHQ.Client/Components/Types/CreateComponentRequestBodyEntityType.cs +++ b/src/SchematicHQ.Client/Components/Types/CreateComponentRequestBodyEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateComponentRequestBodyEntityType { [EnumMember(Value = "entitlement")] Entitlement, [EnumMember(Value = "billing")] - Billing + Billing, } diff --git a/src/SchematicHQ.Client/Components/Types/CreateComponentResponse.cs b/src/SchematicHQ.Client/Components/Types/CreateComponentResponse.cs index 81a333a..5c16b63 100644 --- a/src/SchematicHQ.Client/Components/Types/CreateComponentResponse.cs +++ b/src/SchematicHQ.Client/Components/Types/CreateComponentResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateComponentResponse { [JsonPropertyName("data")] - public required ComponentResponseData Data { get; init; } + public required ComponentResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Types/DeleteComponentResponse.cs b/src/SchematicHQ.Client/Components/Types/DeleteComponentResponse.cs index 766f64a..6ff69c9 100644 --- a/src/SchematicHQ.Client/Components/Types/DeleteComponentResponse.cs +++ b/src/SchematicHQ.Client/Components/Types/DeleteComponentResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteComponentResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Types/GetComponentResponse.cs b/src/SchematicHQ.Client/Components/Types/GetComponentResponse.cs index eb6d6ac..e2230ff 100644 --- a/src/SchematicHQ.Client/Components/Types/GetComponentResponse.cs +++ b/src/SchematicHQ.Client/Components/Types/GetComponentResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetComponentResponse { [JsonPropertyName("data")] - public required ComponentResponseData Data { get; init; } + public required ComponentResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Types/ListComponentsParams.cs b/src/SchematicHQ.Client/Components/Types/ListComponentsParams.cs index 7a23044..d1a100c 100644 --- a/src/SchematicHQ.Client/Components/Types/ListComponentsParams.cs +++ b/src/SchematicHQ.Client/Components/Types/ListComponentsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,14 +11,19 @@ public record ListComponentsParams /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Types/ListComponentsResponse.cs b/src/SchematicHQ.Client/Components/Types/ListComponentsResponse.cs index 0b45167..c54624f 100644 --- a/src/SchematicHQ.Client/Components/Types/ListComponentsResponse.cs +++ b/src/SchematicHQ.Client/Components/Types/ListComponentsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListComponentsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListComponentsParams Params { get; init; } + public required ListComponentsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Components/Types/PreviewComponentDataParams.cs b/src/SchematicHQ.Client/Components/Types/PreviewComponentDataParams.cs new file mode 100644 index 0000000..5cd12fd --- /dev/null +++ b/src/SchematicHQ.Client/Components/Types/PreviewComponentDataParams.cs @@ -0,0 +1,20 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PreviewComponentDataParams +{ + [JsonPropertyName("company_id")] + public string? CompanyId { get; set; } + + [JsonPropertyName("component_id")] + public string? ComponentId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Components/Types/PreviewComponentDataResponse.cs b/src/SchematicHQ.Client/Components/Types/PreviewComponentDataResponse.cs new file mode 100644 index 0000000..f4a24ad --- /dev/null +++ b/src/SchematicHQ.Client/Components/Types/PreviewComponentDataResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PreviewComponentDataResponse +{ + [JsonPropertyName("data")] + public required ComponentPreviewResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public required PreviewComponentDataParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Components/Types/UpdateComponentRequestBodyEntityType.cs b/src/SchematicHQ.Client/Components/Types/UpdateComponentRequestBodyEntityType.cs index f0d0785..d49ee20 100644 --- a/src/SchematicHQ.Client/Components/Types/UpdateComponentRequestBodyEntityType.cs +++ b/src/SchematicHQ.Client/Components/Types/UpdateComponentRequestBodyEntityType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdateComponentRequestBodyEntityType { [EnumMember(Value = "entitlement")] Entitlement, [EnumMember(Value = "billing")] - Billing + Billing, } diff --git a/src/SchematicHQ.Client/Components/Types/UpdateComponentRequestBodyState.cs b/src/SchematicHQ.Client/Components/Types/UpdateComponentRequestBodyState.cs index ec33a9b..65a6408 100644 --- a/src/SchematicHQ.Client/Components/Types/UpdateComponentRequestBodyState.cs +++ b/src/SchematicHQ.Client/Components/Types/UpdateComponentRequestBodyState.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdateComponentRequestBodyState { [EnumMember(Value = "draft")] Draft, [EnumMember(Value = "live")] - Live + Live, } diff --git a/src/SchematicHQ.Client/Components/Types/UpdateComponentResponse.cs b/src/SchematicHQ.Client/Components/Types/UpdateComponentResponse.cs index c0782d9..1ce1236 100644 --- a/src/SchematicHQ.Client/Components/Types/UpdateComponentResponse.cs +++ b/src/SchematicHQ.Client/Components/Types/UpdateComponentResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdateComponentResponse { [JsonPropertyName("data")] - public required ComponentResponseData Data { get; init; } + public required ComponentResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Core/ClientOptions.cs b/src/SchematicHQ.Client/Core/ClientOptions.cs deleted file mode 100644 index 32105ab..0000000 --- a/src/SchematicHQ.Client/Core/ClientOptions.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Net.Http; -using SchematicHQ.Client.Core; - -#nullable enable - -namespace SchematicHQ.Client.Core; - -public partial class ClientOptions -{ - /// - /// The Base URL for the API. - /// - public string BaseUrl { get; init; } = Environments.DEFAULT; - - /// - /// The http client used to make requests. - /// - public HttpClient HttpClient { get; init; } = new HttpClient(); - - /// - /// The http client used to make requests. - /// - public int MaxRetries { get; init; } = 2; - - /// - /// The timeout for the request in seconds. - /// - public int TimeoutInSeconds { get; init; } = 30; -} diff --git a/src/SchematicHQ.Client/Core/CollectionItemSerializer.cs b/src/SchematicHQ.Client/Core/CollectionItemSerializer.cs index 9f421d9..0c519fe 100644 --- a/src/SchematicHQ.Client/Core/CollectionItemSerializer.cs +++ b/src/SchematicHQ.Client/Core/CollectionItemSerializer.cs @@ -10,7 +10,7 @@ namespace SchematicHQ.Client.Core; /// /// Type of item to convert. /// Converter to use for individual items. -public class CollectionItemSerializer +internal class CollectionItemSerializer : JsonConverter> where TConverterType : JsonConverter { diff --git a/src/SchematicHQ.Client/Core/Constants.cs b/src/SchematicHQ.Client/Core/Constants.cs new file mode 100644 index 0000000..3dbad7a --- /dev/null +++ b/src/SchematicHQ.Client/Core/Constants.cs @@ -0,0 +1,7 @@ +namespace SchematicHQ.Client.Core; + +internal static class Constants +{ + public const string DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffK"; + public const string DateFormat = "yyyy-MM-dd"; +} diff --git a/src/SchematicHQ.Client/Core/DateTimeSerializer.cs b/src/SchematicHQ.Client/Core/DateTimeSerializer.cs new file mode 100644 index 0000000..dea9165 --- /dev/null +++ b/src/SchematicHQ.Client/Core/DateTimeSerializer.cs @@ -0,0 +1,22 @@ +using System.Globalization; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace SchematicHQ.Client.Core; + +internal class DateTimeSerializer : JsonConverter +{ + public override DateTime Read( + ref Utf8JsonReader reader, + System.Type typeToConvert, + JsonSerializerOptions options + ) + { + return DateTime.Parse(reader.GetString()!, null, DateTimeStyles.RoundtripKind); + } + + public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) + { + writer.WriteStringValue(value.ToString(Constants.DateTimeFormat)); + } +} diff --git a/src/SchematicHQ.Client/Core/StringEnumSerializer.cs b/src/SchematicHQ.Client/Core/EnumSerializer.cs similarity index 94% rename from src/SchematicHQ.Client/Core/StringEnumSerializer.cs rename to src/SchematicHQ.Client/Core/EnumSerializer.cs index 9942342..1d15302 100644 --- a/src/SchematicHQ.Client/Core/StringEnumSerializer.cs +++ b/src/SchematicHQ.Client/Core/EnumSerializer.cs @@ -4,13 +4,13 @@ namespace SchematicHQ.Client.Core; -public class StringEnumSerializer : JsonConverter +internal class EnumSerializer : JsonConverter where TEnum : struct, System.Enum { private readonly Dictionary _enumToString = new(); private readonly Dictionary _stringToEnum = new(); - public StringEnumSerializer() + public EnumSerializer() { var type = typeof(TEnum); var values = Enum.GetValues(type); diff --git a/src/SchematicHQ.Client/Core/Extensions.cs b/src/SchematicHQ.Client/Core/Extensions.cs new file mode 100644 index 0000000..659360e --- /dev/null +++ b/src/SchematicHQ.Client/Core/Extensions.cs @@ -0,0 +1,14 @@ +using System.Runtime.Serialization; + +namespace SchematicHQ.Client.Core; + +internal static class Extensions +{ + public static string Stringify(this Enum value) + { + var field = value.GetType().GetField(value.ToString()); + var attribute = (EnumMemberAttribute) + Attribute.GetCustomAttribute(field, typeof(EnumMemberAttribute)); + return attribute?.Value ?? value.ToString(); + } +} diff --git a/src/SchematicHQ.Client/Core/HeaderValue.cs b/src/SchematicHQ.Client/Core/HeaderValue.cs new file mode 100644 index 0000000..9018396 --- /dev/null +++ b/src/SchematicHQ.Client/Core/HeaderValue.cs @@ -0,0 +1,17 @@ +using OneOf; + +namespace SchematicHQ.Client.Core; + +internal sealed class HeaderValue(OneOf> value) + : OneOfBase>(value) +{ + public static implicit operator HeaderValue(string value) + { + return new HeaderValue(value); + } + + public static implicit operator HeaderValue(Func value) + { + return new HeaderValue(value); + } +} diff --git a/src/SchematicHQ.Client/Core/Headers.cs b/src/SchematicHQ.Client/Core/Headers.cs new file mode 100644 index 0000000..2f989f4 --- /dev/null +++ b/src/SchematicHQ.Client/Core/Headers.cs @@ -0,0 +1,17 @@ +namespace SchematicHQ.Client.Core; + +internal sealed class Headers : Dictionary +{ + public Headers() { } + + public Headers(Dictionary value) + { + foreach (var kvp in value) + { + this[kvp.Key] = new HeaderValue(kvp.Value); + } + } + + public Headers(IEnumerable> value) + : base(value.ToDictionary(e => e.Key, e => e.Value)) { } +} diff --git a/src/SchematicHQ.Client/Core/HttpMethodExtensions.cs b/src/SchematicHQ.Client/Core/HttpMethodExtensions.cs index d1fb09b..ef17c04 100644 --- a/src/SchematicHQ.Client/Core/HttpMethodExtensions.cs +++ b/src/SchematicHQ.Client/Core/HttpMethodExtensions.cs @@ -2,7 +2,7 @@ namespace SchematicHQ.Client.Core; -public static class HttpMethodExtensions +internal static class HttpMethodExtensions { public static readonly HttpMethod Patch = new("PATCH"); } diff --git a/src/SchematicHQ.Client/Core/IRequestOptions.cs b/src/SchematicHQ.Client/Core/IRequestOptions.cs new file mode 100644 index 0000000..7a71418 --- /dev/null +++ b/src/SchematicHQ.Client/Core/IRequestOptions.cs @@ -0,0 +1,34 @@ +using System; +using System.Net.Http; + +#nullable enable + +namespace SchematicHQ.Client.Core; + +internal interface IRequestOptions +{ + /// + /// The Base URL for the API. + /// + public string? BaseUrl { get; init; } + + /// + /// The http client used to make requests. + /// + public HttpClient? HttpClient { get; init; } + + /// + /// The http headers sent with the request. + /// + internal Headers Headers { get; init; } + + /// + /// The http client used to make requests. + /// + public int? MaxRetries { get; init; } + + /// + /// The timeout for the request. + /// + public TimeSpan? Timeout { get; init; } +} diff --git a/src/SchematicHQ.Client/Core/JsonConfiguration.cs b/src/SchematicHQ.Client/Core/JsonConfiguration.cs new file mode 100644 index 0000000..071c112 --- /dev/null +++ b/src/SchematicHQ.Client/Core/JsonConfiguration.cs @@ -0,0 +1,36 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace SchematicHQ.Client.Core; + +internal static partial class JsonOptions +{ + public static readonly JsonSerializerOptions JsonSerializerOptions; + + static JsonOptions() + { + var options = new JsonSerializerOptions + { + Converters = { new DateTimeSerializer(), new OneOfSerializer() }, + WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + }; + ConfigureJsonSerializerOptions(options); + JsonSerializerOptions = options; + } + + static partial void ConfigureJsonSerializerOptions(JsonSerializerOptions defaultOptions); +} + +internal static class JsonUtils +{ + public static string Serialize(T obj) + { + return JsonSerializer.Serialize(obj, JsonOptions.JsonSerializerOptions); + } + + public static T Deserialize(string json) + { + return JsonSerializer.Deserialize(json, JsonOptions.JsonSerializerOptions)!; + } +} diff --git a/src/SchematicHQ.Client/Core/OneOfSerializer.cs b/src/SchematicHQ.Client/Core/OneOfSerializer.cs index cd2536b..62a5210 100644 --- a/src/SchematicHQ.Client/Core/OneOfSerializer.cs +++ b/src/SchematicHQ.Client/Core/OneOfSerializer.cs @@ -5,10 +5,9 @@ namespace SchematicHQ.Client.Core; -public class OneOfSerializer : JsonConverter - where TOneOf : IOneOf +internal class OneOfSerializer : JsonConverter { - public override TOneOf? Read( + public override IOneOf? Read( ref Utf8JsonReader reader, System.Type typeToConvert, JsonSerializerOptions options @@ -17,14 +16,14 @@ JsonSerializerOptions options if (reader.TokenType is JsonTokenType.Null) return default; - foreach (var (type, cast) in s_types) + foreach (var (type, cast) in GetOneOfTypes(typeToConvert)) { try { var readerCopy = reader; var result = JsonSerializer.Deserialize(ref readerCopy, type, options); reader.Skip(); - return (TOneOf)cast.Invoke(null, [result])!; + return (IOneOf)cast.Invoke(null, [result])!; } catch (JsonException) { } } @@ -34,20 +33,18 @@ JsonSerializerOptions options ); } - private static readonly (System.Type type, MethodInfo cast)[] s_types = GetOneOfTypes(); - - public override void Write(Utf8JsonWriter writer, TOneOf value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, IOneOf value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Value, options); } - private static (System.Type type, MethodInfo cast)[] GetOneOfTypes() + private static (System.Type type, MethodInfo cast)[] GetOneOfTypes(System.Type typeToConvert) { - var casts = typeof(TOneOf) + var casts = typeToConvert .GetRuntimeMethods() .Where(m => m.IsSpecialName && m.Name == "op_Implicit") .ToArray(); - var type = typeof(TOneOf); + var type = typeToConvert; while (type != null) { if ( @@ -62,6 +59,11 @@ private static (System.Type type, MethodInfo cast)[] GetOneOfTypes() type = type.BaseType; } - throw new InvalidOperationException($"{typeof(TOneOf)} isn't OneOf or OneOfBase"); + throw new InvalidOperationException($"{type} isn't OneOf or OneOfBase"); + } + + public override bool CanConvert(System.Type typeToConvert) + { + return typeof(IOneOf).IsAssignableFrom(typeToConvert); } } diff --git a/src/SchematicHQ.Client/Core/Public/ClientOptions.cs b/src/SchematicHQ.Client/Core/Public/ClientOptions.cs new file mode 100644 index 0000000..3ad1607 --- /dev/null +++ b/src/SchematicHQ.Client/Core/Public/ClientOptions.cs @@ -0,0 +1,49 @@ +using System; +using System.Net.Http; + +#nullable enable + +namespace SchematicHQ.Client.Core; + +public partial class ClientOptions +{ + /// + /// The Base URL for the API. + /// + public string BaseUrl { get; init; } = SchematicApiEnvironment.DEFAULT; + + /// + /// The http client used to make requests. + /// + public HttpClient HttpClient { get; init; } = new HttpClient(); + + /// + /// The http client used to make requests. + /// + public int MaxRetries { get; init; } = 2; + + /// + /// The timeout for the request. + /// + public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(30); + + /// + /// The http headers sent with the request. + /// + internal Headers Headers { get; init; } = new(); + + /// + /// Clones this and returns a new instance + /// + internal ClientOptions Clone() + { + return new ClientOptions + { + BaseUrl = BaseUrl, + HttpClient = HttpClient, + MaxRetries = MaxRetries, + Timeout = Timeout, + Headers = new Headers(new Dictionary(Headers)), + }; + } +} diff --git a/src/SchematicHQ.Client/Core/Public/RequestOptions.cs b/src/SchematicHQ.Client/Core/Public/RequestOptions.cs new file mode 100644 index 0000000..dae7d03 --- /dev/null +++ b/src/SchematicHQ.Client/Core/Public/RequestOptions.cs @@ -0,0 +1,34 @@ +using System; +using System.Net.Http; + +#nullable enable + +namespace SchematicHQ.Client.Core; + +public partial class RequestOptions : IRequestOptions +{ + /// + /// The Base URL for the API. + /// + public string? BaseUrl { get; init; } + + /// + /// The http client used to make requests. + /// + public HttpClient? HttpClient { get; init; } + + /// + /// The http client used to make requests. + /// + public int? MaxRetries { get; init; } + + /// + /// The timeout for the request. + /// + public TimeSpan? Timeout { get; init; } + + /// + /// The http headers sent with the request. + /// + Headers IRequestOptions.Headers { get; init; } = new(); +} diff --git a/src/SchematicHQ.Client/Core/Public/SchematicApiApiException.cs b/src/SchematicHQ.Client/Core/Public/SchematicApiApiException.cs new file mode 100644 index 0000000..e88470c --- /dev/null +++ b/src/SchematicHQ.Client/Core/Public/SchematicApiApiException.cs @@ -0,0 +1,18 @@ +namespace SchematicHQ.Client.Core; + +/// +/// This exception type will be thrown for any non-2XX API responses. +/// +public class SchematicApiApiException(string message, int statusCode, object body) + : SchematicApiException(message) +{ + /// + /// The error code of the response that triggered the exception. + /// + public int StatusCode => statusCode; + + /// + /// The body of the response that triggered the exception. + /// + public object Body => body; +} diff --git a/src/SchematicHQ.Client/Core/Environments.cs b/src/SchematicHQ.Client/Core/Public/SchematicApiEnvironment.cs similarity index 74% rename from src/SchematicHQ.Client/Core/Environments.cs rename to src/SchematicHQ.Client/Core/Public/SchematicApiEnvironment.cs index 699b9ac..04ae8e6 100644 --- a/src/SchematicHQ.Client/Core/Environments.cs +++ b/src/SchematicHQ.Client/Core/Public/SchematicApiEnvironment.cs @@ -1,6 +1,6 @@ namespace SchematicHQ.Client.Core; -public class Environments +public class SchematicApiEnvironment { public static string DEFAULT = "https://api.schematichq.com"; } diff --git a/src/SchematicHQ.Client/Core/Public/SchematicApiException.cs b/src/SchematicHQ.Client/Core/Public/SchematicApiException.cs new file mode 100644 index 0000000..03cf4a0 --- /dev/null +++ b/src/SchematicHQ.Client/Core/Public/SchematicApiException.cs @@ -0,0 +1,11 @@ +using System; + +#nullable enable + +namespace SchematicHQ.Client.Core; + +/// +/// Base exception class for all exceptions thrown by the SDK. +/// +public class SchematicApiException(string message, Exception? innerException = null) + : Exception(message, innerException) { } diff --git a/src/SchematicHQ.Client/Core/Public/Version.cs b/src/SchematicHQ.Client/Core/Public/Version.cs new file mode 100644 index 0000000..d2034e2 --- /dev/null +++ b/src/SchematicHQ.Client/Core/Public/Version.cs @@ -0,0 +1,6 @@ +namespace SchematicHQ.Client; + +internal class Version +{ + public const string Current = "1.0.3"; +} diff --git a/src/SchematicHQ.Client/Core/RawClient.cs b/src/SchematicHQ.Client/Core/RawClient.cs index 4f426c1..648d63d 100644 --- a/src/SchematicHQ.Client/Core/RawClient.cs +++ b/src/SchematicHQ.Client/Core/RawClient.cs @@ -1,6 +1,7 @@ using System.Net.Http; +using System.Net.Http.Headers; using System.Text; -using System.Text.Json; +using System.Threading; namespace SchematicHQ.Client.Core; @@ -9,60 +10,34 @@ namespace SchematicHQ.Client.Core; /// /// Utility class for making raw HTTP requests to the API. /// -public class RawClient(Dictionary headers, ClientOptions clientOptions) +internal class RawClient(ClientOptions clientOptions) { - /// - /// The http client used to make requests. - /// - private readonly ClientOptions _clientOptions = clientOptions; + private const int InitialRetryDelayMs = 1000; + private const int MaxRetryDelayMs = 60000; /// - /// Global headers to be sent with every request. + /// The client options applied on every request. /// - private readonly Dictionary _headers = headers; + public readonly ClientOptions Options = clientOptions; - public async Task MakeRequestAsync(BaseApiRequest request) + public async Task MakeRequestAsync( + BaseApiRequest request, + CancellationToken cancellationToken = default + ) { - var url = BuildUrl(request.Path, request.Query); - var httpRequest = new HttpRequestMessage(request.Method, url); - if (request.ContentType != null) - { - request.Headers.Add("Content-Type", request.ContentType); - } - // Add global headers to the request - foreach (var header in _headers) - { - httpRequest.Headers.Add(header.Key, header.Value); - } - // Add request headers to the request - foreach (var header in request.Headers) - { - httpRequest.Headers.Add(header.Key, header.Value); - } - // Add the request body to the request - if (request is JsonApiRequest jsonRequest) - { - if (jsonRequest.Body != null) - { - var serializerOptions = new JsonSerializerOptions { WriteIndented = true, }; - httpRequest.Content = new StringContent( - JsonSerializer.Serialize(jsonRequest.Body, serializerOptions), - Encoding.UTF8, - "application/json" - ); - } - } - else if (request is StreamApiRequest { Body: not null } streamRequest) - { - httpRequest.Content = new StreamContent(streamRequest.Body); - } - // Send the request - var response = await _clientOptions.HttpClient.SendAsync(httpRequest); - return new ApiResponse { StatusCode = (int)response.StatusCode, Raw = response }; + // Apply the request timeout. + var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + var timeout = request.Options?.Timeout ?? Options.Timeout; + cts.CancelAfter(timeout); + + // Send the request. + return await SendWithRetriesAsync(request, cts.Token); } public record BaseApiRequest { + public required string BaseUrl { get; init; } + public required HttpMethod Method { get; init; } public required string Path { get; init; } @@ -71,9 +46,9 @@ public record BaseApiRequest public Dictionary Query { get; init; } = new(); - public Dictionary Headers { get; init; } = new(); + public Headers Headers { get; init; } = new(); - public object? RequestOptions { get; init; } + public IRequestOptions? Options { get; init; } } /// @@ -102,19 +77,113 @@ public record ApiResponse public required HttpResponseMessage Raw { get; init; } } - private string BuildUrl(string path, Dictionary query) + private async Task SendWithRetriesAsync( + BaseApiRequest request, + CancellationToken cancellationToken + ) { - var trimmedBaseUrl = _clientOptions.BaseUrl.TrimEnd('/'); - var trimmedBasePath = path.TrimStart('/'); + var httpClient = request.Options?.HttpClient ?? Options.HttpClient; + var maxRetries = request.Options?.MaxRetries ?? Options.MaxRetries; + var response = await httpClient.SendAsync(BuildHttpRequest(request), cancellationToken); + for (var i = 0; i < maxRetries; i++) + { + if (!ShouldRetry(response)) + { + break; + } + var delayMs = Math.Min(InitialRetryDelayMs * (int)Math.Pow(2, i), MaxRetryDelayMs); + await System.Threading.Tasks.Task.Delay(delayMs, cancellationToken); + response = await httpClient.SendAsync(BuildHttpRequest(request), cancellationToken); + } + return new ApiResponse { StatusCode = (int)response.StatusCode, Raw = response }; + } + + private static bool ShouldRetry(HttpResponseMessage response) + { + var statusCode = (int)response.StatusCode; + return statusCode is 408 or 429 or >= 500; + } + + private HttpRequestMessage BuildHttpRequest(BaseApiRequest request) + { + var url = BuildUrl(request); + var httpRequest = new HttpRequestMessage(request.Method, url); + switch (request) + { + // Add the request body to the request. + case JsonApiRequest jsonRequest: + { + if (jsonRequest.Body != null) + { + httpRequest.Content = new StringContent( + JsonUtils.Serialize(jsonRequest.Body), + Encoding.UTF8, + "application/json" + ); + } + break; + } + case StreamApiRequest { Body: not null } streamRequest: + httpRequest.Content = new StreamContent(streamRequest.Body); + break; + } + if (request.ContentType != null) + { + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse( + request.ContentType + ); + } + SetHeaders(httpRequest, Options.Headers); + SetHeaders(httpRequest, request.Headers); + SetHeaders(httpRequest, request.Options?.Headers ?? new Headers()); + + return httpRequest; + } + + private static string BuildUrl(BaseApiRequest request) + { + var baseUrl = request.Options?.BaseUrl ?? request.BaseUrl; + var trimmedBaseUrl = baseUrl.TrimEnd('/'); + var trimmedBasePath = request.Path.TrimStart('/'); var url = $"{trimmedBaseUrl}/{trimmedBasePath}"; - if (query.Count <= 0) + if (request.Query.Count <= 0) return url; url += "?"; - url = query.Aggregate( + url = request.Query.Aggregate( url, - (current, queryItem) => current + $"{queryItem.Key}={queryItem.Value}&" + (current, queryItem) => + { + if (queryItem.Value is System.Collections.IEnumerable collection and not string) + { + var items = collection + .Cast() + .Select(value => $"{queryItem.Key}={value}") + .ToList(); + if (items.Any()) + { + current += string.Join("&", items) + "&"; + } + } + else + { + current += $"{queryItem.Key}={queryItem.Value}&"; + } + return current; + } ); - url = url.Substring(0, url.Length - 1); + url = url[..^1]; return url; } + + private static void SetHeaders(HttpRequestMessage httpRequest, Headers headers) + { + foreach (var header in headers) + { + var value = header.Value?.Match(str => str, func => func.Invoke()); + if (value != null) + { + httpRequest.Headers.TryAddWithoutValidation(header.Key, value); + } + } + } } diff --git a/src/SchematicHQ.Client/Crm/CrmClient.cs b/src/SchematicHQ.Client/Crm/CrmClient.cs index 5d00a68..2e3457d 100644 --- a/src/SchematicHQ.Client/Crm/CrmClient.cs +++ b/src/SchematicHQ.Client/Crm/CrmClient.cs @@ -1,86 +1,239 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class CrmClient +public partial class CrmClient { private RawClient _client; - public CrmClient(RawClient client) + internal CrmClient(RawClient client) { _client = client; } + /// + /// + /// await client.Crm.UpsertDealLineItemAssociationAsync( + /// new CreateCrmDealLineItemAssociationRequestBody + /// { + /// DealExternalId = "deal_external_id", + /// LineItemExternalId = "line_item_external_id", + /// } + /// ); + /// + /// public async Task UpsertDealLineItemAssociationAsync( - CreateCrmDealLineItemAssociationRequestBody request + CreateCrmDealLineItemAssociationRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "crm/associations/deal-line-item", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Crm.UpsertLineItemAsync( + /// new CreateCrmLineItemRequestBody + /// { + /// Amount = "amount", + /// Interval = "interval", + /// LineItemExternalId = "line_item_external_id", + /// ProductExternalId = "product_external_id", + /// Quantity = 1, + /// } + /// ); + /// + /// public async Task UpsertLineItemAsync( - CreateCrmLineItemRequestBody request + CreateCrmLineItemRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "crm/deal-line-item/upsert", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task UpsertCrmDealAsync(CreateCrmDealRequestBody request) + /// + /// + /// await client.Crm.UpsertCrmDealAsync( + /// new CreateCrmDealRequestBody + /// { + /// CrmCompanyKey = "crm_company_key", + /// CrmType = "crm_type", + /// DealExternalId = "deal_external_id", + /// } + /// ); + /// + /// + public async Task UpsertCrmDealAsync( + CreateCrmDealRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "crm/deals/upsert", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); - } - public async Task ListCrmProductsAsync(ListCrmProductsRequest request) - { - var _query = new Dictionary() { }; - if (request.Ids != null) + try { - _query["ids"] = request.Ids; + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Crm.ListCrmProductsAsync(new ListCrmProductsRequest()); + /// + /// + public async Task ListCrmProductsAsync( + ListCrmProductsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.Name != null) { _query["name"] = request.Name; @@ -96,36 +249,122 @@ public async Task ListCrmProductsAsync(ListCrmProductsR var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "crm/products", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Crm.UpsertCrmProductAsync( + /// new CreateCrmProductRequestBody + /// { + /// Currency = "currency", + /// Description = "description", + /// ExternalId = "external_id", + /// Interval = "interval", + /// Name = "name", + /// Price = "price", + /// Quantity = 1, + /// Sku = "sku", + /// } + /// ); + /// + /// public async Task UpsertCrmProductAsync( - CreateCrmProductRequestBody request + CreateCrmProductRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "crm/products/upsert", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } } diff --git a/src/SchematicHQ.Client/Crm/Requests/CreateCrmDealLineItemAssociationRequestBody.cs b/src/SchematicHQ.Client/Crm/Requests/CreateCrmDealLineItemAssociationRequestBody.cs index 8ec539f..90425d0 100644 --- a/src/SchematicHQ.Client/Crm/Requests/CreateCrmDealLineItemAssociationRequestBody.cs +++ b/src/SchematicHQ.Client/Crm/Requests/CreateCrmDealLineItemAssociationRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,8 +8,13 @@ namespace SchematicHQ.Client; public record CreateCrmDealLineItemAssociationRequestBody { [JsonPropertyName("deal_external_id")] - public required string DealExternalId { get; init; } + public required string DealExternalId { get; set; } [JsonPropertyName("line_item_external_id")] - public required string LineItemExternalId { get; init; } + public required string LineItemExternalId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Crm/Requests/CreateCrmDealRequestBody.cs b/src/SchematicHQ.Client/Crm/Requests/CreateCrmDealRequestBody.cs index 99a4595..a218277 100644 --- a/src/SchematicHQ.Client/Crm/Requests/CreateCrmDealRequestBody.cs +++ b/src/SchematicHQ.Client/Crm/Requests/CreateCrmDealRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,29 +8,34 @@ namespace SchematicHQ.Client; public record CreateCrmDealRequestBody { [JsonPropertyName("arr")] - public string? Arr { get; init; } + public string? Arr { get; set; } [JsonPropertyName("crm_company_id")] - public string? CrmCompanyId { get; init; } + public string? CrmCompanyId { get; set; } [JsonPropertyName("crm_company_key")] - public required string CrmCompanyKey { get; init; } + public required string CrmCompanyKey { get; set; } [JsonPropertyName("crm_product_id")] - public string? CrmProductId { get; init; } + public string? CrmProductId { get; set; } [JsonPropertyName("crm_type")] - public required string CrmType { get; init; } + public required string CrmType { get; set; } [JsonPropertyName("deal_external_id")] - public required string DealExternalId { get; init; } + public required string DealExternalId { get; set; } [JsonPropertyName("deal_name")] - public string? DealName { get; init; } + public string? DealName { get; set; } [JsonPropertyName("deal_stage")] - public string? DealStage { get; init; } + public string? DealStage { get; set; } [JsonPropertyName("mrr")] - public string? Mrr { get; init; } + public string? Mrr { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Crm/Requests/CreateCrmLineItemRequestBody.cs b/src/SchematicHQ.Client/Crm/Requests/CreateCrmLineItemRequestBody.cs index ed74b97..3077cff 100644 --- a/src/SchematicHQ.Client/Crm/Requests/CreateCrmLineItemRequestBody.cs +++ b/src/SchematicHQ.Client/Crm/Requests/CreateCrmLineItemRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,27 +7,32 @@ namespace SchematicHQ.Client; public record CreateCrmLineItemRequestBody { - [JsonPropertyName("TermMonth")] - public int? TermMonth { get; init; } - [JsonPropertyName("amount")] - public required string Amount { get; init; } + public required string Amount { get; set; } [JsonPropertyName("discount_percentage")] - public string? DiscountPercentage { get; init; } + public string? DiscountPercentage { get; set; } [JsonPropertyName("interval")] - public required string Interval { get; init; } + public required string Interval { get; set; } [JsonPropertyName("line_item_external_id")] - public required string LineItemExternalId { get; init; } + public required string LineItemExternalId { get; set; } [JsonPropertyName("product_external_id")] - public required string ProductExternalId { get; init; } + public required string ProductExternalId { get; set; } [JsonPropertyName("quantity")] - public required int Quantity { get; init; } + public required int Quantity { get; set; } + + [JsonPropertyName("term_month")] + public int? TermMonth { get; set; } [JsonPropertyName("total_discount")] - public string? TotalDiscount { get; init; } + public string? TotalDiscount { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Crm/Requests/CreateCrmProductRequestBody.cs b/src/SchematicHQ.Client/Crm/Requests/CreateCrmProductRequestBody.cs index ff096b0..867123d 100644 --- a/src/SchematicHQ.Client/Crm/Requests/CreateCrmProductRequestBody.cs +++ b/src/SchematicHQ.Client/Crm/Requests/CreateCrmProductRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,26 +8,31 @@ namespace SchematicHQ.Client; public record CreateCrmProductRequestBody { [JsonPropertyName("currency")] - public required string Currency { get; init; } + public required string Currency { get; set; } [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("external_id")] - public required string ExternalId { get; init; } + public required string ExternalId { get; set; } [JsonPropertyName("interval")] - public required string Interval { get; init; } + public required string Interval { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("price")] - public required string Price { get; init; } + public required string Price { get; set; } [JsonPropertyName("quantity")] - public required int Quantity { get; init; } + public required int Quantity { get; set; } [JsonPropertyName("sku")] - public required string Sku { get; init; } + public required string Sku { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Crm/Requests/ListCrmProductsRequest.cs b/src/SchematicHQ.Client/Crm/Requests/ListCrmProductsRequest.cs index 7ba54de..744036e 100644 --- a/src/SchematicHQ.Client/Crm/Requests/ListCrmProductsRequest.cs +++ b/src/SchematicHQ.Client/Crm/Requests/ListCrmProductsRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListCrmProductsRequest { - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Name { get; init; } + public string? Name { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Crm/Types/ListCrmProductsParams.cs b/src/SchematicHQ.Client/Crm/Types/ListCrmProductsParams.cs index 6f5753d..d80ce35 100644 --- a/src/SchematicHQ.Client/Crm/Types/ListCrmProductsParams.cs +++ b/src/SchematicHQ.Client/Crm/Types/ListCrmProductsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record ListCrmProductsParams { [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Crm/Types/ListCrmProductsResponse.cs b/src/SchematicHQ.Client/Crm/Types/ListCrmProductsResponse.cs index 3bfc379..01a5c81 100644 --- a/src/SchematicHQ.Client/Crm/Types/ListCrmProductsResponse.cs +++ b/src/SchematicHQ.Client/Crm/Types/ListCrmProductsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListCrmProductsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListCrmProductsParams Params { get; init; } + public required ListCrmProductsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Crm/Types/UpsertCrmDealResponse.cs b/src/SchematicHQ.Client/Crm/Types/UpsertCrmDealResponse.cs index 3b3770b..ea5921c 100644 --- a/src/SchematicHQ.Client/Crm/Types/UpsertCrmDealResponse.cs +++ b/src/SchematicHQ.Client/Crm/Types/UpsertCrmDealResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertCrmDealResponse { [JsonPropertyName("data")] - public required CrmDealResponseData Data { get; init; } + public required CrmDealResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Crm/Types/UpsertCrmProductResponse.cs b/src/SchematicHQ.Client/Crm/Types/UpsertCrmProductResponse.cs index 2e9b5c4..6cd77ee 100644 --- a/src/SchematicHQ.Client/Crm/Types/UpsertCrmProductResponse.cs +++ b/src/SchematicHQ.Client/Crm/Types/UpsertCrmProductResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertCrmProductResponse { [JsonPropertyName("data")] - public required CrmProductResponseData Data { get; init; } + public required CrmProductResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Crm/Types/UpsertDealLineItemAssociationResponse.cs b/src/SchematicHQ.Client/Crm/Types/UpsertDealLineItemAssociationResponse.cs index ec6c103..d7f81e8 100644 --- a/src/SchematicHQ.Client/Crm/Types/UpsertDealLineItemAssociationResponse.cs +++ b/src/SchematicHQ.Client/Crm/Types/UpsertDealLineItemAssociationResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertDealLineItemAssociationResponse { [JsonPropertyName("data")] - public required CrmLineItemResponseData Data { get; init; } + public required CrmLineItemResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Crm/Types/UpsertLineItemResponse.cs b/src/SchematicHQ.Client/Crm/Types/UpsertLineItemResponse.cs index e18cb2e..b700722 100644 --- a/src/SchematicHQ.Client/Crm/Types/UpsertLineItemResponse.cs +++ b/src/SchematicHQ.Client/Crm/Types/UpsertLineItemResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertLineItemResponse { [JsonPropertyName("data")] - public required CrmLineItemResponseData Data { get; init; } + public required CrmLineItemResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs b/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs index 094f433..8a28dde 100644 --- a/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs +++ b/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs @@ -1,45 +1,47 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class EntitlementsClient +public partial class EntitlementsClient { private RawClient _client; - public EntitlementsClient(RawClient client) + internal EntitlementsClient(RawClient client) { _client = client; } + /// + /// + /// await client.Entitlements.ListCompanyOverridesAsync(new ListCompanyOverridesRequest()); + /// + /// public async Task ListCompanyOverridesAsync( - ListCompanyOverridesRequest request + ListCompanyOverridesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["company_ids"] = request.CompanyIds; + _query["feature_ids"] = request.FeatureIds; + _query["ids"] = request.Ids; if (request.CompanyId != null) { _query["company_id"] = request.CompanyId; } - if (request.CompanyIds != null) - { - _query["company_ids"] = request.CompanyIds; - } if (request.FeatureId != null) { _query["feature_id"] = request.FeatureId; } - if (request.FeatureIds != null) + if (request.WithoutExpired != null) { - _query["feature_ids"] = request.FeatureIds; - } - if (request.Ids != null) - { - _query["ids"] = request.Ids; + _query["without_expired"] = request.WithoutExpired.ToString(); } if (request.Q != null) { @@ -56,120 +58,334 @@ ListCompanyOverridesRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "company-overrides", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.CreateCompanyOverrideAsync( + /// new CreateCompanyOverrideRequestBody + /// { + /// CompanyId = "company_id", + /// FeatureId = "feature_id", + /// ValueType = CreateCompanyOverrideRequestBodyValueType.Boolean, + /// } + /// ); + /// + /// public async Task CreateCompanyOverrideAsync( - CreateCompanyOverrideRequestBody request + CreateCompanyOverrideRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "company-overrides", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetCompanyOverrideAsync(string companyOverrideId) + /// + /// + /// await client.Entitlements.GetCompanyOverrideAsync("company_override_id"); + /// + /// + public async Task GetCompanyOverrideAsync( + string companyOverrideId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"company-overrides/{companyOverrideId}" - } + Path = $"company-overrides/{companyOverrideId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.UpdateCompanyOverrideAsync( + /// "company_override_id", + /// new UpdateCompanyOverrideRequestBody + /// { + /// ValueType = UpdateCompanyOverrideRequestBodyValueType.Boolean, + /// } + /// ); + /// + /// public async Task UpdateCompanyOverrideAsync( string companyOverrideId, - UpdateCompanyOverrideRequestBody request + UpdateCompanyOverrideRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"company-overrides/{companyOverrideId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.DeleteCompanyOverrideAsync("company_override_id"); + /// + /// public async Task DeleteCompanyOverrideAsync( - string companyOverrideId + string companyOverrideId, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, - Path = $"company-overrides/{companyOverrideId}" - } + Path = $"company-overrides/{companyOverrideId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.CountCompanyOverridesAsync(new CountCompanyOverridesRequest()); + /// + /// public async Task CountCompanyOverridesAsync( - CountCompanyOverridesRequest request + CountCompanyOverridesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["company_ids"] = request.CompanyIds; + _query["feature_ids"] = request.FeatureIds; + _query["ids"] = request.Ids; if (request.CompanyId != null) { _query["company_id"] = request.CompanyId; } - if (request.CompanyIds != null) - { - _query["company_ids"] = request.CompanyIds; - } if (request.FeatureId != null) { _query["feature_id"] = request.FeatureId; } - if (request.FeatureIds != null) - { - _query["feature_ids"] = request.FeatureIds; - } - if (request.Ids != null) + if (request.WithoutExpired != null) { - _query["ids"] = request.Ids; + _query["without_expired"] = request.WithoutExpired.ToString(); } if (request.Q != null) { @@ -186,24 +402,67 @@ CountCompanyOverridesRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "company-overrides/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.ListFeatureCompaniesAsync( + /// new ListFeatureCompaniesRequest { FeatureId = "feature_id" } + /// ); + /// + /// public async Task ListFeatureCompaniesAsync( - ListFeatureCompaniesRequest request + ListFeatureCompaniesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { { "feature_id", request.FeatureId }, }; + var _query = new Dictionary(); + _query["feature_id"] = request.FeatureId; if (request.Q != null) { _query["q"] = request.Q; @@ -219,24 +478,67 @@ ListFeatureCompaniesRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "feature-companies", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.CountFeatureCompaniesAsync( + /// new CountFeatureCompaniesRequest { FeatureId = "feature_id" } + /// ); + /// + /// public async Task CountFeatureCompaniesAsync( - CountFeatureCompaniesRequest request + CountFeatureCompaniesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { { "feature_id", request.FeatureId }, }; + var _query = new Dictionary(); + _query["feature_id"] = request.FeatureId; if (request.Q != null) { _query["q"] = request.Q; @@ -252,24 +554,65 @@ CountFeatureCompaniesRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "feature-companies/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.ListFeatureUsageAsync(new ListFeatureUsageRequest()); + /// + /// public async Task ListFeatureUsageAsync( - ListFeatureUsageRequest request + ListFeatureUsageRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["feature_ids"] = request.FeatureIds; if (request.CompanyId != null) { _query["company_id"] = request.CompanyId; @@ -278,14 +621,15 @@ ListFeatureUsageRequest request { _query["company_keys"] = request.CompanyKeys.ToString(); } - if (request.FeatureIds != null) - { - _query["feature_ids"] = request.FeatureIds; - } if (request.Q != null) { _query["q"] = request.Q; } + if (request.WithoutNegativeEntitlements != null) + { + _query["without_negative_entitlements"] = + request.WithoutNegativeEntitlements.ToString(); + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -297,24 +641,65 @@ ListFeatureUsageRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "feature-usage", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.CountFeatureUsageAsync(new CountFeatureUsageRequest()); + /// + /// public async Task CountFeatureUsageAsync( - CountFeatureUsageRequest request + CountFeatureUsageRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["feature_ids"] = request.FeatureIds; if (request.CompanyId != null) { _query["company_id"] = request.CompanyId; @@ -323,14 +708,15 @@ CountFeatureUsageRequest request { _query["company_keys"] = request.CompanyKeys.ToString(); } - if (request.FeatureIds != null) - { - _query["feature_ids"] = request.FeatureIds; - } if (request.Q != null) { _query["q"] = request.Q; } + if (request.WithoutNegativeEntitlements != null) + { + _query["without_negative_entitlements"] = + request.WithoutNegativeEntitlements.ToString(); + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -342,24 +728,67 @@ CountFeatureUsageRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "feature-usage/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.ListFeatureUsersAsync( + /// new ListFeatureUsersRequest { FeatureId = "feature_id" } + /// ); + /// + /// public async Task ListFeatureUsersAsync( - ListFeatureUsersRequest request + ListFeatureUsersRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { { "feature_id", request.FeatureId }, }; + var _query = new Dictionary(); + _query["feature_id"] = request.FeatureId; if (request.Q != null) { _query["q"] = request.Q; @@ -375,24 +804,67 @@ ListFeatureUsersRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "feature-users", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.CountFeatureUsersAsync( + /// new CountFeatureUsersRequest { FeatureId = "feature_id" } + /// ); + /// + /// public async Task CountFeatureUsersAsync( - CountFeatureUsersRequest request + CountFeatureUsersRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { { "feature_id", request.FeatureId }, }; + var _query = new Dictionary(); + _query["feature_id"] = request.FeatureId; if (request.Q != null) { _query["q"] = request.Q; @@ -408,48 +880,83 @@ CountFeatureUsersRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "feature-users/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.ListPlanEntitlementsAsync(new ListPlanEntitlementsRequest()); + /// + /// public async Task ListPlanEntitlementsAsync( - ListPlanEntitlementsRequest request + ListPlanEntitlementsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["feature_ids"] = request.FeatureIds; + _query["ids"] = request.Ids; + _query["plan_ids"] = request.PlanIds; if (request.FeatureId != null) { _query["feature_id"] = request.FeatureId; } - if (request.FeatureIds != null) - { - _query["feature_ids"] = request.FeatureIds; - } - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } if (request.PlanId != null) { _query["plan_id"] = request.PlanId; } - if (request.PlanIds != null) - { - _query["plan_ids"] = request.PlanIds; - } if (request.Q != null) { _query["q"] = request.Q; } + if (request.WithMeteredProducts != null) + { + _query["with_metered_products"] = request.WithMeteredProducts.ToString(); + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -461,125 +968,339 @@ ListPlanEntitlementsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "plan-entitlements", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.CreatePlanEntitlementAsync( + /// new CreatePlanEntitlementRequestBody + /// { + /// FeatureId = "feature_id", + /// PlanId = "plan_id", + /// ValueType = CreatePlanEntitlementRequestBodyValueType.Boolean, + /// } + /// ); + /// + /// public async Task CreatePlanEntitlementAsync( - CreatePlanEntitlementRequestBody request + CreatePlanEntitlementRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "plan-entitlements", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetPlanEntitlementAsync(string planEntitlementId) + /// + /// + /// await client.Entitlements.GetPlanEntitlementAsync("plan_entitlement_id"); + /// + /// + public async Task GetPlanEntitlementAsync( + string planEntitlementId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"plan-entitlements/{planEntitlementId}" - } + Path = $"plan-entitlements/{planEntitlementId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.UpdatePlanEntitlementAsync( + /// "plan_entitlement_id", + /// new UpdatePlanEntitlementRequestBody + /// { + /// ValueType = UpdatePlanEntitlementRequestBodyValueType.Boolean, + /// } + /// ); + /// + /// public async Task UpdatePlanEntitlementAsync( string planEntitlementId, - UpdatePlanEntitlementRequestBody request + UpdatePlanEntitlementRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"plan-entitlements/{planEntitlementId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.DeletePlanEntitlementAsync("plan_entitlement_id"); + /// + /// public async Task DeletePlanEntitlementAsync( - string planEntitlementId + string planEntitlementId, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, - Path = $"plan-entitlements/{planEntitlementId}" - } + Path = $"plan-entitlements/{planEntitlementId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.CountPlanEntitlementsAsync(new CountPlanEntitlementsRequest()); + /// + /// public async Task CountPlanEntitlementsAsync( - CountPlanEntitlementsRequest request + CountPlanEntitlementsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["feature_ids"] = request.FeatureIds; + _query["ids"] = request.Ids; + _query["plan_ids"] = request.PlanIds; if (request.FeatureId != null) { _query["feature_id"] = request.FeatureId; } - if (request.FeatureIds != null) - { - _query["feature_ids"] = request.FeatureIds; - } - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } if (request.PlanId != null) { _query["plan_id"] = request.PlanId; } - if (request.PlanIds != null) - { - _query["plan_ids"] = request.PlanIds; - } if (request.Q != null) { _query["q"] = request.Q; } + if (request.WithMeteredProducts != null) + { + _query["with_metered_products"] = request.WithMeteredProducts.ToString(); + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -591,37 +1312,122 @@ CountPlanEntitlementsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "plan-entitlements/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Entitlements.GetFeatureUsageByCompanyAsync( + /// new GetFeatureUsageByCompanyRequest + /// { + /// Keys = new Dictionary<string, object>() + /// { + /// { + /// "keys", + /// new Dictionary<object, object?>() { { "key", "value" } } + /// }, + /// }, + /// } + /// ); + /// + /// public async Task GetFeatureUsageByCompanyAsync( - GetFeatureUsageByCompanyRequest request + GetFeatureUsageByCompanyRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { { "keys", request.Keys.ToString() }, }; + var _query = new Dictionary(); + _query["keys"] = request.Keys.ToString(); var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "usage-by-company", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/CountCompanyOverridesRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/CountCompanyOverridesRequest.cs index 29e1430..1490520 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/CountCompanyOverridesRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/CountCompanyOverridesRequest.cs @@ -1,26 +1,58 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountCompanyOverridesRequest { - public string? CompanyId { get; init; } + /// + /// Filter company overrides by a single company ID (starting with comp_) + /// + public string? CompanyId { get; set; } - public string? CompanyIds { get; init; } + /// + /// Filter company overrides by multiple company IDs (starting with comp_) + /// + public IEnumerable CompanyIds { get; set; } = new List(); + + /// + /// Filter company overrides by a single feature ID (starting with feat_) + /// + public string? FeatureId { get; set; } - public string? FeatureId { get; init; } + /// + /// Filter company overrides by multiple feature IDs (starting with feat_) + /// + public IEnumerable FeatureIds { get; set; } = new List(); - public string? FeatureIds { get; init; } + /// + /// Filter company overrides by multiple company override IDs (starting with cmov_) + /// + public IEnumerable Ids { get; set; } = new List(); - public string? Ids { get; init; } + /// + /// Filter company overrides by whether they have not expired + /// + public bool? WithoutExpired { get; set; } - public string? Q { get; init; } + /// + /// Search for company overrides by feature or company name + /// + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureCompaniesRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureCompaniesRequest.cs index b402048..ae20098 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureCompaniesRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureCompaniesRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountFeatureCompaniesRequest { - public required string FeatureId { get; init; } + public required string FeatureId { get; set; } - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureUsageRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureUsageRequest.cs index e5367f1..9dd82d5 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureUsageRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureUsageRequest.cs @@ -1,22 +1,33 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountFeatureUsageRequest { - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } - public Dictionary? CompanyKeys { get; init; } + public Dictionary? CompanyKeys { get; set; } - public string? FeatureIds { get; init; } + public IEnumerable FeatureIds { get; set; } = new List(); - public string? Q { get; init; } + public string? Q { get; set; } + + public bool? WithoutNegativeEntitlements { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureUsersRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureUsersRequest.cs index 5fdf95c..9b142e0 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureUsersRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/CountFeatureUsersRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountFeatureUsersRequest { - public required string FeatureId { get; init; } + public required string FeatureId { get; set; } - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/CountPlanEntitlementsRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/CountPlanEntitlementsRequest.cs index 9a676ad..bae6cf8 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/CountPlanEntitlementsRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/CountPlanEntitlementsRequest.cs @@ -1,26 +1,58 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountPlanEntitlementsRequest { - public string? FeatureId { get; init; } + /// + /// Filter plan entitlements by a single feature ID (starting with feat_) + /// + public string? FeatureId { get; set; } - public string? FeatureIds { get; init; } + /// + /// Filter plan entitlements by multiple feature IDs (starting with feat_) + /// + public IEnumerable FeatureIds { get; set; } = new List(); + + /// + /// Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) + /// + public IEnumerable Ids { get; set; } = new List(); - public string? Ids { get; init; } + /// + /// Filter plan entitlements by a single plan ID (starting with plan_) + /// + public string? PlanId { get; set; } - public string? PlanId { get; init; } + /// + /// Filter plan entitlements by multiple plan IDs (starting with plan_) + /// + public IEnumerable PlanIds { get; set; } = new List(); - public string? PlanIds { get; init; } + /// + /// Search for plan entitlements by feature or company name + /// + public string? Q { get; set; } - public string? Q { get; init; } + /// + /// Filter plan entitlements only with metered products + /// + public bool? WithMeteredProducts { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/CreateCompanyOverrideRequestBody.cs b/src/SchematicHQ.Client/Entitlements/Requests/CreateCompanyOverrideRequestBody.cs index 0174bb8..0ea68f9 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/CreateCompanyOverrideRequestBody.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/CreateCompanyOverrideRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,23 +8,34 @@ namespace SchematicHQ.Client; public record CreateCompanyOverrideRequestBody { [JsonPropertyName("company_id")] - public required string CompanyId { get; init; } + public required string CompanyId { get; set; } + + [JsonPropertyName("expiration_date")] + public DateTime? ExpirationDate { get; set; } [JsonPropertyName("feature_id")] - public required string FeatureId { get; init; } + public required string FeatureId { get; set; } [JsonPropertyName("metric_period")] - public CreateCompanyOverrideRequestBodyMetricPeriod? MetricPeriod { get; init; } + public CreateCompanyOverrideRequestBodyMetricPeriod? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public CreateCompanyOverrideRequestBodyMetricPeriodMonthReset? MetricPeriodMonthReset { get; set; } [JsonPropertyName("value_bool")] - public bool? ValueBool { get; init; } + public bool? ValueBool { get; set; } [JsonPropertyName("value_numeric")] - public int? ValueNumeric { get; init; } + public int? ValueNumeric { get; set; } [JsonPropertyName("value_trait_id")] - public string? ValueTraitId { get; init; } + public string? ValueTraitId { get; set; } [JsonPropertyName("value_type")] - public required CreateCompanyOverrideRequestBodyValueType ValueType { get; init; } + public required CreateCompanyOverrideRequestBodyValueType ValueType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/CreatePlanEntitlementRequestBody.cs b/src/SchematicHQ.Client/Entitlements/Requests/CreatePlanEntitlementRequestBody.cs index 3bbb747..70413e6 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/CreatePlanEntitlementRequestBody.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/CreatePlanEntitlementRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,23 +8,40 @@ namespace SchematicHQ.Client; public record CreatePlanEntitlementRequestBody { [JsonPropertyName("feature_id")] - public required string FeatureId { get; init; } + public required string FeatureId { get; set; } [JsonPropertyName("metric_period")] - public CreatePlanEntitlementRequestBodyMetricPeriod? MetricPeriod { get; init; } + public CreatePlanEntitlementRequestBodyMetricPeriod? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public CreatePlanEntitlementRequestBodyMetricPeriodMonthReset? MetricPeriodMonthReset { get; set; } + + [JsonPropertyName("monthly_metered_price_id")] + public string? MonthlyMeteredPriceId { get; set; } [JsonPropertyName("plan_id")] - public required string PlanId { get; init; } + public required string PlanId { get; set; } + + [JsonPropertyName("price_behavior")] + public string? PriceBehavior { get; set; } [JsonPropertyName("value_bool")] - public bool? ValueBool { get; init; } + public bool? ValueBool { get; set; } [JsonPropertyName("value_numeric")] - public int? ValueNumeric { get; init; } + public int? ValueNumeric { get; set; } [JsonPropertyName("value_trait_id")] - public string? ValueTraitId { get; init; } + public string? ValueTraitId { get; set; } [JsonPropertyName("value_type")] - public required CreatePlanEntitlementRequestBodyValueType ValueType { get; init; } + public required CreatePlanEntitlementRequestBodyValueType ValueType { get; set; } + + [JsonPropertyName("yearly_metered_price_id")] + public string? YearlyMeteredPriceId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/GetFeatureUsageByCompanyRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/GetFeatureUsageByCompanyRequest.cs index 44b4670..94bc35b 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/GetFeatureUsageByCompanyRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/GetFeatureUsageByCompanyRequest.cs @@ -1,3 +1,7 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record GetFeatureUsageByCompanyRequest @@ -5,5 +9,10 @@ public record GetFeatureUsageByCompanyRequest /// /// Key/value pairs /// - public Dictionary Keys { get; init; } = new Dictionary(); + public Dictionary Keys { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/ListCompanyOverridesRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/ListCompanyOverridesRequest.cs index 6218061..29328b2 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/ListCompanyOverridesRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/ListCompanyOverridesRequest.cs @@ -1,26 +1,58 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListCompanyOverridesRequest { - public string? CompanyId { get; init; } + /// + /// Filter company overrides by a single company ID (starting with comp_) + /// + public string? CompanyId { get; set; } - public string? CompanyIds { get; init; } + /// + /// Filter company overrides by multiple company IDs (starting with comp_) + /// + public IEnumerable CompanyIds { get; set; } = new List(); + + /// + /// Filter company overrides by a single feature ID (starting with feat_) + /// + public string? FeatureId { get; set; } - public string? FeatureId { get; init; } + /// + /// Filter company overrides by multiple feature IDs (starting with feat_) + /// + public IEnumerable FeatureIds { get; set; } = new List(); - public string? FeatureIds { get; init; } + /// + /// Filter company overrides by multiple company override IDs (starting with cmov_) + /// + public IEnumerable Ids { get; set; } = new List(); - public string? Ids { get; init; } + /// + /// Filter company overrides by whether they have not expired + /// + public bool? WithoutExpired { get; set; } - public string? Q { get; init; } + /// + /// Search for company overrides by feature or company name + /// + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureCompaniesRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureCompaniesRequest.cs index 461482a..34367da 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureCompaniesRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureCompaniesRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListFeatureCompaniesRequest { - public required string FeatureId { get; init; } + public required string FeatureId { get; set; } - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureUsageRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureUsageRequest.cs index 125b926..3944ee5 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureUsageRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureUsageRequest.cs @@ -1,22 +1,33 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListFeatureUsageRequest { - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } - public Dictionary? CompanyKeys { get; init; } + public Dictionary? CompanyKeys { get; set; } - public string? FeatureIds { get; init; } + public IEnumerable FeatureIds { get; set; } = new List(); - public string? Q { get; init; } + public string? Q { get; set; } + + public bool? WithoutNegativeEntitlements { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureUsersRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureUsersRequest.cs index 6ea2846..538eb46 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureUsersRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/ListFeatureUsersRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListFeatureUsersRequest { - public required string FeatureId { get; init; } + public required string FeatureId { get; set; } - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/ListPlanEntitlementsRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/ListPlanEntitlementsRequest.cs index 6193640..076dc44 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/ListPlanEntitlementsRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/ListPlanEntitlementsRequest.cs @@ -1,26 +1,58 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListPlanEntitlementsRequest { - public string? FeatureId { get; init; } + /// + /// Filter plan entitlements by a single feature ID (starting with feat_) + /// + public string? FeatureId { get; set; } - public string? FeatureIds { get; init; } + /// + /// Filter plan entitlements by multiple feature IDs (starting with feat_) + /// + public IEnumerable FeatureIds { get; set; } = new List(); + + /// + /// Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) + /// + public IEnumerable Ids { get; set; } = new List(); - public string? Ids { get; init; } + /// + /// Filter plan entitlements by a single plan ID (starting with plan_) + /// + public string? PlanId { get; set; } - public string? PlanId { get; init; } + /// + /// Filter plan entitlements by multiple plan IDs (starting with plan_) + /// + public IEnumerable PlanIds { get; set; } = new List(); - public string? PlanIds { get; init; } + /// + /// Search for plan entitlements by feature or company name + /// + public string? Q { get; set; } - public string? Q { get; init; } + /// + /// Filter plan entitlements only with metered products + /// + public bool? WithMeteredProducts { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/UpdateCompanyOverrideRequestBody.cs b/src/SchematicHQ.Client/Entitlements/Requests/UpdateCompanyOverrideRequestBody.cs index 82a09b1..d933431 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/UpdateCompanyOverrideRequestBody.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/UpdateCompanyOverrideRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -7,18 +7,29 @@ namespace SchematicHQ.Client; public record UpdateCompanyOverrideRequestBody { + [JsonPropertyName("expiration_date")] + public DateTime? ExpirationDate { get; set; } + [JsonPropertyName("metric_period")] - public UpdateCompanyOverrideRequestBodyMetricPeriod? MetricPeriod { get; init; } + public UpdateCompanyOverrideRequestBodyMetricPeriod? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset? MetricPeriodMonthReset { get; set; } [JsonPropertyName("value_bool")] - public bool? ValueBool { get; init; } + public bool? ValueBool { get; set; } [JsonPropertyName("value_numeric")] - public int? ValueNumeric { get; init; } + public int? ValueNumeric { get; set; } [JsonPropertyName("value_trait_id")] - public string? ValueTraitId { get; init; } + public string? ValueTraitId { get; set; } [JsonPropertyName("value_type")] - public required UpdateCompanyOverrideRequestBodyValueType ValueType { get; init; } + public required UpdateCompanyOverrideRequestBodyValueType ValueType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Requests/UpdatePlanEntitlementRequestBody.cs b/src/SchematicHQ.Client/Entitlements/Requests/UpdatePlanEntitlementRequestBody.cs index ee76f1f..5f66519 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/UpdatePlanEntitlementRequestBody.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/UpdatePlanEntitlementRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,17 +8,34 @@ namespace SchematicHQ.Client; public record UpdatePlanEntitlementRequestBody { [JsonPropertyName("metric_period")] - public UpdatePlanEntitlementRequestBodyMetricPeriod? MetricPeriod { get; init; } + public UpdatePlanEntitlementRequestBodyMetricPeriod? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset? MetricPeriodMonthReset { get; set; } + + [JsonPropertyName("monthly_metered_price_id")] + public string? MonthlyMeteredPriceId { get; set; } + + [JsonPropertyName("price_behavior")] + public string? PriceBehavior { get; set; } [JsonPropertyName("value_bool")] - public bool? ValueBool { get; init; } + public bool? ValueBool { get; set; } [JsonPropertyName("value_numeric")] - public int? ValueNumeric { get; init; } + public int? ValueNumeric { get; set; } [JsonPropertyName("value_trait_id")] - public string? ValueTraitId { get; init; } + public string? ValueTraitId { get; set; } [JsonPropertyName("value_type")] - public required UpdatePlanEntitlementRequestBodyValueType ValueType { get; init; } + public required UpdatePlanEntitlementRequestBodyValueType ValueType { get; set; } + + [JsonPropertyName("yearly_metered_price_id")] + public string? YearlyMeteredPriceId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesParams.cs b/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesParams.cs index b4a9309..041c64c 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,33 +7,62 @@ namespace SchematicHQ.Client; public record CountCompanyOverridesParams { + /// + /// Filter company overrides by a single company ID (starting with comp_) + /// [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } + /// + /// Filter company overrides by multiple company IDs (starting with comp_) + /// [JsonPropertyName("company_ids")] - public IEnumerable? CompanyIds { get; init; } + public IEnumerable? CompanyIds { get; set; } + /// + /// Filter company overrides by a single feature ID (starting with feat_) + /// [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } + /// + /// Filter company overrides by multiple feature IDs (starting with feat_) + /// [JsonPropertyName("feature_ids")] - public IEnumerable? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; set; } + /// + /// Filter company overrides by multiple company override IDs (starting with cmov_) + /// [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + /// + /// Search for company overrides by feature or company name + /// [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + /// + /// Filter company overrides by whether they have not expired + /// + [JsonPropertyName("without_expired")] + public bool? WithoutExpired { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesResponse.cs index c7b1b66..386292a 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountCompanyOverridesResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountCompanyOverridesParams Params { get; init; } + public required CountCompanyOverridesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureCompaniesParams.cs b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureCompaniesParams.cs index dc54be2..5790590 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureCompaniesParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureCompaniesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record CountFeatureCompaniesParams { [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureCompaniesResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureCompaniesResponse.cs index 3266f80..9a7dcbf 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureCompaniesResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureCompaniesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountFeatureCompaniesResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountFeatureCompaniesParams Params { get; init; } + public required CountFeatureCompaniesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageParams.cs b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageParams.cs index 4a0e753..4e6cf05 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,26 +8,34 @@ namespace SchematicHQ.Client; public record CountFeatureUsageParams { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("company_keys")] - public Dictionary? CompanyKeys { get; init; } + public Dictionary? CompanyKeys { get; set; } [JsonPropertyName("feature_ids")] - public IEnumerable? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + [JsonPropertyName("without_negative_entitlements")] + public bool? WithoutNegativeEntitlements { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageResponse.cs index 6bdea56..9f3c1dd 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountFeatureUsageResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountFeatureUsageParams Params { get; init; } + public required CountFeatureUsageParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsersParams.cs b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsersParams.cs index 62ba791..d355a15 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsersParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsersParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record CountFeatureUsersParams { [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsersResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsersResponse.cs index 1d8e6c8..f465295 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsersResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsersResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountFeatureUsersResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountFeatureUsersParams Params { get; init; } + public required CountFeatureUsersParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsParams.cs b/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsParams.cs index b398802..c41e5ab 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,33 +7,62 @@ namespace SchematicHQ.Client; public record CountPlanEntitlementsParams { + /// + /// Filter plan entitlements by a single feature ID (starting with feat_) + /// [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } + /// + /// Filter plan entitlements by multiple feature IDs (starting with feat_) + /// [JsonPropertyName("feature_ids")] - public IEnumerable? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; set; } + /// + /// Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) + /// [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + /// + /// Filter plan entitlements by a single plan ID (starting with plan_) + /// [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } + /// + /// Filter plan entitlements by multiple plan IDs (starting with plan_) + /// [JsonPropertyName("plan_ids")] - public IEnumerable? PlanIds { get; init; } + public IEnumerable? PlanIds { get; set; } + /// + /// Search for plan entitlements by feature or company name + /// [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + /// + /// Filter plan entitlements only with metered products + /// + [JsonPropertyName("with_metered_products")] + public bool? WithMeteredProducts { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsResponse.cs index f528559..684d8dd 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountPlanEntitlementsResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountPlanEntitlementsParams Params { get; init; } + public required CountPlanEntitlementsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyMetricPeriod.cs b/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyMetricPeriod.cs index b62ee09..e19346d 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyMetricPeriod.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyMetricPeriod.cs @@ -1,15 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateCompanyOverrideRequestBodyMetricPeriod { + [EnumMember(Value = "all_time")] + AllTime, + [EnumMember(Value = "current_month")] CurrentMonth, @@ -17,5 +19,5 @@ public enum CreateCompanyOverrideRequestBodyMetricPeriod CurrentWeek, [EnumMember(Value = "current_day")] - CurrentDay + CurrentDay, } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyMetricPeriodMonthReset.cs b/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyMetricPeriodMonthReset.cs new file mode 100644 index 0000000..84a00ef --- /dev/null +++ b/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyMetricPeriodMonthReset.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(EnumSerializer))] +public enum CreateCompanyOverrideRequestBodyMetricPeriodMonthReset +{ + [EnumMember(Value = "first_of_month")] + FirstOfMonth, + + [EnumMember(Value = "billing_cycle")] + BillingCycle, +} diff --git a/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyValueType.cs b/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyValueType.cs index a627006..9c9e1e3 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyValueType.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideRequestBodyValueType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateCompanyOverrideRequestBodyValueType { [EnumMember(Value = "boolean")] @@ -20,5 +19,5 @@ public enum CreateCompanyOverrideRequestBodyValueType Trait, [EnumMember(Value = "unlimited")] - Unlimited + Unlimited, } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideResponse.cs index b0bcfff..82d38d4 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CreateCompanyOverrideResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateCompanyOverrideResponse { [JsonPropertyName("data")] - public required CompanyOverrideResponseData Data { get; init; } + public required CompanyOverrideResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyMetricPeriod.cs b/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyMetricPeriod.cs index a1f76b8..a64cad1 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyMetricPeriod.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyMetricPeriod.cs @@ -1,15 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreatePlanEntitlementRequestBodyMetricPeriod { + [EnumMember(Value = "all_time")] + AllTime, + [EnumMember(Value = "current_month")] CurrentMonth, @@ -17,5 +19,5 @@ public enum CreatePlanEntitlementRequestBodyMetricPeriod CurrentWeek, [EnumMember(Value = "current_day")] - CurrentDay + CurrentDay, } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyMetricPeriodMonthReset.cs b/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyMetricPeriodMonthReset.cs new file mode 100644 index 0000000..0d2466a --- /dev/null +++ b/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyMetricPeriodMonthReset.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(EnumSerializer))] +public enum CreatePlanEntitlementRequestBodyMetricPeriodMonthReset +{ + [EnumMember(Value = "first_of_month")] + FirstOfMonth, + + [EnumMember(Value = "billing_cycle")] + BillingCycle, +} diff --git a/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyValueType.cs b/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyValueType.cs index 6a52b5b..09c9e8e 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyValueType.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementRequestBodyValueType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreatePlanEntitlementRequestBodyValueType { [EnumMember(Value = "boolean")] @@ -20,5 +19,5 @@ public enum CreatePlanEntitlementRequestBodyValueType Trait, [EnumMember(Value = "unlimited")] - Unlimited + Unlimited, } diff --git a/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementResponse.cs index 326972e..85f02b7 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CreatePlanEntitlementResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreatePlanEntitlementResponse { [JsonPropertyName("data")] - public required PlanEntitlementResponseData Data { get; init; } + public required PlanEntitlementResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/DeleteCompanyOverrideResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/DeleteCompanyOverrideResponse.cs index 01a6cb2..eef8714 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/DeleteCompanyOverrideResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/DeleteCompanyOverrideResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteCompanyOverrideResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/DeletePlanEntitlementResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/DeletePlanEntitlementResponse.cs index b6951f6..4b135d9 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/DeletePlanEntitlementResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/DeletePlanEntitlementResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeletePlanEntitlementResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/GetCompanyOverrideResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/GetCompanyOverrideResponse.cs index 3477fc8..615f9ee 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/GetCompanyOverrideResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/GetCompanyOverrideResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetCompanyOverrideResponse { [JsonPropertyName("data")] - public required CompanyOverrideResponseData Data { get; init; } + public required CompanyOverrideResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/GetFeatureUsageByCompanyParams.cs b/src/SchematicHQ.Client/Entitlements/Types/GetFeatureUsageByCompanyParams.cs index db67492..d8e1c80 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/GetFeatureUsageByCompanyParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/GetFeatureUsageByCompanyParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,5 +8,10 @@ namespace SchematicHQ.Client; public record GetFeatureUsageByCompanyParams { [JsonPropertyName("keys")] - public Dictionary? Keys { get; init; } + public Dictionary? Keys { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/GetFeatureUsageByCompanyResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/GetFeatureUsageByCompanyResponse.cs index 654f5a1..5eb784b 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/GetFeatureUsageByCompanyResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/GetFeatureUsageByCompanyResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetFeatureUsageByCompanyResponse { [JsonPropertyName("data")] - public required FeatureUsageDetailResponseData Data { get; init; } + public required FeatureUsageDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required GetFeatureUsageByCompanyParams Params { get; init; } + public required GetFeatureUsageByCompanyParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/GetPlanEntitlementResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/GetPlanEntitlementResponse.cs index 06667a6..e3e3254 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/GetPlanEntitlementResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/GetPlanEntitlementResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetPlanEntitlementResponse { [JsonPropertyName("data")] - public required PlanEntitlementResponseData Data { get; init; } + public required PlanEntitlementResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesParams.cs b/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesParams.cs index fc2d1d5..d86767f 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,33 +7,62 @@ namespace SchematicHQ.Client; public record ListCompanyOverridesParams { + /// + /// Filter company overrides by a single company ID (starting with comp_) + /// [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } + /// + /// Filter company overrides by multiple company IDs (starting with comp_) + /// [JsonPropertyName("company_ids")] - public IEnumerable? CompanyIds { get; init; } + public IEnumerable? CompanyIds { get; set; } + /// + /// Filter company overrides by a single feature ID (starting with feat_) + /// [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } + /// + /// Filter company overrides by multiple feature IDs (starting with feat_) + /// [JsonPropertyName("feature_ids")] - public IEnumerable? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; set; } + /// + /// Filter company overrides by multiple company override IDs (starting with cmov_) + /// [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + /// + /// Search for company overrides by feature or company name + /// [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + /// + /// Filter company overrides by whether they have not expired + /// + [JsonPropertyName("without_expired")] + public bool? WithoutExpired { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesResponse.cs index 12fb928..8d33943 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListCompanyOverridesResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListCompanyOverridesParams Params { get; init; } + public required ListCompanyOverridesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesParams.cs b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesParams.cs index 41ed2ee..8689d6e 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record ListFeatureCompaniesParams { [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesResponse.cs index d8871a9..063ece7 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListFeatureCompaniesResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListFeatureCompaniesParams Params { get; init; } + public required ListFeatureCompaniesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageParams.cs b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageParams.cs index 7028c8b..79dd87d 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,26 +8,34 @@ namespace SchematicHQ.Client; public record ListFeatureUsageParams { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("company_keys")] - public Dictionary? CompanyKeys { get; init; } + public Dictionary? CompanyKeys { get; set; } [JsonPropertyName("feature_ids")] - public IEnumerable? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + [JsonPropertyName("without_negative_entitlements")] + public bool? WithoutNegativeEntitlements { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageResponse.cs index 8b645e0..224c275 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListFeatureUsageResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListFeatureUsageParams Params { get; init; } + public required ListFeatureUsageParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersParams.cs b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersParams.cs index 565250c..3212ba7 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record ListFeatureUsersParams { [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersResponse.cs index fb54f67..172664b 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListFeatureUsersResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListFeatureUsersParams Params { get; init; } + public required ListFeatureUsersParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsParams.cs b/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsParams.cs index 58f2b0c..42e2b3b 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,33 +7,62 @@ namespace SchematicHQ.Client; public record ListPlanEntitlementsParams { + /// + /// Filter plan entitlements by a single feature ID (starting with feat_) + /// [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } + /// + /// Filter plan entitlements by multiple feature IDs (starting with feat_) + /// [JsonPropertyName("feature_ids")] - public IEnumerable? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; set; } + /// + /// Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) + /// [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + /// + /// Filter plan entitlements by a single plan ID (starting with plan_) + /// [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } + /// + /// Filter plan entitlements by multiple plan IDs (starting with plan_) + /// [JsonPropertyName("plan_ids")] - public IEnumerable? PlanIds { get; init; } + public IEnumerable? PlanIds { get; set; } + /// + /// Search for plan entitlements by feature or company name + /// [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + /// + /// Filter plan entitlements only with metered products + /// + [JsonPropertyName("with_metered_products")] + public bool? WithMeteredProducts { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsResponse.cs index ae8d48b..9cf2df1 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListPlanEntitlementsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListPlanEntitlementsParams Params { get; init; } + public required ListPlanEntitlementsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyMetricPeriod.cs b/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyMetricPeriod.cs index 8a0f1d1..8dc2736 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyMetricPeriod.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyMetricPeriod.cs @@ -1,15 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdateCompanyOverrideRequestBodyMetricPeriod { + [EnumMember(Value = "all_time")] + AllTime, + [EnumMember(Value = "current_month")] CurrentMonth, @@ -17,5 +19,5 @@ public enum UpdateCompanyOverrideRequestBodyMetricPeriod CurrentWeek, [EnumMember(Value = "current_day")] - CurrentDay + CurrentDay, } diff --git a/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset.cs b/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset.cs new file mode 100644 index 0000000..137f2ab --- /dev/null +++ b/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(EnumSerializer))] +public enum UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset +{ + [EnumMember(Value = "first_of_month")] + FirstOfMonth, + + [EnumMember(Value = "billing_cycle")] + BillingCycle, +} diff --git a/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyValueType.cs b/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyValueType.cs index ef59f23..9011280 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyValueType.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideRequestBodyValueType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdateCompanyOverrideRequestBodyValueType { [EnumMember(Value = "boolean")] @@ -20,5 +19,5 @@ public enum UpdateCompanyOverrideRequestBodyValueType Trait, [EnumMember(Value = "unlimited")] - Unlimited + Unlimited, } diff --git a/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideResponse.cs index 1a749e0..4cc7beb 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/UpdateCompanyOverrideResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdateCompanyOverrideResponse { [JsonPropertyName("data")] - public required CompanyOverrideResponseData Data { get; init; } + public required CompanyOverrideResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyMetricPeriod.cs b/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyMetricPeriod.cs index 3338962..7b0e4ee 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyMetricPeriod.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyMetricPeriod.cs @@ -1,15 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdatePlanEntitlementRequestBodyMetricPeriod { + [EnumMember(Value = "all_time")] + AllTime, + [EnumMember(Value = "current_month")] CurrentMonth, @@ -17,5 +19,5 @@ public enum UpdatePlanEntitlementRequestBodyMetricPeriod CurrentWeek, [EnumMember(Value = "current_day")] - CurrentDay + CurrentDay, } diff --git a/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset.cs b/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset.cs new file mode 100644 index 0000000..7bdbaaf --- /dev/null +++ b/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(EnumSerializer))] +public enum UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset +{ + [EnumMember(Value = "first_of_month")] + FirstOfMonth, + + [EnumMember(Value = "billing_cycle")] + BillingCycle, +} diff --git a/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyValueType.cs b/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyValueType.cs index e0ed5cc..88e037b 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyValueType.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementRequestBodyValueType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdatePlanEntitlementRequestBodyValueType { [EnumMember(Value = "boolean")] @@ -20,5 +19,5 @@ public enum UpdatePlanEntitlementRequestBodyValueType Trait, [EnumMember(Value = "unlimited")] - Unlimited + Unlimited, } diff --git a/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementResponse.cs index fa6a9e3..b91ee75 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/UpdatePlanEntitlementResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdatePlanEntitlementResponse { [JsonPropertyName("data")] - public required PlanEntitlementResponseData Data { get; init; } + public required PlanEntitlementResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/EventsClient.cs b/src/SchematicHQ.Client/Events/EventsClient.cs index 1ab2721..4074590 100644 --- a/src/SchematicHQ.Client/Events/EventsClient.cs +++ b/src/SchematicHQ.Client/Events/EventsClient.cs @@ -1,54 +1,107 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class EventsClient +public partial class EventsClient { private RawClient _client; - public EventsClient(RawClient client) + internal EventsClient(RawClient client) { _client = client; } + /// + /// + /// await client.Events.CreateEventBatchAsync( + /// new CreateEventBatchRequestBody + /// { + /// Events = new List<CreateEventRequestBody>() + /// { + /// new CreateEventRequestBody { EventType = CreateEventRequestBodyEventType.Identify }, + /// }, + /// } + /// ); + /// + /// public async Task CreateEventBatchAsync( - CreateEventBatchRequestBody request + CreateEventBatchRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "event-batch", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Events.GetEventSummariesAsync(new GetEventSummariesRequest()); + /// + /// public async Task GetEventSummariesAsync( - GetEventSummariesRequest request + GetEventSummariesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["event_subtypes"] = request.EventSubtypes; if (request.Q != null) { _query["q"] = request.Q; } - if (request.EventSubtypes != null) - { - _query["event_subtypes"] = request.EventSubtypes; - } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -60,35 +113,65 @@ GetEventSummariesRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "event-types", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); - } - public async Task GetEventSummaryBySubtypeAsync(string key) - { - var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"event-types/{key}" } - ); - var responseBody = await response.Raw.Content.ReadAsStringAsync(); - if (response.StatusCode is >= 200 and < 400) + try { - return JsonSerializer.Deserialize(responseBody)!; + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task ListEventsAsync(ListEventsRequest request) + /// + /// + /// await client.Events.ListEventsAsync(new ListEventsRequest()); + /// + /// + public async Task ListEventsAsync( + ListEventsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["event_types"] = request.EventTypes; if (request.CompanyId != null) { _query["company_id"] = request.CompanyId; @@ -97,10 +180,6 @@ public async Task ListEventsAsync(ListEventsRequest request) { _query["event_subtype"] = request.EventSubtype; } - if (request.EventTypes != null) - { - _query["event_types"] = request.EventTypes; - } if (request.FlagId != null) { _query["flag_id"] = request.FlagId; @@ -120,121 +199,229 @@ public async Task ListEventsAsync(ListEventsRequest request) var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "events", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CreateEventAsync(CreateEventRequestBody request) + /// + /// + /// await client.Events.CreateEventAsync( + /// new CreateEventRequestBody { EventType = CreateEventRequestBodyEventType.Identify } + /// ); + /// + /// + public async Task CreateEventAsync( + CreateEventRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "events", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetEventAsync(string eventId) + /// + /// + /// await client.Events.GetEventAsync("event_id"); + /// + /// + public async Task GetEventAsync( + string eventId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"events/{eventId}" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = $"events/{eventId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); - } - public async Task ListMetricCountsAsync( - ListMetricCountsRequest request - ) - { - var _query = new Dictionary() { }; - if (request.StartTime != null) - { - _query["start_time"] = request.StartTime.Value.ToString("o0"); - } - if (request.EndTime != null) - { - _query["end_time"] = request.EndTime.Value.ToString("o0"); - } - if (request.EventSubtype != null) - { - _query["event_subtype"] = request.EventSubtype; - } - if (request.EventSubtypes != null) - { - _query["event_subtypes"] = request.EventSubtypes; - } - if (request.CompanyId != null) - { - _query["company_id"] = request.CompanyId; - } - if (request.CompanyIds != null) - { - _query["company_ids"] = request.CompanyIds; - } - if (request.UserId != null) - { - _query["user_id"] = request.UserId; - } - if (request.Limit != null) - { - _query["limit"] = request.Limit.ToString(); - } - if (request.Offset != null) + try { - _query["offset"] = request.Offset.ToString(); + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - if (request.Grouping != null) + catch (JsonException) { - _query["grouping"] = request.Grouping; + // unable to map error response, throwing generic error } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Events.GetSegmentIntegrationStatusAsync(); + /// + /// + public async Task GetSegmentIntegrationStatusAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = "metric-counts", - Query = _query - } + Path = "segment-integration", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); - } - public async Task GetSegmentIntegrationStatusAsync() - { - var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = "segment-integration" } - ); - var responseBody = await response.Raw.Content.ReadAsStringAsync(); - if (response.StatusCode is >= 200 and < 400) + try { - return JsonSerializer.Deserialize(responseBody)!; + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } } diff --git a/src/SchematicHQ.Client/Events/Requests/CreateEventBatchRequestBody.cs b/src/SchematicHQ.Client/Events/Requests/CreateEventBatchRequestBody.cs index 05bb84b..2b96c55 100644 --- a/src/SchematicHQ.Client/Events/Requests/CreateEventBatchRequestBody.cs +++ b/src/SchematicHQ.Client/Events/Requests/CreateEventBatchRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,6 +8,11 @@ namespace SchematicHQ.Client; public record CreateEventBatchRequestBody { [JsonPropertyName("events")] - public IEnumerable Events { get; init; } = + public IEnumerable Events { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Requests/GetEventSummariesRequest.cs b/src/SchematicHQ.Client/Events/Requests/GetEventSummariesRequest.cs index c7c53ec..bf17356 100644 --- a/src/SchematicHQ.Client/Events/Requests/GetEventSummariesRequest.cs +++ b/src/SchematicHQ.Client/Events/Requests/GetEventSummariesRequest.cs @@ -1,18 +1,27 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record GetEventSummariesRequest { - public string? Q { get; init; } + public string? Q { get; set; } - public string? EventSubtypes { get; init; } + public IEnumerable EventSubtypes { get; set; } = new List(); /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Requests/ListEventsRequest.cs b/src/SchematicHQ.Client/Events/Requests/ListEventsRequest.cs index ac9d447..59a477b 100644 --- a/src/SchematicHQ.Client/Events/Requests/ListEventsRequest.cs +++ b/src/SchematicHQ.Client/Events/Requests/ListEventsRequest.cs @@ -1,24 +1,33 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListEventsRequest { - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } - public string? EventSubtype { get; init; } + public string? EventSubtype { get; set; } - public string? EventTypes { get; init; } + public IEnumerable EventTypes { get; set; } = new List(); - public string? FlagId { get; init; } + public string? FlagId { get; set; } - public string? UserId { get; init; } + public string? UserId { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Requests/ListMetricCountsRequest.cs b/src/SchematicHQ.Client/Events/Requests/ListMetricCountsRequest.cs deleted file mode 100644 index b292c9f..0000000 --- a/src/SchematicHQ.Client/Events/Requests/ListMetricCountsRequest.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace SchematicHQ.Client; - -public record ListMetricCountsRequest -{ - public DateTime? StartTime { get; init; } - - public DateTime? EndTime { get; init; } - - public string? EventSubtype { get; init; } - - public string? EventSubtypes { get; init; } - - public string? CompanyId { get; init; } - - public string? CompanyIds { get; init; } - - public string? UserId { get; init; } - - /// - /// Page limit (default 100) - /// - public int? Limit { get; init; } - - /// - /// Page offset (default 0) - /// - public int? Offset { get; init; } - - public string? Grouping { get; init; } -} diff --git a/src/SchematicHQ.Client/Events/Types/CreateEventBatchResponse.cs b/src/SchematicHQ.Client/Events/Types/CreateEventBatchResponse.cs index c007cb2..db2c46f 100644 --- a/src/SchematicHQ.Client/Events/Types/CreateEventBatchResponse.cs +++ b/src/SchematicHQ.Client/Events/Types/CreateEventBatchResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateEventBatchResponse { [JsonPropertyName("data")] - public required RawEventBatchResponseData Data { get; init; } + public required RawEventBatchResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Types/CreateEventResponse.cs b/src/SchematicHQ.Client/Events/Types/CreateEventResponse.cs index bd79452..4ee7bfc 100644 --- a/src/SchematicHQ.Client/Events/Types/CreateEventResponse.cs +++ b/src/SchematicHQ.Client/Events/Types/CreateEventResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateEventResponse { [JsonPropertyName("data")] - public required RawEventResponseData Data { get; init; } + public required RawEventResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Types/GetEventResponse.cs b/src/SchematicHQ.Client/Events/Types/GetEventResponse.cs index 0be8db1..1d71902 100644 --- a/src/SchematicHQ.Client/Events/Types/GetEventResponse.cs +++ b/src/SchematicHQ.Client/Events/Types/GetEventResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetEventResponse { [JsonPropertyName("data")] - public required EventDetailResponseData Data { get; init; } + public required EventDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Types/GetEventSummariesParams.cs b/src/SchematicHQ.Client/Events/Types/GetEventSummariesParams.cs index eda2e11..d6f943e 100644 --- a/src/SchematicHQ.Client/Events/Types/GetEventSummariesParams.cs +++ b/src/SchematicHQ.Client/Events/Types/GetEventSummariesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record GetEventSummariesParams { [JsonPropertyName("event_subtypes")] - public IEnumerable? EventSubtypes { get; init; } + public IEnumerable? EventSubtypes { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Types/GetEventSummariesResponse.cs b/src/SchematicHQ.Client/Events/Types/GetEventSummariesResponse.cs index b8c86a3..6a163f7 100644 --- a/src/SchematicHQ.Client/Events/Types/GetEventSummariesResponse.cs +++ b/src/SchematicHQ.Client/Events/Types/GetEventSummariesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record GetEventSummariesResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required GetEventSummariesParams Params { get; init; } + public required GetEventSummariesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Types/GetEventSummaryBySubtypeResponse.cs b/src/SchematicHQ.Client/Events/Types/GetEventSummaryBySubtypeResponse.cs deleted file mode 100644 index 64a4dad..0000000 --- a/src/SchematicHQ.Client/Events/Types/GetEventSummaryBySubtypeResponse.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Text.Json.Serialization; -using SchematicHQ.Client; - -#nullable enable - -namespace SchematicHQ.Client; - -public record GetEventSummaryBySubtypeResponse -{ - [JsonPropertyName("data")] - public required EventSummaryResponseData Data { get; init; } - - /// - /// Input parameters - /// - [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); -} diff --git a/src/SchematicHQ.Client/Events/Types/GetSegmentIntegrationStatusResponse.cs b/src/SchematicHQ.Client/Events/Types/GetSegmentIntegrationStatusResponse.cs index 5f14e89..6c67219 100644 --- a/src/SchematicHQ.Client/Events/Types/GetSegmentIntegrationStatusResponse.cs +++ b/src/SchematicHQ.Client/Events/Types/GetSegmentIntegrationStatusResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetSegmentIntegrationStatusResponse { [JsonPropertyName("data")] - public required SegmentStatusResp Data { get; init; } + public required SegmentStatusResp Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Types/ListEventsParams.cs b/src/SchematicHQ.Client/Events/Types/ListEventsParams.cs index 7e75e43..523e11f 100644 --- a/src/SchematicHQ.Client/Events/Types/ListEventsParams.cs +++ b/src/SchematicHQ.Client/Events/Types/ListEventsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,29 +8,34 @@ namespace SchematicHQ.Client; public record ListEventsParams { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("event_subtype")] - public string? EventSubtype { get; init; } + public string? EventSubtype { get; set; } [JsonPropertyName("event_types")] - public IEnumerable? EventTypes { get; init; } + public IEnumerable? EventTypes { get; set; } [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("user_id")] - public string? UserId { get; init; } + public string? UserId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Types/ListEventsResponse.cs b/src/SchematicHQ.Client/Events/Types/ListEventsResponse.cs index 970c768..cae9f6c 100644 --- a/src/SchematicHQ.Client/Events/Types/ListEventsResponse.cs +++ b/src/SchematicHQ.Client/Events/Types/ListEventsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListEventsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListEventsParams Params { get; init; } + public required ListEventsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Events/Types/ListMetricCountsParams.cs b/src/SchematicHQ.Client/Events/Types/ListMetricCountsParams.cs deleted file mode 100644 index e39fdc0..0000000 --- a/src/SchematicHQ.Client/Events/Types/ListMetricCountsParams.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Text.Json.Serialization; - -#nullable enable - -namespace SchematicHQ.Client; - -public record ListMetricCountsParams -{ - [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } - - [JsonPropertyName("company_ids")] - public IEnumerable? CompanyIds { get; init; } - - [JsonPropertyName("end_time")] - public DateTime? EndTime { get; init; } - - [JsonPropertyName("event_subtype")] - public string? EventSubtype { get; init; } - - [JsonPropertyName("event_subtypes")] - public IEnumerable? EventSubtypes { get; init; } - - [JsonPropertyName("grouping")] - public string? Grouping { get; init; } - - /// - /// Page limit (default 100) - /// - [JsonPropertyName("limit")] - public int? Limit { get; init; } - - /// - /// Page offset (default 0) - /// - [JsonPropertyName("offset")] - public int? Offset { get; init; } - - [JsonPropertyName("start_time")] - public DateTime? StartTime { get; init; } - - [JsonPropertyName("user_id")] - public string? UserId { get; init; } -} diff --git a/src/SchematicHQ.Client/Events/Types/ListMetricCountsResponse.cs b/src/SchematicHQ.Client/Events/Types/ListMetricCountsResponse.cs deleted file mode 100644 index 369bbb2..0000000 --- a/src/SchematicHQ.Client/Events/Types/ListMetricCountsResponse.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Text.Json.Serialization; -using SchematicHQ.Client; - -#nullable enable - -namespace SchematicHQ.Client; - -public record ListMetricCountsResponse -{ - /// - /// The returned resources - /// - [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = - new List(); - - /// - /// Input parameters - /// - [JsonPropertyName("params")] - public required ListMetricCountsParams Params { get; init; } -} diff --git a/src/SchematicHQ.Client/Exceptions/BadRequestError.cs b/src/SchematicHQ.Client/Exceptions/BadRequestError.cs new file mode 100644 index 0000000..0eeaf63 --- /dev/null +++ b/src/SchematicHQ.Client/Exceptions/BadRequestError.cs @@ -0,0 +1,16 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +/// +/// This exception type will be thrown for any non-2XX API responses. +/// +public class BadRequestError(ApiError body) : SchematicApiApiException("BadRequestError", 400, body) +{ + /// + /// The body of the response that triggered the exception. + /// + public new ApiError Body => body; +} diff --git a/src/SchematicHQ.Client/Exceptions/ForbiddenError.cs b/src/SchematicHQ.Client/Exceptions/ForbiddenError.cs new file mode 100644 index 0000000..c2c2fac --- /dev/null +++ b/src/SchematicHQ.Client/Exceptions/ForbiddenError.cs @@ -0,0 +1,16 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +/// +/// This exception type will be thrown for any non-2XX API responses. +/// +public class ForbiddenError(ApiError body) : SchematicApiApiException("ForbiddenError", 403, body) +{ + /// + /// The body of the response that triggered the exception. + /// + public new ApiError Body => body; +} diff --git a/src/SchematicHQ.Client/Exceptions/InternalServerError.cs b/src/SchematicHQ.Client/Exceptions/InternalServerError.cs new file mode 100644 index 0000000..fccfe15 --- /dev/null +++ b/src/SchematicHQ.Client/Exceptions/InternalServerError.cs @@ -0,0 +1,17 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +/// +/// This exception type will be thrown for any non-2XX API responses. +/// +public class InternalServerError(ApiError body) + : SchematicApiApiException("InternalServerError", 500, body) +{ + /// + /// The body of the response that triggered the exception. + /// + public new ApiError Body => body; +} diff --git a/src/SchematicHQ.Client/Exceptions/NotFoundError.cs b/src/SchematicHQ.Client/Exceptions/NotFoundError.cs new file mode 100644 index 0000000..4e254bb --- /dev/null +++ b/src/SchematicHQ.Client/Exceptions/NotFoundError.cs @@ -0,0 +1,16 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +/// +/// This exception type will be thrown for any non-2XX API responses. +/// +public class NotFoundError(ApiError body) : SchematicApiApiException("NotFoundError", 404, body) +{ + /// + /// The body of the response that triggered the exception. + /// + public new ApiError Body => body; +} diff --git a/src/SchematicHQ.Client/Exceptions/UnauthorizedError.cs b/src/SchematicHQ.Client/Exceptions/UnauthorizedError.cs new file mode 100644 index 0000000..d419e7b --- /dev/null +++ b/src/SchematicHQ.Client/Exceptions/UnauthorizedError.cs @@ -0,0 +1,17 @@ +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +/// +/// This exception type will be thrown for any non-2XX API responses. +/// +public class UnauthorizedError(ApiError body) + : SchematicApiApiException("UnauthorizedError", 401, body) +{ + /// + /// The body of the response that triggered the exception. + /// + public new ApiError Body => body; +} diff --git a/src/SchematicHQ.Client/Features/FeaturesClient.cs b/src/SchematicHQ.Client/Features/FeaturesClient.cs index f91eeb7..6190d43 100644 --- a/src/SchematicHQ.Client/Features/FeaturesClient.cs +++ b/src/SchematicHQ.Client/Features/FeaturesClient.cs @@ -1,106 +1,390 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class FeaturesClient +public partial class FeaturesClient { private RawClient _client; - public FeaturesClient(RawClient client) + internal FeaturesClient(RawClient client) { _client = client; } + /// + /// + /// await client.Features.CountAudienceCompaniesAsync( + /// new AudienceRequestBody + /// { + /// ConditionGroups = new List<CreateOrUpdateConditionGroupRequestBody>() + /// { + /// new CreateOrUpdateConditionGroupRequestBody + /// { + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// }, + /// }, + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// } + /// ); + /// + /// public async Task CountAudienceCompaniesAsync( - AudienceRequestBody request + AudienceRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "audience/count-companies", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Features.CountAudienceUsersAsync( + /// new AudienceRequestBody + /// { + /// ConditionGroups = new List<CreateOrUpdateConditionGroupRequestBody>() + /// { + /// new CreateOrUpdateConditionGroupRequestBody + /// { + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// }, + /// }, + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// } + /// ); + /// + /// public async Task CountAudienceUsersAsync( - AudienceRequestBody request + AudienceRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "audience/count-users", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Features.ListAudienceCompaniesAsync( + /// new AudienceRequestBody + /// { + /// ConditionGroups = new List<CreateOrUpdateConditionGroupRequestBody>() + /// { + /// new CreateOrUpdateConditionGroupRequestBody + /// { + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// }, + /// }, + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// } + /// ); + /// + /// public async Task ListAudienceCompaniesAsync( - AudienceRequestBody request + AudienceRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "audience/get-companies", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task ListAudienceUsersAsync(AudienceRequestBody request) + /// + /// + /// await client.Features.ListAudienceUsersAsync( + /// new AudienceRequestBody + /// { + /// ConditionGroups = new List<CreateOrUpdateConditionGroupRequestBody>() + /// { + /// new CreateOrUpdateConditionGroupRequestBody + /// { + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// }, + /// }, + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// } + /// ); + /// + /// + public async Task ListAudienceUsersAsync( + AudienceRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "audience/get-users", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); - } - public async Task ListFeaturesAsync(ListFeaturesRequest request) - { - var _query = new Dictionary() { }; - if (request.Ids != null) + try { - _query["ids"] = request.Ids; + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Features.ListFeaturesAsync(new ListFeaturesRequest()); + /// + /// + public async Task ListFeaturesAsync( + ListFeaturesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.Q != null) { _query["q"] = request.Q; @@ -124,95 +408,315 @@ public async Task ListFeaturesAsync(ListFeaturesRequest re var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "features", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CreateFeatureAsync(CreateFeatureRequestBody request) + /// + /// + /// await client.Features.CreateFeatureAsync( + /// new CreateFeatureRequestBody + /// { + /// Description = "description", + /// FeatureType = CreateFeatureRequestBodyFeatureType.Boolean, + /// Name = "name", + /// } + /// ); + /// + /// + public async Task CreateFeatureAsync( + CreateFeatureRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "features", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetFeatureAsync(string featureId) + /// + /// + /// await client.Features.GetFeatureAsync("feature_id"); + /// + /// + public async Task GetFeatureAsync( + string featureId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"features/{featureId}" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = $"features/{featureId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Features.UpdateFeatureAsync("feature_id", new UpdateFeatureRequestBody()); + /// + /// public async Task UpdateFeatureAsync( string featureId, - UpdateFeatureRequestBody request + UpdateFeatureRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"features/{featureId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteFeatureAsync(string featureId) + /// + /// + /// await client.Features.DeleteFeatureAsync("feature_id"); + /// + /// + public async Task DeleteFeatureAsync( + string featureId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, - Path = $"features/{featureId}" - } + Path = $"features/{featureId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); - } - public async Task CountFeaturesAsync(CountFeaturesRequest request) - { - var _query = new Dictionary() { }; - if (request.Ids != null) + try { - _query["ids"] = request.Ids; + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Features.CountFeaturesAsync(new CountFeaturesRequest()); + /// + /// + public async Task CountFeaturesAsync( + CountFeaturesRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.Q != null) { _query["q"] = request.Q; @@ -236,30 +740,69 @@ public async Task CountFeaturesAsync(CountFeaturesRequest var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "features/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task ListFlagsAsync(ListFlagsRequest request) + /// + /// + /// await client.Features.ListFlagsAsync(new ListFlagsRequest()); + /// + /// + public async Task ListFlagsAsync( + ListFlagsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.FeatureId != null) { _query["feature_id"] = request.FeatureId; } - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } if (request.Q != null) { _query["q"] = request.Q; @@ -275,152 +818,557 @@ public async Task ListFlagsAsync(ListFlagsRequest request) var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "flags", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CreateFlagAsync(CreateFlagRequestBody request) + /// + /// + /// await client.Features.CreateFlagAsync( + /// new CreateFlagRequestBody + /// { + /// DefaultValue = true, + /// Description = "description", + /// FlagType = "flag_type", + /// Key = "key", + /// Name = "name", + /// } + /// ); + /// + /// + public async Task CreateFlagAsync( + CreateFlagRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "flags", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetFlagAsync(string flagId) + /// + /// + /// await client.Features.GetFlagAsync("flag_id"); + /// + /// + public async Task GetFlagAsync( + string flagId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"flags/{flagId}" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = $"flags/{flagId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Features.UpdateFlagAsync( + /// "flag_id", + /// new CreateFlagRequestBody + /// { + /// DefaultValue = true, + /// Description = "description", + /// FlagType = "flag_type", + /// Key = "key", + /// Name = "name", + /// } + /// ); + /// + /// public async Task UpdateFlagAsync( string flagId, - CreateFlagRequestBody request + CreateFlagRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"flags/{flagId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteFlagAsync(string flagId) + /// + /// + /// await client.Features.DeleteFlagAsync("flag_id"); + /// + /// + public async Task DeleteFlagAsync( + string flagId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Delete, Path = $"flags/{flagId}" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Delete, + Path = $"flags/{flagId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Features.UpdateFlagRulesAsync( + /// "flag_id", + /// new UpdateFlagRulesRequestBody + /// { + /// Rules = new List<CreateOrUpdateRuleRequestBody>() + /// { + /// new CreateOrUpdateRuleRequestBody + /// { + /// ConditionGroups = new List<CreateOrUpdateConditionGroupRequestBody>() + /// { + /// new CreateOrUpdateConditionGroupRequestBody + /// { + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = + /// CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// }, + /// }, + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// Name = "name", + /// Priority = 1, + /// Value = true, + /// }, + /// }, + /// } + /// ); + /// + /// public async Task UpdateFlagRulesAsync( string flagId, - UpdateFlagRulesRequestBody request + UpdateFlagRulesRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"flags/{flagId}/rules", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CheckFlagAsync(string key, CheckFlagRequestBody request) + /// + /// + /// await client.Features.CheckFlagAsync("key", new CheckFlagRequestBody()); + /// + /// + public async Task CheckFlagAsync( + string key, + CheckFlagRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = $"flags/{key}/check", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CheckFlagsAsync(CheckFlagRequestBody request) + /// + /// + /// await client.Features.CheckFlagsAsync(new CheckFlagRequestBody()); + /// + /// + public async Task CheckFlagsAsync( + CheckFlagRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "flags/check", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CountFlagsAsync(CountFlagsRequest request) + /// + /// + /// await client.Features.CountFlagsAsync(new CountFlagsRequest()); + /// + /// + public async Task CountFlagsAsync( + CountFlagsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.FeatureId != null) { _query["feature_id"] = request.FeatureId; } - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } if (request.Q != null) { _query["q"] = request.Q; @@ -436,16 +1384,49 @@ public async Task CountFlagsAsync(CountFlagsRequest request) var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "flags/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } } diff --git a/src/SchematicHQ.Client/Features/Requests/CountFeaturesRequest.cs b/src/SchematicHQ.Client/Features/Requests/CountFeaturesRequest.cs index 164103e..a612d04 100644 --- a/src/SchematicHQ.Client/Features/Requests/CountFeaturesRequest.cs +++ b/src/SchematicHQ.Client/Features/Requests/CountFeaturesRequest.cs @@ -1,28 +1,37 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountFeaturesRequest { - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Q { get; init; } + public string? Q { get; set; } /// /// Filter out features that already have a company override for the specified company ID /// - public string? WithoutCompanyOverrideFor { get; init; } + public string? WithoutCompanyOverrideFor { get; set; } /// /// Filter out features that already have a plan entitlement for the specified plan ID /// - public string? WithoutPlanEntitlementFor { get; init; } + public string? WithoutPlanEntitlementFor { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Requests/CountFlagsRequest.cs b/src/SchematicHQ.Client/Features/Requests/CountFlagsRequest.cs index 7be5f6a..5984514 100644 --- a/src/SchematicHQ.Client/Features/Requests/CountFlagsRequest.cs +++ b/src/SchematicHQ.Client/Features/Requests/CountFlagsRequest.cs @@ -1,20 +1,29 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountFlagsRequest { - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Requests/CreateFeatureRequestBody.cs b/src/SchematicHQ.Client/Features/Requests/CreateFeatureRequestBody.cs index b5de2bc..93f1290 100644 --- a/src/SchematicHQ.Client/Features/Requests/CreateFeatureRequestBody.cs +++ b/src/SchematicHQ.Client/Features/Requests/CreateFeatureRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,29 +8,34 @@ namespace SchematicHQ.Client; public record CreateFeatureRequestBody { [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("event_subtype")] - public string? EventSubtype { get; init; } + public string? EventSubtype { get; set; } [JsonPropertyName("feature_type")] - public required CreateFeatureRequestBodyFeatureType FeatureType { get; init; } + public required CreateFeatureRequestBodyFeatureType FeatureType { get; set; } [JsonPropertyName("flag")] - public CreateOrUpdateFlagRequestBody? Flag { get; init; } + public CreateOrUpdateFlagRequestBody? Flag { get; set; } [JsonPropertyName("icon")] - public string? Icon { get; init; } + public string? Icon { get; set; } [JsonPropertyName("lifecycle_phase")] - public string? LifecyclePhase { get; init; } + public string? LifecyclePhase { get; set; } [JsonPropertyName("maintainer_id")] - public string? MaintainerId { get; init; } + public string? MaintainerId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("trait_id")] - public string? TraitId { get; init; } + public string? TraitId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Requests/ListFeaturesRequest.cs b/src/SchematicHQ.Client/Features/Requests/ListFeaturesRequest.cs index e6a9711..6df2aa1 100644 --- a/src/SchematicHQ.Client/Features/Requests/ListFeaturesRequest.cs +++ b/src/SchematicHQ.Client/Features/Requests/ListFeaturesRequest.cs @@ -1,28 +1,37 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListFeaturesRequest { - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Q { get; init; } + public string? Q { get; set; } /// /// Filter out features that already have a company override for the specified company ID /// - public string? WithoutCompanyOverrideFor { get; init; } + public string? WithoutCompanyOverrideFor { get; set; } /// /// Filter out features that already have a plan entitlement for the specified plan ID /// - public string? WithoutPlanEntitlementFor { get; init; } + public string? WithoutPlanEntitlementFor { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Requests/ListFlagsRequest.cs b/src/SchematicHQ.Client/Features/Requests/ListFlagsRequest.cs index b33c7f6..5e86558 100644 --- a/src/SchematicHQ.Client/Features/Requests/ListFlagsRequest.cs +++ b/src/SchematicHQ.Client/Features/Requests/ListFlagsRequest.cs @@ -1,20 +1,29 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListFlagsRequest { - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } - public string? Ids { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Requests/UpdateFeatureRequestBody.cs b/src/SchematicHQ.Client/Features/Requests/UpdateFeatureRequestBody.cs index 5fe89cd..4dc269f 100644 --- a/src/SchematicHQ.Client/Features/Requests/UpdateFeatureRequestBody.cs +++ b/src/SchematicHQ.Client/Features/Requests/UpdateFeatureRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,29 +8,34 @@ namespace SchematicHQ.Client; public record UpdateFeatureRequestBody { [JsonPropertyName("description")] - public string? Description { get; init; } + public string? Description { get; set; } [JsonPropertyName("event_subtype")] - public string? EventSubtype { get; init; } + public string? EventSubtype { get; set; } [JsonPropertyName("feature_type")] - public UpdateFeatureRequestBodyFeatureType? FeatureType { get; init; } + public UpdateFeatureRequestBodyFeatureType? FeatureType { get; set; } [JsonPropertyName("flag")] - public CreateOrUpdateFlagRequestBody? Flag { get; init; } + public CreateOrUpdateFlagRequestBody? Flag { get; set; } [JsonPropertyName("icon")] - public string? Icon { get; init; } + public string? Icon { get; set; } [JsonPropertyName("lifecycle_phase")] - public string? LifecyclePhase { get; init; } + public string? LifecyclePhase { get; set; } [JsonPropertyName("maintainer_id")] - public string? MaintainerId { get; init; } + public string? MaintainerId { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } [JsonPropertyName("trait_id")] - public string? TraitId { get; init; } + public string? TraitId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Requests/UpdateFlagRulesRequestBody.cs b/src/SchematicHQ.Client/Features/Requests/UpdateFlagRulesRequestBody.cs index d8dd86d..14e9c4b 100644 --- a/src/SchematicHQ.Client/Features/Requests/UpdateFlagRulesRequestBody.cs +++ b/src/SchematicHQ.Client/Features/Requests/UpdateFlagRulesRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,6 +8,11 @@ namespace SchematicHQ.Client; public record UpdateFlagRulesRequestBody { [JsonPropertyName("rules")] - public IEnumerable Rules { get; init; } = + public IEnumerable Rules { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/CheckFlagResponse.cs b/src/SchematicHQ.Client/Features/Types/CheckFlagResponse.cs index 7f6202a..3ad96e9 100644 --- a/src/SchematicHQ.Client/Features/Types/CheckFlagResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/CheckFlagResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CheckFlagResponse { [JsonPropertyName("data")] - public required CheckFlagResponseData Data { get; init; } + public required CheckFlagResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/CheckFlagsResponse.cs b/src/SchematicHQ.Client/Features/Types/CheckFlagsResponse.cs index ae0799e..01fb21a 100644 --- a/src/SchematicHQ.Client/Features/Types/CheckFlagsResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/CheckFlagsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CheckFlagsResponse { [JsonPropertyName("data")] - public required CheckFlagsResponseData Data { get; init; } + public required CheckFlagsResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/CountAudienceCompaniesResponse.cs b/src/SchematicHQ.Client/Features/Types/CountAudienceCompaniesResponse.cs index bb0b449..8074c0a 100644 --- a/src/SchematicHQ.Client/Features/Types/CountAudienceCompaniesResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/CountAudienceCompaniesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountAudienceCompaniesResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/CountAudienceUsersResponse.cs b/src/SchematicHQ.Client/Features/Types/CountAudienceUsersResponse.cs index 6f577ff..0fda738 100644 --- a/src/SchematicHQ.Client/Features/Types/CountAudienceUsersResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/CountAudienceUsersResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountAudienceUsersResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs b/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs index 956ae56..8bd1588 100644 --- a/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs +++ b/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,32 +8,37 @@ namespace SchematicHQ.Client; public record CountFeaturesParams { [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } /// /// Filter out features that already have a company override for the specified company ID /// [JsonPropertyName("without_company_override_for")] - public string? WithoutCompanyOverrideFor { get; init; } + public string? WithoutCompanyOverrideFor { get; set; } /// /// Filter out features that already have a plan entitlement for the specified plan ID /// [JsonPropertyName("without_plan_entitlement_for")] - public string? WithoutPlanEntitlementFor { get; init; } + public string? WithoutPlanEntitlementFor { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/CountFeaturesResponse.cs b/src/SchematicHQ.Client/Features/Types/CountFeaturesResponse.cs index 86cd8e5..5b0ffca 100644 --- a/src/SchematicHQ.Client/Features/Types/CountFeaturesResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/CountFeaturesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountFeaturesResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountFeaturesParams Params { get; init; } + public required CountFeaturesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/CountFlagsParams.cs b/src/SchematicHQ.Client/Features/Types/CountFlagsParams.cs index 4827cd1..703941f 100644 --- a/src/SchematicHQ.Client/Features/Types/CountFlagsParams.cs +++ b/src/SchematicHQ.Client/Features/Types/CountFlagsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record CountFlagsParams { [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/CountFlagsResponse.cs b/src/SchematicHQ.Client/Features/Types/CountFlagsResponse.cs index bffd576..24cfa96 100644 --- a/src/SchematicHQ.Client/Features/Types/CountFlagsResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/CountFlagsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountFlagsResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountFlagsParams Params { get; init; } + public required CountFlagsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/CreateFeatureRequestBodyFeatureType.cs b/src/SchematicHQ.Client/Features/Types/CreateFeatureRequestBodyFeatureType.cs index f3345e2..1079586 100644 --- a/src/SchematicHQ.Client/Features/Types/CreateFeatureRequestBodyFeatureType.cs +++ b/src/SchematicHQ.Client/Features/Types/CreateFeatureRequestBodyFeatureType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateFeatureRequestBodyFeatureType { [EnumMember(Value = "boolean")] @@ -17,5 +16,5 @@ public enum CreateFeatureRequestBodyFeatureType Event, [EnumMember(Value = "trait")] - Trait + Trait, } diff --git a/src/SchematicHQ.Client/Features/Types/CreateFeatureResponse.cs b/src/SchematicHQ.Client/Features/Types/CreateFeatureResponse.cs index 0230783..2ca31e0 100644 --- a/src/SchematicHQ.Client/Features/Types/CreateFeatureResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/CreateFeatureResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateFeatureResponse { [JsonPropertyName("data")] - public required FeatureDetailResponseData Data { get; init; } + public required FeatureDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/CreateFlagResponse.cs b/src/SchematicHQ.Client/Features/Types/CreateFlagResponse.cs index 63608e3..6655f64 100644 --- a/src/SchematicHQ.Client/Features/Types/CreateFlagResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/CreateFlagResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateFlagResponse { [JsonPropertyName("data")] - public required FlagDetailResponseData Data { get; init; } + public required FlagDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/DeleteFeatureResponse.cs b/src/SchematicHQ.Client/Features/Types/DeleteFeatureResponse.cs index 44bede0..a0f6c96 100644 --- a/src/SchematicHQ.Client/Features/Types/DeleteFeatureResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/DeleteFeatureResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteFeatureResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/DeleteFlagResponse.cs b/src/SchematicHQ.Client/Features/Types/DeleteFlagResponse.cs index 5d9f2a8..d9897cf 100644 --- a/src/SchematicHQ.Client/Features/Types/DeleteFlagResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/DeleteFlagResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteFlagResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/GetFeatureResponse.cs b/src/SchematicHQ.Client/Features/Types/GetFeatureResponse.cs index 19a23be..4db0779 100644 --- a/src/SchematicHQ.Client/Features/Types/GetFeatureResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/GetFeatureResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetFeatureResponse { [JsonPropertyName("data")] - public required FeatureDetailResponseData Data { get; init; } + public required FeatureDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/GetFlagResponse.cs b/src/SchematicHQ.Client/Features/Types/GetFlagResponse.cs index ab074c8..1af4872 100644 --- a/src/SchematicHQ.Client/Features/Types/GetFlagResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/GetFlagResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetFlagResponse { [JsonPropertyName("data")] - public required FlagDetailResponseData Data { get; init; } + public required FlagDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/ListAudienceCompaniesResponse.cs b/src/SchematicHQ.Client/Features/Types/ListAudienceCompaniesResponse.cs index 04c8976..e4a881a 100644 --- a/src/SchematicHQ.Client/Features/Types/ListAudienceCompaniesResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/ListAudienceCompaniesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListAudienceCompaniesResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/ListAudienceUsersResponse.cs b/src/SchematicHQ.Client/Features/Types/ListAudienceUsersResponse.cs index 09c8cdc..6e5a6be 100644 --- a/src/SchematicHQ.Client/Features/Types/ListAudienceUsersResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/ListAudienceUsersResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListAudienceUsersResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs b/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs index 7bb94a2..961adf1 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,32 +8,37 @@ namespace SchematicHQ.Client; public record ListFeaturesParams { [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } /// /// Filter out features that already have a company override for the specified company ID /// [JsonPropertyName("without_company_override_for")] - public string? WithoutCompanyOverrideFor { get; init; } + public string? WithoutCompanyOverrideFor { get; set; } /// /// Filter out features that already have a plan entitlement for the specified plan ID /// [JsonPropertyName("without_plan_entitlement_for")] - public string? WithoutPlanEntitlementFor { get; init; } + public string? WithoutPlanEntitlementFor { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/ListFeaturesResponse.cs b/src/SchematicHQ.Client/Features/Types/ListFeaturesResponse.cs index e055892..360dbf1 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFeaturesResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFeaturesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListFeaturesResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListFeaturesParams Params { get; init; } + public required ListFeaturesParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/ListFlagsParams.cs b/src/SchematicHQ.Client/Features/Types/ListFlagsParams.cs index 46cfbec..c2c42e7 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFlagsParams.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFlagsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record ListFlagsParams { [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/ListFlagsResponse.cs b/src/SchematicHQ.Client/Features/Types/ListFlagsResponse.cs index fc2818c..68571ea 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFlagsResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFlagsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListFlagsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListFlagsParams Params { get; init; } + public required ListFlagsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/UpdateFeatureRequestBodyFeatureType.cs b/src/SchematicHQ.Client/Features/Types/UpdateFeatureRequestBodyFeatureType.cs index 06fb6d9..4f85dc4 100644 --- a/src/SchematicHQ.Client/Features/Types/UpdateFeatureRequestBodyFeatureType.cs +++ b/src/SchematicHQ.Client/Features/Types/UpdateFeatureRequestBodyFeatureType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdateFeatureRequestBodyFeatureType { [EnumMember(Value = "boolean")] @@ -17,5 +16,5 @@ public enum UpdateFeatureRequestBodyFeatureType Event, [EnumMember(Value = "trait")] - Trait + Trait, } diff --git a/src/SchematicHQ.Client/Features/Types/UpdateFeatureResponse.cs b/src/SchematicHQ.Client/Features/Types/UpdateFeatureResponse.cs index d20528f..438f7b0 100644 --- a/src/SchematicHQ.Client/Features/Types/UpdateFeatureResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/UpdateFeatureResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdateFeatureResponse { [JsonPropertyName("data")] - public required FeatureDetailResponseData Data { get; init; } + public required FeatureDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/UpdateFlagResponse.cs b/src/SchematicHQ.Client/Features/Types/UpdateFlagResponse.cs index bb6633d..3e0a843 100644 --- a/src/SchematicHQ.Client/Features/Types/UpdateFlagResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/UpdateFlagResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdateFlagResponse { [JsonPropertyName("data")] - public required FlagDetailResponseData Data { get; init; } + public required FlagDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Features/Types/UpdateFlagRulesResponse.cs b/src/SchematicHQ.Client/Features/Types/UpdateFlagRulesResponse.cs index 36ebe42..4889a6d 100644 --- a/src/SchematicHQ.Client/Features/Types/UpdateFlagRulesResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/UpdateFlagRulesResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdateFlagRulesResponse { [JsonPropertyName("data")] - public required RulesDetailResponseData Data { get; init; } + public required RulesDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plangroups/PlangroupsClient.cs b/src/SchematicHQ.Client/Plangroups/PlangroupsClient.cs new file mode 100644 index 0000000..f5c5d8d --- /dev/null +++ b/src/SchematicHQ.Client/Plangroups/PlangroupsClient.cs @@ -0,0 +1,214 @@ +using System.Net.Http; +using System.Text.Json; +using System.Threading; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public partial class PlangroupsClient +{ + private RawClient _client; + + internal PlangroupsClient(RawClient client) + { + _client = client; + } + + /// + /// + /// await client.Plangroups.GetPlanGroupAsync(); + /// + /// + public async Task GetPlanGroupAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = "plan-groups", + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Plangroups.CreatePlanGroupAsync( + /// new CreatePlanGroupRequestBody + /// { + /// AddOnIds = new List<string>() { "add_on_ids" }, + /// PlanIds = new List<string>() { "plan_ids" }, + /// } + /// ); + /// + /// + public async Task CreatePlanGroupAsync( + CreatePlanGroupRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Post, + Path = "plan-groups", + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Plangroups.UpdatePlanGroupAsync( + /// "plan_group_id", + /// new UpdatePlanGroupRequestBody + /// { + /// AddOnIds = new List<string>() { "add_on_ids" }, + /// PlanIds = new List<string>() { "plan_ids" }, + /// } + /// ); + /// + /// + public async Task UpdatePlanGroupAsync( + string planGroupId, + UpdatePlanGroupRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Put, + Path = $"plan-groups/{planGroupId}", + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ); + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + if (response.StatusCode is >= 200 and < 400) + { + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } +} diff --git a/src/SchematicHQ.Client/Plangroups/Requests/CreatePlanGroupRequestBody.cs b/src/SchematicHQ.Client/Plangroups/Requests/CreatePlanGroupRequestBody.cs new file mode 100644 index 0000000..d114fcd --- /dev/null +++ b/src/SchematicHQ.Client/Plangroups/Requests/CreatePlanGroupRequestBody.cs @@ -0,0 +1,29 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CreatePlanGroupRequestBody +{ + [JsonPropertyName("add_on_ids")] + public IEnumerable AddOnIds { get; set; } = new List(); + + [JsonPropertyName("default_plan_id")] + public string? DefaultPlanId { get; set; } + + [JsonPropertyName("plan_ids")] + public IEnumerable PlanIds { get; set; } = new List(); + + [JsonPropertyName("trial_days")] + public int? TrialDays { get; set; } + + [JsonPropertyName("trial_payment_method_required")] + public bool? TrialPaymentMethodRequired { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Plangroups/Requests/UpdatePlanGroupRequestBody.cs b/src/SchematicHQ.Client/Plangroups/Requests/UpdatePlanGroupRequestBody.cs new file mode 100644 index 0000000..b3f35d9 --- /dev/null +++ b/src/SchematicHQ.Client/Plangroups/Requests/UpdatePlanGroupRequestBody.cs @@ -0,0 +1,29 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpdatePlanGroupRequestBody +{ + [JsonPropertyName("add_on_ids")] + public IEnumerable AddOnIds { get; set; } = new List(); + + [JsonPropertyName("default_plan_id")] + public string? DefaultPlanId { get; set; } + + [JsonPropertyName("plan_ids")] + public IEnumerable PlanIds { get; set; } = new List(); + + [JsonPropertyName("trial_days")] + public int? TrialDays { get; set; } + + [JsonPropertyName("trial_payment_method_required")] + public bool? TrialPaymentMethodRequired { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Plangroups/Types/CreatePlanGroupResponse.cs b/src/SchematicHQ.Client/Plangroups/Types/CreatePlanGroupResponse.cs new file mode 100644 index 0000000..d5cd9c6 --- /dev/null +++ b/src/SchematicHQ.Client/Plangroups/Types/CreatePlanGroupResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CreatePlanGroupResponse +{ + [JsonPropertyName("data")] + public required PlanGroupResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Plangroups/Types/GetPlanGroupResponse.cs b/src/SchematicHQ.Client/Plangroups/Types/GetPlanGroupResponse.cs new file mode 100644 index 0000000..380935d --- /dev/null +++ b/src/SchematicHQ.Client/Plangroups/Types/GetPlanGroupResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record GetPlanGroupResponse +{ + [JsonPropertyName("data")] + public required PlanGroupDetailResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Plangroups/Types/UpdatePlanGroupResponse.cs b/src/SchematicHQ.Client/Plangroups/Types/UpdatePlanGroupResponse.cs new file mode 100644 index 0000000..2c05103 --- /dev/null +++ b/src/SchematicHQ.Client/Plangroups/Types/UpdatePlanGroupResponse.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpdatePlanGroupResponse +{ + [JsonPropertyName("data")] + public required PlanGroupResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Plans/PlansClient.cs b/src/SchematicHQ.Client/Plans/PlansClient.cs index d880664..cf2e7ba 100644 --- a/src/SchematicHQ.Client/Plans/PlansClient.cs +++ b/src/SchematicHQ.Client/Plans/PlansClient.cs @@ -1,99 +1,269 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class PlansClient +public partial class PlansClient { private RawClient _client; - public PlansClient(RawClient client) + internal PlansClient(RawClient client) { _client = client; } - public async Task GetAudienceAsync(string planAudienceId) + /// + /// + /// await client.Plans.GetAudienceAsync("plan_audience_id"); + /// + /// + public async Task GetAudienceAsync( + string planAudienceId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"plan-audiences/{planAudienceId}" - } + Path = $"plan-audiences/{planAudienceId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Plans.UpdateAudienceAsync( + /// "plan_audience_id", + /// new UpdateAudienceRequestBody + /// { + /// ConditionGroups = new List<CreateOrUpdateConditionGroupRequestBody>() + /// { + /// new CreateOrUpdateConditionGroupRequestBody + /// { + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// }, + /// }, + /// Conditions = new List<CreateOrUpdateConditionRequestBody>() + /// { + /// new CreateOrUpdateConditionRequestBody + /// { + /// ConditionType = CreateOrUpdateConditionRequestBodyConditionType.Company, + /// Operator = CreateOrUpdateConditionRequestBodyOperator.Eq, + /// ResourceIds = new List<string>() { "resource_ids" }, + /// }, + /// }, + /// } + /// ); + /// + /// public async Task UpdateAudienceAsync( string planAudienceId, - UpdateAudienceRequestBody request + UpdateAudienceRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"plan-audiences/{planAudienceId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteAudienceAsync(string planAudienceId) + /// + /// + /// await client.Plans.DeleteAudienceAsync("plan_audience_id"); + /// + /// + public async Task DeleteAudienceAsync( + string planAudienceId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, - Path = $"plan-audiences/{planAudienceId}" - } + Path = $"plan-audiences/{planAudienceId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task ListPlansAsync(ListPlansRequest request) + /// + /// + /// await client.Plans.ListPlansAsync(new ListPlansRequest()); + /// + /// + public async Task ListPlansAsync( + ListPlansRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.CompanyId != null) { _query["company_id"] = request.CompanyId; } - if (request.Ids != null) + if (request.HasProductId != null) { - _query["ids"] = request.Ids; + _query["has_product_id"] = request.HasProductId.ToString(); } - if (request.Q != null) + if (request.PlanType != null) { - _query["q"] = request.Q; + _query["plan_type"] = request.PlanType.Value.Stringify(); } - if (request.PlanType != null) + if (request.Q != null) { - _query["plan_type"] = JsonSerializer.Serialize(request.PlanType.Value); + _query["q"] = request.Q; } if (request.WithoutEntitlementFor != null) { _query["without_entitlement_for"] = request.WithoutEntitlementFor; } + if (request.WithoutProductId != null) + { + _query["without_product_id"] = request.WithoutProductId.ToString(); + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -105,128 +275,406 @@ public async Task ListPlansAsync(ListPlansRequest request) var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "plans", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CreatePlanAsync(CreatePlanRequestBody request) + /// + /// + /// await client.Plans.CreatePlanAsync( + /// new CreatePlanRequestBody + /// { + /// Description = "description", + /// Name = "name", + /// PlanType = CreatePlanRequestBodyPlanType.Plan, + /// } + /// ); + /// + /// + public async Task CreatePlanAsync( + CreatePlanRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "plans", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetPlanAsync(string planId) + /// + /// + /// await client.Plans.GetPlanAsync("plan_id"); + /// + /// + public async Task GetPlanAsync( + string planId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"plans/{planId}" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = $"plans/{planId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Plans.UpdatePlanAsync("plan_id", new UpdatePlanRequestBody { Name = "name" }); + /// + /// public async Task UpdatePlanAsync( string planId, - UpdatePlanRequestBody request + UpdatePlanRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"plans/{planId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeletePlanAsync(string planId) + /// + /// + /// await client.Plans.DeletePlanAsync("plan_id"); + /// + /// + public async Task DeletePlanAsync( + string planId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Delete, Path = $"plans/{planId}" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Delete, + Path = $"plans/{planId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Plans.UpsertBillingProductPlanAsync( + /// "plan_id", + /// new UpsertBillingProductRequestBody { IsFreePlan = true, IsTrialable = true } + /// ); + /// + /// public async Task UpsertBillingProductPlanAsync( string planId, - UpsertBillingProductRequestBody request + UpsertBillingProductRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"plans/{planId}/billing_products", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CountPlansAsync(CountPlansRequest request) + /// + /// + /// await client.Plans.CountPlansAsync(new CountPlansRequest()); + /// + /// + public async Task CountPlansAsync( + CountPlansRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.CompanyId != null) { _query["company_id"] = request.CompanyId; } - if (request.Ids != null) + if (request.HasProductId != null) { - _query["ids"] = request.Ids; + _query["has_product_id"] = request.HasProductId.ToString(); } - if (request.Q != null) + if (request.PlanType != null) { - _query["q"] = request.Q; + _query["plan_type"] = request.PlanType.Value.Stringify(); } - if (request.PlanType != null) + if (request.Q != null) { - _query["plan_type"] = JsonSerializer.Serialize(request.PlanType.Value); + _query["q"] = request.Q; } if (request.WithoutEntitlementFor != null) { _query["without_entitlement_for"] = request.WithoutEntitlementFor; } + if (request.WithoutProductId != null) + { + _query["without_product_id"] = request.WithoutProductId.ToString(); + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -238,16 +686,49 @@ public async Task CountPlansAsync(CountPlansRequest request) var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "plans/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } } diff --git a/src/SchematicHQ.Client/Plans/Requests/CountPlansRequest.cs b/src/SchematicHQ.Client/Plans/Requests/CountPlansRequest.cs index 31a1eca..5017edb 100644 --- a/src/SchematicHQ.Client/Plans/Requests/CountPlansRequest.cs +++ b/src/SchematicHQ.Client/Plans/Requests/CountPlansRequest.cs @@ -1,4 +1,4 @@ -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -6,29 +6,44 @@ namespace SchematicHQ.Client; public record CountPlansRequest { - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } - public string? Ids { get; init; } + /// + /// Filter out plans that do not have a billing product ID + /// + public bool? HasProductId { get; set; } - public string? Q { get; init; } + public IEnumerable Ids { get; set; } = new List(); /// /// Filter by plan type /// - public CountPlansRequestPlanType? PlanType { get; init; } + public CountPlansRequestPlanType? PlanType { get; set; } + + public string? Q { get; set; } /// /// Filter out plans that already have a plan entitlement for the specified feature ID /// - public string? WithoutEntitlementFor { get; init; } + public string? WithoutEntitlementFor { get; set; } + + /// + /// Filter out plans that have a billing product ID + /// + public bool? WithoutProductId { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Requests/CreatePlanRequestBody.cs b/src/SchematicHQ.Client/Plans/Requests/CreatePlanRequestBody.cs index c4b172a..465de91 100644 --- a/src/SchematicHQ.Client/Plans/Requests/CreatePlanRequestBody.cs +++ b/src/SchematicHQ.Client/Plans/Requests/CreatePlanRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,14 +8,19 @@ namespace SchematicHQ.Client; public record CreatePlanRequestBody { [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("icon")] - public string? Icon { get; init; } + public string? Icon { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("plan_type")] - public required CreatePlanRequestBodyPlanType PlanType { get; init; } + public required CreatePlanRequestBodyPlanType PlanType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Requests/ListPlansRequest.cs b/src/SchematicHQ.Client/Plans/Requests/ListPlansRequest.cs index 87ca1ef..e26d41d 100644 --- a/src/SchematicHQ.Client/Plans/Requests/ListPlansRequest.cs +++ b/src/SchematicHQ.Client/Plans/Requests/ListPlansRequest.cs @@ -1,4 +1,4 @@ -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -6,29 +6,44 @@ namespace SchematicHQ.Client; public record ListPlansRequest { - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } - public string? Ids { get; init; } + /// + /// Filter out plans that do not have a billing product ID + /// + public bool? HasProductId { get; set; } - public string? Q { get; init; } + public IEnumerable Ids { get; set; } = new List(); /// /// Filter by plan type /// - public ListPlansRequestPlanType? PlanType { get; init; } + public ListPlansRequestPlanType? PlanType { get; set; } + + public string? Q { get; set; } /// /// Filter out plans that already have a plan entitlement for the specified feature ID /// - public string? WithoutEntitlementFor { get; init; } + public string? WithoutEntitlementFor { get; set; } + + /// + /// Filter out plans that have a billing product ID + /// + public bool? WithoutProductId { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Requests/UpdateAudienceRequestBody.cs b/src/SchematicHQ.Client/Plans/Requests/UpdateAudienceRequestBody.cs index fef1324..f0e6d9e 100644 --- a/src/SchematicHQ.Client/Plans/Requests/UpdateAudienceRequestBody.cs +++ b/src/SchematicHQ.Client/Plans/Requests/UpdateAudienceRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,10 +8,15 @@ namespace SchematicHQ.Client; public record UpdateAudienceRequestBody { [JsonPropertyName("condition_groups")] - public IEnumerable ConditionGroups { get; init; } = + public IEnumerable ConditionGroups { get; set; } = new List(); [JsonPropertyName("conditions")] - public IEnumerable Conditions { get; init; } = + public IEnumerable Conditions { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Requests/UpdatePlanRequestBody.cs b/src/SchematicHQ.Client/Plans/Requests/UpdatePlanRequestBody.cs index c069bc4..56f061f 100644 --- a/src/SchematicHQ.Client/Plans/Requests/UpdatePlanRequestBody.cs +++ b/src/SchematicHQ.Client/Plans/Requests/UpdatePlanRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdatePlanRequestBody { [JsonPropertyName("description")] - public string? Description { get; init; } + public string? Description { get; set; } [JsonPropertyName("icon")] - public string? Icon { get; init; } + public string? Icon { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Requests/UpsertBillingProductRequestBody.cs b/src/SchematicHQ.Client/Plans/Requests/UpsertBillingProductRequestBody.cs index ad28848..2964b18 100644 --- a/src/SchematicHQ.Client/Plans/Requests/UpsertBillingProductRequestBody.cs +++ b/src/SchematicHQ.Client/Plans/Requests/UpsertBillingProductRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,11 +8,25 @@ namespace SchematicHQ.Client; public record UpsertBillingProductRequestBody { [JsonPropertyName("billing_product_id")] - public required string BillingProductId { get; init; } + public string? BillingProductId { get; set; } + + [JsonPropertyName("is_free_plan")] + public required bool IsFreePlan { get; set; } + + [JsonPropertyName("is_trialable")] + public required bool IsTrialable { get; set; } [JsonPropertyName("monthly_price_id")] - public string? MonthlyPriceId { get; init; } + public string? MonthlyPriceId { get; set; } + + [JsonPropertyName("trial_days")] + public int? TrialDays { get; set; } [JsonPropertyName("yearly_price_id")] - public string? YearlyPriceId { get; init; } + public string? YearlyPriceId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs b/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs index de1b3bd..f106463 100644 --- a/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs +++ b/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,35 +8,52 @@ namespace SchematicHQ.Client; public record CountPlansParams { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } + + /// + /// Filter out plans that do not have a billing product ID + /// + [JsonPropertyName("has_product_id")] + public bool? HasProductId { get; set; } [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } /// /// Filter by plan type /// [JsonPropertyName("plan_type")] - public CountPlansResponseParamsPlanType? PlanType { get; init; } + public CountPlansResponseParamsPlanType? PlanType { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } /// /// Filter out plans that already have a plan entitlement for the specified feature ID /// [JsonPropertyName("without_entitlement_for")] - public string? WithoutEntitlementFor { get; init; } + public string? WithoutEntitlementFor { get; set; } + + /// + /// Filter out plans that have a billing product ID + /// + [JsonPropertyName("without_product_id")] + public bool? WithoutProductId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/CountPlansRequestPlanType.cs b/src/SchematicHQ.Client/Plans/Types/CountPlansRequestPlanType.cs index 52fcf2c..3be8b60 100644 --- a/src/SchematicHQ.Client/Plans/Types/CountPlansRequestPlanType.cs +++ b/src/SchematicHQ.Client/Plans/Types/CountPlansRequestPlanType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CountPlansRequestPlanType { [EnumMember(Value = "plan")] Plan, [EnumMember(Value = "add_on")] - AddOn + AddOn, } diff --git a/src/SchematicHQ.Client/Plans/Types/CountPlansResponse.cs b/src/SchematicHQ.Client/Plans/Types/CountPlansResponse.cs index 654f8e5..fef7ca7 100644 --- a/src/SchematicHQ.Client/Plans/Types/CountPlansResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/CountPlansResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountPlansResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountPlansParams Params { get; init; } + public required CountPlansParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/CountPlansResponseParamsPlanType.cs b/src/SchematicHQ.Client/Plans/Types/CountPlansResponseParamsPlanType.cs index 5bd554e..5162892 100644 --- a/src/SchematicHQ.Client/Plans/Types/CountPlansResponseParamsPlanType.cs +++ b/src/SchematicHQ.Client/Plans/Types/CountPlansResponseParamsPlanType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CountPlansResponseParamsPlanType { [EnumMember(Value = "plan")] Plan, [EnumMember(Value = "add_on")] - AddOn + AddOn, } diff --git a/src/SchematicHQ.Client/Plans/Types/CreatePlanRequestBodyPlanType.cs b/src/SchematicHQ.Client/Plans/Types/CreatePlanRequestBodyPlanType.cs index b3f6bda..4020266 100644 --- a/src/SchematicHQ.Client/Plans/Types/CreatePlanRequestBodyPlanType.cs +++ b/src/SchematicHQ.Client/Plans/Types/CreatePlanRequestBodyPlanType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreatePlanRequestBodyPlanType { [EnumMember(Value = "plan")] Plan, [EnumMember(Value = "add_on")] - AddOn + AddOn, } diff --git a/src/SchematicHQ.Client/Plans/Types/CreatePlanResponse.cs b/src/SchematicHQ.Client/Plans/Types/CreatePlanResponse.cs index b97bf0f..846fd4e 100644 --- a/src/SchematicHQ.Client/Plans/Types/CreatePlanResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/CreatePlanResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreatePlanResponse { [JsonPropertyName("data")] - public required PlanDetailResponseData Data { get; init; } + public required PlanDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/DeleteAudienceResponse.cs b/src/SchematicHQ.Client/Plans/Types/DeleteAudienceResponse.cs index a383306..6abe54f 100644 --- a/src/SchematicHQ.Client/Plans/Types/DeleteAudienceResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/DeleteAudienceResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteAudienceResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/DeletePlanResponse.cs b/src/SchematicHQ.Client/Plans/Types/DeletePlanResponse.cs index d37919b..95c012a 100644 --- a/src/SchematicHQ.Client/Plans/Types/DeletePlanResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/DeletePlanResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeletePlanResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/GetAudienceResponse.cs b/src/SchematicHQ.Client/Plans/Types/GetAudienceResponse.cs index 7829935..8b87cd7 100644 --- a/src/SchematicHQ.Client/Plans/Types/GetAudienceResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/GetAudienceResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetAudienceResponse { [JsonPropertyName("data")] - public required PlanAudienceDetailResponseData Data { get; init; } + public required PlanAudienceDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/GetPlanResponse.cs b/src/SchematicHQ.Client/Plans/Types/GetPlanResponse.cs index 1d68ddb..999ab34 100644 --- a/src/SchematicHQ.Client/Plans/Types/GetPlanResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/GetPlanResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetPlanResponse { [JsonPropertyName("data")] - public required PlanDetailResponseData Data { get; init; } + public required PlanDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs b/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs index 73b2aa5..88d6907 100644 --- a/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs +++ b/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,35 +8,52 @@ namespace SchematicHQ.Client; public record ListPlansParams { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } + + /// + /// Filter out plans that do not have a billing product ID + /// + [JsonPropertyName("has_product_id")] + public bool? HasProductId { get; set; } [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } /// /// Filter by plan type /// [JsonPropertyName("plan_type")] - public ListPlansResponseParamsPlanType? PlanType { get; init; } + public ListPlansResponseParamsPlanType? PlanType { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } /// /// Filter out plans that already have a plan entitlement for the specified feature ID /// [JsonPropertyName("without_entitlement_for")] - public string? WithoutEntitlementFor { get; init; } + public string? WithoutEntitlementFor { get; set; } + + /// + /// Filter out plans that have a billing product ID + /// + [JsonPropertyName("without_product_id")] + public bool? WithoutProductId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/ListPlansRequestPlanType.cs b/src/SchematicHQ.Client/Plans/Types/ListPlansRequestPlanType.cs index 5821c75..da60a4e 100644 --- a/src/SchematicHQ.Client/Plans/Types/ListPlansRequestPlanType.cs +++ b/src/SchematicHQ.Client/Plans/Types/ListPlansRequestPlanType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum ListPlansRequestPlanType { [EnumMember(Value = "plan")] Plan, [EnumMember(Value = "add_on")] - AddOn + AddOn, } diff --git a/src/SchematicHQ.Client/Plans/Types/ListPlansResponse.cs b/src/SchematicHQ.Client/Plans/Types/ListPlansResponse.cs index 15ee3f7..df6a215 100644 --- a/src/SchematicHQ.Client/Plans/Types/ListPlansResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/ListPlansResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListPlansResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListPlansParams Params { get; init; } + public required ListPlansParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/ListPlansResponseParamsPlanType.cs b/src/SchematicHQ.Client/Plans/Types/ListPlansResponseParamsPlanType.cs index f2f1766..3d1410d 100644 --- a/src/SchematicHQ.Client/Plans/Types/ListPlansResponseParamsPlanType.cs +++ b/src/SchematicHQ.Client/Plans/Types/ListPlansResponseParamsPlanType.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum ListPlansResponseParamsPlanType { [EnumMember(Value = "plan")] Plan, [EnumMember(Value = "add_on")] - AddOn + AddOn, } diff --git a/src/SchematicHQ.Client/Plans/Types/UpdateAudienceResponse.cs b/src/SchematicHQ.Client/Plans/Types/UpdateAudienceResponse.cs index 99912c2..e7665a5 100644 --- a/src/SchematicHQ.Client/Plans/Types/UpdateAudienceResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/UpdateAudienceResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdateAudienceResponse { [JsonPropertyName("data")] - public required PlanAudienceDetailResponseData Data { get; init; } + public required PlanAudienceDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/UpdatePlanResponse.cs b/src/SchematicHQ.Client/Plans/Types/UpdatePlanResponse.cs index 2041473..2212263 100644 --- a/src/SchematicHQ.Client/Plans/Types/UpdatePlanResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/UpdatePlanResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdatePlanResponse { [JsonPropertyName("data")] - public required PlanDetailResponseData Data { get; init; } + public required PlanDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Plans/Types/UpsertBillingProductPlanResponse.cs b/src/SchematicHQ.Client/Plans/Types/UpsertBillingProductPlanResponse.cs index 86fe539..610bacc 100644 --- a/src/SchematicHQ.Client/Plans/Types/UpsertBillingProductPlanResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/UpsertBillingProductPlanResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpsertBillingProductPlanResponse { [JsonPropertyName("data")] - public required BillingProductPlanResponseData Data { get; init; } + public required BillingProductPlanResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/SchematicApi.cs b/src/SchematicHQ.Client/SchematicApi.cs index e9345fa..c17892c 100644 --- a/src/SchematicHQ.Client/SchematicApi.cs +++ b/src/SchematicHQ.Client/SchematicApi.cs @@ -1,5 +1,6 @@ using System.Net.Http; -using SchematicHQ.Client; +using System.Threading; +using System.Threading.Tasks; using SchematicHQ.Client.Core; #nullable enable @@ -12,25 +13,36 @@ public partial class SchematicApi public SchematicApi(string? apiKey = null, ClientOptions? clientOptions = null) { - _client = new RawClient( + var defaultHeaders = new Headers( new Dictionary() { { "X-Schematic-Api-Key", apiKey }, { "X-Fern-Language", "C#" }, { "X-Fern-SDK-Name", "SchematicHQ.Client" }, - { "X-Fern-SDK-Version", "1.0.2" }, - }, - clientOptions ?? new ClientOptions() + { "X-Fern-SDK-Version", Version.Current }, + { "User-Agent", "SchematicHQ.Client/1.0.3" }, + } ); + clientOptions ??= new ClientOptions(); + foreach (var header in defaultHeaders) + { + if (!clientOptions.Headers.ContainsKey(header.Key)) + { + clientOptions.Headers[header.Key] = header.Value; + } + } + _client = new RawClient(clientOptions); Accounts = new AccountsClient(_client); Features = new FeaturesClient(_client); Billing = new BillingClient(_client); + Checkout = new CheckoutClient(_client); Companies = new CompaniesClient(_client); Entitlements = new EntitlementsClient(_client); Components = new ComponentsClient(_client); Crm = new CrmClient(_client); Events = new EventsClient(_client); Plans = new PlansClient(_client); + Plangroups = new PlangroupsClient(_client); Accesstokens = new AccesstokensClient(_client); Webhooks = new WebhooksClient(_client); } @@ -41,6 +53,8 @@ public SchematicApi(string? apiKey = null, ClientOptions? clientOptions = null) public BillingClient Billing { get; init; } + public CheckoutClient Checkout { get; init; } + public CompaniesClient Companies { get; init; } public EntitlementsClient Entitlements { get; init; } @@ -53,14 +67,41 @@ public SchematicApi(string? apiKey = null, ClientOptions? clientOptions = null) public PlansClient Plans { get; init; } + public PlangroupsClient Plangroups { get; init; } + public AccesstokensClient Accesstokens { get; init; } public WebhooksClient Webhooks { get; init; } - public async Task GetCompanyPlansAsync() + /// + /// + /// await client.GetCompanyPlansAsync(); + /// + /// + public async Task GetCompanyPlansAsync( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = "company-plans" } + var response = await _client.MakeRequestAsync( + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = "company-plans", + Options = options, + }, + cancellationToken + ); + if (response.StatusCode is >= 200 and < 400) + { + return; + } + var responseBody = await response.Raw.Content.ReadAsStringAsync(); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody ); } } diff --git a/src/SchematicHQ.Client/SchematicHQ.Client.Custom.props b/src/SchematicHQ.Client/SchematicHQ.Client.Custom.props new file mode 100644 index 0000000..70df284 --- /dev/null +++ b/src/SchematicHQ.Client/SchematicHQ.Client.Custom.props @@ -0,0 +1,20 @@ + + + + \ No newline at end of file diff --git a/src/SchematicHQ.Client/SchematicHQ.Client.csproj b/src/SchematicHQ.Client/SchematicHQ.Client.csproj index 1edb8a4..280a836 100644 --- a/src/SchematicHQ.Client/SchematicHQ.Client.csproj +++ b/src/SchematicHQ.Client/SchematicHQ.Client.csproj @@ -7,7 +7,9 @@ false 12 enable - 1.0.2 + 1.0.3 + $(Version) + $(Version) README.md https://github.com/schematichq/schematic-csharp @@ -43,5 +45,11 @@ + + + <_Parameter1>SchematicHQ.Client.Test + + + diff --git a/src/SchematicHQ.Client/Types/ApiError.cs b/src/SchematicHQ.Client/Types/ApiError.cs index 6476f4e..0425f65 100644 --- a/src/SchematicHQ.Client/Types/ApiError.cs +++ b/src/SchematicHQ.Client/Types/ApiError.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,5 +11,10 @@ public record ApiError /// Error message /// [JsonPropertyName("error")] - public required string Error { get; init; } + public required string Error { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs b/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs index 72a67d8..1351794 100644 --- a/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs +++ b/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,29 +8,34 @@ namespace SchematicHQ.Client; public record ApiKeyCreateResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("description")] - public string? Description { get; init; } + public string? Description { get; set; } [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("last_used_at")] - public DateTime? LastUsedAt { get; init; } + public DateTime? LastUsedAt { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("scopes")] - public IEnumerable Scopes { get; init; } = new List(); + public IEnumerable Scopes { get; set; } = new List(); [JsonPropertyName("secret")] - public required string Secret { get; init; } + public required string Secret { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/ApiKeyRequestListResponseData.cs b/src/SchematicHQ.Client/Types/ApiKeyRequestListResponseData.cs index fc25434..618cd14 100644 --- a/src/SchematicHQ.Client/Types/ApiKeyRequestListResponseData.cs +++ b/src/SchematicHQ.Client/Types/ApiKeyRequestListResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,50 +8,55 @@ namespace SchematicHQ.Client; public record ApiKeyRequestListResponseData { [JsonPropertyName("api_key_id")] - public required string ApiKeyId { get; init; } + public required string ApiKeyId { get; set; } [JsonPropertyName("ended_at")] - public DateTime? EndedAt { get; init; } + public DateTime? EndedAt { get; set; } [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("method")] - public required string Method { get; init; } + public required string Method { get; set; } [JsonPropertyName("req_body")] - public string? ReqBody { get; init; } + public string? ReqBody { get; set; } [JsonPropertyName("request_type")] - public string? RequestType { get; init; } + public string? RequestType { get; set; } [JsonPropertyName("resource_id")] - public int? ResourceId { get; init; } + public int? ResourceId { get; set; } [JsonPropertyName("resource_id_string")] - public string? ResourceIdString { get; init; } + public string? ResourceIdString { get; set; } [JsonPropertyName("resource_name")] - public string? ResourceName { get; init; } + public string? ResourceName { get; set; } [JsonPropertyName("resource_type")] - public string? ResourceType { get; init; } + public string? ResourceType { get; set; } [JsonPropertyName("resp_code")] - public int? RespCode { get; init; } + public int? RespCode { get; set; } [JsonPropertyName("secondary_resource")] - public string? SecondaryResource { get; init; } + public string? SecondaryResource { get; set; } [JsonPropertyName("started_at")] - public required DateTime StartedAt { get; init; } + public required DateTime StartedAt { get; set; } [JsonPropertyName("url")] - public required string Url { get; init; } + public required string Url { get; set; } [JsonPropertyName("user_name")] - public string? UserName { get; init; } + public string? UserName { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/ApiKeyRequestResponseData.cs b/src/SchematicHQ.Client/Types/ApiKeyRequestResponseData.cs index 7dfd5c5..294e2ca 100644 --- a/src/SchematicHQ.Client/Types/ApiKeyRequestResponseData.cs +++ b/src/SchematicHQ.Client/Types/ApiKeyRequestResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,59 +8,64 @@ namespace SchematicHQ.Client; public record ApiKeyRequestResponseData { [JsonPropertyName("api_key_id")] - public required string ApiKeyId { get; init; } + public required string ApiKeyId { get; set; } [JsonPropertyName("ended_at")] - public DateTime? EndedAt { get; init; } + public DateTime? EndedAt { get; set; } [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("method")] - public required string Method { get; init; } + public required string Method { get; set; } [JsonPropertyName("req_body")] - public string? ReqBody { get; init; } + public string? ReqBody { get; set; } [JsonPropertyName("request_type")] - public string? RequestType { get; init; } + public string? RequestType { get; set; } [JsonPropertyName("resource_id")] - public int? ResourceId { get; init; } + public int? ResourceId { get; set; } [JsonPropertyName("resource_id_string")] - public string? ResourceIdString { get; init; } + public string? ResourceIdString { get; set; } [JsonPropertyName("resource_name")] - public string? ResourceName { get; init; } + public string? ResourceName { get; set; } [JsonPropertyName("resource_type")] - public string? ResourceType { get; init; } + public string? ResourceType { get; set; } [JsonPropertyName("resp_body")] - public string? RespBody { get; init; } + public string? RespBody { get; set; } [JsonPropertyName("resp_code")] - public int? RespCode { get; init; } + public int? RespCode { get; set; } [JsonPropertyName("secondary_resource")] - public string? SecondaryResource { get; init; } + public string? SecondaryResource { get; set; } [JsonPropertyName("started_at")] - public required DateTime StartedAt { get; init; } + public required DateTime StartedAt { get; set; } [JsonPropertyName("url")] - public required string Url { get; init; } + public required string Url { get; set; } [JsonPropertyName("user_agent")] - public string? UserAgent { get; init; } + public string? UserAgent { get; set; } [JsonPropertyName("user_id")] - public string? UserId { get; init; } + public string? UserId { get; set; } [JsonPropertyName("user_name")] - public string? UserName { get; init; } + public string? UserName { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs b/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs index f56760a..520484f 100644 --- a/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs +++ b/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,26 +8,31 @@ namespace SchematicHQ.Client; public record ApiKeyResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("description")] - public string? Description { get; init; } + public string? Description { get; set; } [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("last_used_at")] - public DateTime? LastUsedAt { get; init; } + public DateTime? LastUsedAt { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("scopes")] - public IEnumerable Scopes { get; init; } = new List(); + public IEnumerable Scopes { get; set; } = new List(); [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/AudienceRequestBody.cs b/src/SchematicHQ.Client/Types/AudienceRequestBody.cs index 72e808f..66ab9aa 100644 --- a/src/SchematicHQ.Client/Types/AudienceRequestBody.cs +++ b/src/SchematicHQ.Client/Types/AudienceRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,25 +8,30 @@ namespace SchematicHQ.Client; public record AudienceRequestBody { [JsonPropertyName("condition_groups")] - public IEnumerable ConditionGroups { get; init; } = + public IEnumerable ConditionGroups { get; set; } = new List(); [JsonPropertyName("conditions")] - public IEnumerable Conditions { get; init; } = + public IEnumerable Conditions { get; set; } = new List(); /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingCouponResponseData.cs b/src/SchematicHQ.Client/Types/BillingCouponResponseData.cs new file mode 100644 index 0000000..c840f03 --- /dev/null +++ b/src/SchematicHQ.Client/Types/BillingCouponResponseData.cs @@ -0,0 +1,62 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record BillingCouponResponseData +{ + [JsonPropertyName("account_id")] + public required string AccountId { get; set; } + + [JsonPropertyName("amount_off")] + public int? AmountOff { get; set; } + + [JsonPropertyName("currency")] + public string? Currency { get; set; } + + [JsonPropertyName("duration")] + public string? Duration { get; set; } + + [JsonPropertyName("duration_in_months")] + public int? DurationInMonths { get; set; } + + [JsonPropertyName("environment_id")] + public required string EnvironmentId { get; set; } + + [JsonPropertyName("external_id")] + public required string ExternalId { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("is_active")] + public required bool IsActive { get; set; } + + [JsonPropertyName("max_redemptions")] + public int? MaxRedemptions { get; set; } + + [JsonPropertyName("metadata")] + public Dictionary Metadata { get; set; } = new Dictionary(); + + [JsonPropertyName("name")] + public required string Name { get; set; } + + [JsonPropertyName("percent_off")] + public int? PercentOff { get; set; } + + [JsonPropertyName("times_redeemed")] + public required int TimesRedeemed { get; set; } + + [JsonPropertyName("valid_from")] + public DateTime? ValidFrom { get; set; } + + [JsonPropertyName("valid_until")] + public DateTime? ValidUntil { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/BillingCustomerResponseData.cs b/src/SchematicHQ.Client/Types/BillingCustomerResponseData.cs index 092f878..c425785 100644 --- a/src/SchematicHQ.Client/Types/BillingCustomerResponseData.cs +++ b/src/SchematicHQ.Client/Types/BillingCustomerResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,26 +8,31 @@ namespace SchematicHQ.Client; public record BillingCustomerResponseData { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("deleted_at")] - public DateTime? DeletedAt { get; init; } + public DateTime? DeletedAt { get; set; } [JsonPropertyName("email")] - public required string Email { get; init; } + public required string Email { get; set; } [JsonPropertyName("external_id")] - public required string ExternalId { get; init; } + public required string ExternalId { get; set; } [JsonPropertyName("failed_to_import")] - public required bool FailedToImport { get; init; } + public required bool FailedToImport { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingCustomerSubscription.cs b/src/SchematicHQ.Client/Types/BillingCustomerSubscription.cs index 9c3f11c..4571b1b 100644 --- a/src/SchematicHQ.Client/Types/BillingCustomerSubscription.cs +++ b/src/SchematicHQ.Client/Types/BillingCustomerSubscription.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,9 +7,26 @@ namespace SchematicHQ.Client; public record BillingCustomerSubscription { + [JsonPropertyName("currency")] + public required string Currency { get; set; } + [JsonPropertyName("expired_at")] - public DateTime? ExpiredAt { get; init; } + public DateTime? ExpiredAt { get; set; } + + [JsonPropertyName("interval")] + public required string Interval { get; set; } + + [JsonPropertyName("metered_usage")] + public required bool MeteredUsage { get; set; } + + [JsonPropertyName("per_unit_price")] + public required int PerUnitPrice { get; set; } [JsonPropertyName("total_price")] - public required int TotalPrice { get; init; } + public required int TotalPrice { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingCustomerWithSubscriptionsResponseData.cs b/src/SchematicHQ.Client/Types/BillingCustomerWithSubscriptionsResponseData.cs index 4d962b8..fa7917b 100644 --- a/src/SchematicHQ.Client/Types/BillingCustomerWithSubscriptionsResponseData.cs +++ b/src/SchematicHQ.Client/Types/BillingCustomerWithSubscriptionsResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,30 +8,35 @@ namespace SchematicHQ.Client; public record BillingCustomerWithSubscriptionsResponseData { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("deleted_at")] - public DateTime? DeletedAt { get; init; } + public DateTime? DeletedAt { get; set; } [JsonPropertyName("email")] - public required string Email { get; init; } + public required string Email { get; set; } [JsonPropertyName("external_id")] - public required string ExternalId { get; init; } + public required string ExternalId { get; set; } [JsonPropertyName("failed_to_import")] - public required bool FailedToImport { get; init; } + public required bool FailedToImport { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("subscriptions")] - public IEnumerable Subscriptions { get; init; } = + public IEnumerable Subscriptions { get; set; } = new List(); [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingMeterResponseData.cs b/src/SchematicHQ.Client/Types/BillingMeterResponseData.cs new file mode 100644 index 0000000..2e0d211 --- /dev/null +++ b/src/SchematicHQ.Client/Types/BillingMeterResponseData.cs @@ -0,0 +1,29 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record BillingMeterResponseData +{ + [JsonPropertyName("dispaly_name")] + public required string DispalyName { get; set; } + + [JsonPropertyName("event_name")] + public required string EventName { get; set; } + + [JsonPropertyName("event_payload_key")] + public required string EventPayloadKey { get; set; } + + [JsonPropertyName("external_price_id")] + public required string ExternalPriceId { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/BillingPlan.cs b/src/SchematicHQ.Client/Types/BillingPlan.cs deleted file mode 100644 index e7b75d9..0000000 --- a/src/SchematicHQ.Client/Types/BillingPlan.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Text.Json.Serialization; - -#nullable enable - -namespace SchematicHQ.Client; - -public record BillingPlan -{ - [JsonPropertyName("description")] - public string? Description { get; init; } - - [JsonPropertyName("id")] - public required string Id { get; init; } - - [JsonPropertyName("image_url")] - public string? ImageUrl { get; init; } - - [JsonPropertyName("name")] - public required string Name { get; init; } - - [JsonPropertyName("plan_period")] - public string? PlanPeriod { get; init; } - - [JsonPropertyName("plan_price")] - public int? PlanPrice { get; init; } -} diff --git a/src/SchematicHQ.Client/Types/BillingPlanGroupResponseData.cs b/src/SchematicHQ.Client/Types/BillingPlanGroupResponseData.cs deleted file mode 100644 index f789b77..0000000 --- a/src/SchematicHQ.Client/Types/BillingPlanGroupResponseData.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Text.Json.Serialization; - -#nullable enable - -namespace SchematicHQ.Client; - -public record BillingPlanGroupResponseData -{ - [JsonPropertyName("default_plan_id")] - public string? DefaultPlanId { get; init; } - - [JsonPropertyName("id")] - public required string Id { get; init; } - - [JsonPropertyName("plan_ids")] - public IEnumerable PlanIds { get; init; } = new List(); -} diff --git a/src/SchematicHQ.Client/Types/BillingPriceResponseData.cs b/src/SchematicHQ.Client/Types/BillingPriceResponseData.cs index 92aa7a2..49866d9 100644 --- a/src/SchematicHQ.Client/Types/BillingPriceResponseData.cs +++ b/src/SchematicHQ.Client/Types/BillingPriceResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,15 +7,23 @@ namespace SchematicHQ.Client; public record BillingPriceResponseData { + [JsonPropertyName("currency")] + public required string Currency { get; set; } + [JsonPropertyName("external_price_id")] - public required string ExternalPriceId { get; init; } + public required string ExternalPriceId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("interval")] - public required string Interval { get; init; } + public required string Interval { get; set; } [JsonPropertyName("price")] - public required int Price { get; init; } + public required int Price { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingPriceView.cs b/src/SchematicHQ.Client/Types/BillingPriceView.cs new file mode 100644 index 0000000..39b864d --- /dev/null +++ b/src/SchematicHQ.Client/Types/BillingPriceView.cs @@ -0,0 +1,53 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record BillingPriceView +{ + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("currency")] + public required string Currency { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("interval")] + public required string Interval { get; set; } + + [JsonPropertyName("meter_id")] + public string? MeterId { get; set; } + + [JsonPropertyName("price")] + public required int Price { get; set; } + + [JsonPropertyName("price_external_id")] + public required string PriceExternalId { get; set; } + + [JsonPropertyName("price_id")] + public required string PriceId { get; set; } + + [JsonPropertyName("product_external_id")] + public required string ProductExternalId { get; set; } + + [JsonPropertyName("product_id")] + public required string ProductId { get; set; } + + [JsonPropertyName("product_name")] + public required string ProductName { get; set; } + + [JsonPropertyName("updated_at")] + public required DateTime UpdatedAt { get; set; } + + [JsonPropertyName("usage_type")] + public required string UsageType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/BillingProductDetailResponseData.cs b/src/SchematicHQ.Client/Types/BillingProductDetailResponseData.cs index b956d0e..cc162ed 100644 --- a/src/SchematicHQ.Client/Types/BillingProductDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/BillingProductDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -7,37 +7,42 @@ namespace SchematicHQ.Client; public record BillingProductDetailResponseData { - [JsonPropertyName("Prices")] - public IEnumerable Prices { get; init; } = - new List(); - [JsonPropertyName("account_id")] - public required string AccountId { get; init; } + public required string AccountId { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("currency")] - public required string Currency { get; init; } + public required string Currency { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("external_id")] - public required string ExternalId { get; init; } + public required string ExternalId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("price")] - public required double Price { get; init; } + public required double Price { get; set; } + + [JsonPropertyName("prices")] + public IEnumerable Prices { get; set; } = + new List(); [JsonPropertyName("product_id")] - public required string ProductId { get; init; } + public required string ProductId { get; set; } [JsonPropertyName("quantity")] - public required double Quantity { get; init; } + public required double Quantity { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingProductForSubscriptionResponseData.cs b/src/SchematicHQ.Client/Types/BillingProductForSubscriptionResponseData.cs index e5644a7..a952768 100644 --- a/src/SchematicHQ.Client/Types/BillingProductForSubscriptionResponseData.cs +++ b/src/SchematicHQ.Client/Types/BillingProductForSubscriptionResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,36 +7,53 @@ namespace SchematicHQ.Client; public record BillingProductForSubscriptionResponseData { - [JsonPropertyName("account_id")] - public required string AccountId { get; init; } - [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("currency")] - public required string Currency { get; init; } + public required string Currency { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("external_id")] - public required string ExternalId { get; init; } + public required string ExternalId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("interval")] - public string? Interval { get; init; } + public required string Interval { get; set; } + + [JsonPropertyName("meter_id")] + public string? MeterId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("price")] - public required double Price { get; init; } + public required int Price { get; set; } + + [JsonPropertyName("price_external_id")] + public required string PriceExternalId { get; set; } + + [JsonPropertyName("price_id")] + public required string PriceId { get; set; } [JsonPropertyName("quantity")] - public required double Quantity { get; init; } + public required double Quantity { get; set; } + + [JsonPropertyName("subscription_id")] + public required string SubscriptionId { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + [JsonPropertyName("usage_type")] + public required string UsageType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingProductPlanResponseData.cs b/src/SchematicHQ.Client/Types/BillingProductPlanResponseData.cs index ec48ffa..d3aacb9 100644 --- a/src/SchematicHQ.Client/Types/BillingProductPlanResponseData.cs +++ b/src/SchematicHQ.Client/Types/BillingProductPlanResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,31 @@ namespace SchematicHQ.Client; public record BillingProductPlanResponseData { [JsonPropertyName("account_id")] - public required string AccountId { get; init; } + public required string AccountId { get; set; } [JsonPropertyName("billing_product_id")] - public required string BillingProductId { get; init; } + public required string BillingProductId { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } + + [JsonPropertyName("is_trialable")] + public required bool IsTrialable { get; set; } [JsonPropertyName("monthly_price_id")] - public string? MonthlyPriceId { get; init; } + public string? MonthlyPriceId { get; set; } [JsonPropertyName("plan_id")] - public required string PlanId { get; init; } + public required string PlanId { get; set; } + + [JsonPropertyName("trial_days")] + public int? TrialDays { get; set; } [JsonPropertyName("yearly_price_id")] - public string? YearlyPriceId { get; init; } + public string? YearlyPriceId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingProductPriceResponseData.cs b/src/SchematicHQ.Client/Types/BillingProductPriceResponseData.cs new file mode 100644 index 0000000..54f3b39 --- /dev/null +++ b/src/SchematicHQ.Client/Types/BillingProductPriceResponseData.cs @@ -0,0 +1,44 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record BillingProductPriceResponseData +{ + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("currency")] + public required string Currency { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("interval")] + public required string Interval { get; set; } + + [JsonPropertyName("meter_id")] + public string? MeterId { get; set; } + + [JsonPropertyName("price")] + public required int Price { get; set; } + + [JsonPropertyName("price_external_id")] + public required string PriceExternalId { get; set; } + + [JsonPropertyName("product_external_id")] + public required string ProductExternalId { get; set; } + + [JsonPropertyName("updated_at")] + public required DateTime UpdatedAt { get; set; } + + [JsonPropertyName("usage_type")] + public required string UsageType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/BillingProductPricing.cs b/src/SchematicHQ.Client/Types/BillingProductPricing.cs index ec95e27..3e7d7b7 100644 --- a/src/SchematicHQ.Client/Types/BillingProductPricing.cs +++ b/src/SchematicHQ.Client/Types/BillingProductPricing.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,15 +7,32 @@ namespace SchematicHQ.Client; public record BillingProductPricing { + [JsonPropertyName("currency")] + public required string Currency { get; set; } + [JsonPropertyName("interval")] - public string? Interval { get; init; } + public required string Interval { get; set; } + + [JsonPropertyName("meter_id")] + public string? MeterId { get; set; } [JsonPropertyName("price")] - public required int Price { get; init; } + public required int Price { get; set; } [JsonPropertyName("price_external_id")] - public string? PriceExternalId { get; init; } + public required string PriceExternalId { get; set; } [JsonPropertyName("product_external_id")] - public required string ProductExternalId { get; init; } + public required string ProductExternalId { get; set; } + + [JsonPropertyName("quantity")] + public required int Quantity { get; set; } + + [JsonPropertyName("usage_type")] + public required string UsageType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingProductResponseData.cs b/src/SchematicHQ.Client/Types/BillingProductResponseData.cs index 17e934b..f0ee809 100644 --- a/src/SchematicHQ.Client/Types/BillingProductResponseData.cs +++ b/src/SchematicHQ.Client/Types/BillingProductResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,32 +8,37 @@ namespace SchematicHQ.Client; public record BillingProductResponseData { [JsonPropertyName("account_id")] - public required string AccountId { get; init; } + public required string AccountId { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("currency")] - public required string Currency { get; init; } + public required string Currency { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("external_id")] - public required string ExternalId { get; init; } + public required string ExternalId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("price")] - public required double Price { get; init; } + public required double Price { get; set; } [JsonPropertyName("product_id")] - public required string ProductId { get; init; } + public required string ProductId { get; set; } [JsonPropertyName("quantity")] - public required double Quantity { get; init; } + public required double Quantity { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingSubscriptionDiscount.cs b/src/SchematicHQ.Client/Types/BillingSubscriptionDiscount.cs new file mode 100644 index 0000000..2abfdb7 --- /dev/null +++ b/src/SchematicHQ.Client/Types/BillingSubscriptionDiscount.cs @@ -0,0 +1,35 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record BillingSubscriptionDiscount +{ + [JsonPropertyName("coupon_external_id")] + public required string CouponExternalId { get; set; } + + [JsonPropertyName("customer_facing_code")] + public string? CustomerFacingCode { get; set; } + + [JsonPropertyName("ended_at")] + public DateTime? EndedAt { get; set; } + + [JsonPropertyName("external_id")] + public required string ExternalId { get; set; } + + [JsonPropertyName("is_active")] + public required bool IsActive { get; set; } + + [JsonPropertyName("promo_code_external_id")] + public string? PromoCodeExternalId { get; set; } + + [JsonPropertyName("started_at")] + public required DateTime StartedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/BillingSubscriptionDiscountView.cs b/src/SchematicHQ.Client/Types/BillingSubscriptionDiscountView.cs new file mode 100644 index 0000000..7779629 --- /dev/null +++ b/src/SchematicHQ.Client/Types/BillingSubscriptionDiscountView.cs @@ -0,0 +1,56 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record BillingSubscriptionDiscountView +{ + [JsonPropertyName("amount_off")] + public int? AmountOff { get; set; } + + [JsonPropertyName("coupon_id")] + public required string CouponId { get; set; } + + [JsonPropertyName("coupon_name")] + public required string CouponName { get; set; } + + [JsonPropertyName("currency")] + public string? Currency { get; set; } + + [JsonPropertyName("customer_facing_code")] + public string? CustomerFacingCode { get; set; } + + [JsonPropertyName("discount_external_id")] + public required string DiscountExternalId { get; set; } + + [JsonPropertyName("duration")] + public required string Duration { get; set; } + + [JsonPropertyName("duration_in_months")] + public int? DurationInMonths { get; set; } + + [JsonPropertyName("ended_at")] + public DateTime? EndedAt { get; set; } + + [JsonPropertyName("is_active")] + public required bool IsActive { get; set; } + + [JsonPropertyName("percent_off")] + public double? PercentOff { get; set; } + + [JsonPropertyName("promo_code_external_id")] + public string? PromoCodeExternalId { get; set; } + + [JsonPropertyName("started_at")] + public required DateTime StartedAt { get; set; } + + [JsonPropertyName("subscription_external_id")] + public required string SubscriptionExternalId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/BillingSubscriptionResponseData.cs b/src/SchematicHQ.Client/Types/BillingSubscriptionResponseData.cs index 75530b0..c253359 100644 --- a/src/SchematicHQ.Client/Types/BillingSubscriptionResponseData.cs +++ b/src/SchematicHQ.Client/Types/BillingSubscriptionResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -6,15 +7,53 @@ namespace SchematicHQ.Client; public record BillingSubscriptionResponseData { - [JsonPropertyName("expired_at")] - public DateTime? ExpiredAt { get; init; } + [JsonPropertyName("company_id")] + public string? CompanyId { get; set; } + + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } - [JsonPropertyName("external_id")] - public required string ExternalId { get; init; } + [JsonPropertyName("currency")] + public required string Currency { get; set; } + + [JsonPropertyName("customer_external_id")] + public required string CustomerExternalId { get; set; } + + [JsonPropertyName("expired_at")] + public DateTime? ExpiredAt { get; set; } [JsonPropertyName("id")] - public required int Id { get; init; } + public required string Id { get; set; } + + [JsonPropertyName("interval")] + public required string Interval { get; set; } + + [JsonPropertyName("metadata")] + public Dictionary? Metadata { get; set; } + + [JsonPropertyName("period_end")] + public required int PeriodEnd { get; set; } + + [JsonPropertyName("period_start")] + public required int PeriodStart { get; set; } + + [JsonPropertyName("status")] + public required string Status { get; set; } + + [JsonPropertyName("subscription_external_id")] + public required string SubscriptionExternalId { get; set; } + + [JsonPropertyName("total_price")] + public required int TotalPrice { get; set; } + + [JsonPropertyName("trial_end")] + public int? TrialEnd { get; set; } + + [JsonPropertyName("trial_end_setting")] + public string? TrialEndSetting { get; set; } - [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/BillingSubscriptionView.cs b/src/SchematicHQ.Client/Types/BillingSubscriptionView.cs new file mode 100644 index 0000000..0944893 --- /dev/null +++ b/src/SchematicHQ.Client/Types/BillingSubscriptionView.cs @@ -0,0 +1,73 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record BillingSubscriptionView +{ + [JsonPropertyName("company_id")] + public string? CompanyId { get; set; } + + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("currency")] + public required string Currency { get; set; } + + [JsonPropertyName("customer_external_id")] + public required string CustomerExternalId { get; set; } + + [JsonPropertyName("discounts")] + public IEnumerable Discounts { get; set; } = + new List(); + + [JsonPropertyName("expired_at")] + public DateTime? ExpiredAt { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("interval")] + public required string Interval { get; set; } + + [JsonPropertyName("latest_invoice")] + public InvoiceResponseData? LatestInvoice { get; set; } + + [JsonPropertyName("metadata")] + public Dictionary? Metadata { get; set; } + + [JsonPropertyName("payment_method")] + public PaymentMethodResponseData? PaymentMethod { get; set; } + + [JsonPropertyName("period_end")] + public required int PeriodEnd { get; set; } + + [JsonPropertyName("period_start")] + public required int PeriodStart { get; set; } + + [JsonPropertyName("products")] + public IEnumerable Products { get; set; } = + new List(); + + [JsonPropertyName("status")] + public required string Status { get; set; } + + [JsonPropertyName("subscription_external_id")] + public required string SubscriptionExternalId { get; set; } + + [JsonPropertyName("total_price")] + public required int TotalPrice { get; set; } + + [JsonPropertyName("trial_end")] + public int? TrialEnd { get; set; } + + [JsonPropertyName("trial_end_setting")] + public string? TrialEndSetting { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/ChangeSubscriptionInternalRequestBody.cs b/src/SchematicHQ.Client/Types/ChangeSubscriptionInternalRequestBody.cs new file mode 100644 index 0000000..204b42f --- /dev/null +++ b/src/SchematicHQ.Client/Types/ChangeSubscriptionInternalRequestBody.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ChangeSubscriptionInternalRequestBody +{ + [JsonPropertyName("add_on_ids")] + public IEnumerable AddOnIds { get; set; } = + new List(); + + [JsonPropertyName("company_id")] + public required string CompanyId { get; set; } + + [JsonPropertyName("new_plan_id")] + public required string NewPlanId { get; set; } + + [JsonPropertyName("new_price_id")] + public required string NewPriceId { get; set; } + + [JsonPropertyName("pay_in_advance")] + public IEnumerable PayInAdvance { get; set; } = + new List(); + + [JsonPropertyName("payment_method_id")] + public string? PaymentMethodId { get; set; } + + [JsonPropertyName("promo_code")] + public string? PromoCode { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/ChangeSubscriptionRequestBody.cs b/src/SchematicHQ.Client/Types/ChangeSubscriptionRequestBody.cs new file mode 100644 index 0000000..c0e0040 --- /dev/null +++ b/src/SchematicHQ.Client/Types/ChangeSubscriptionRequestBody.cs @@ -0,0 +1,34 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ChangeSubscriptionRequestBody +{ + [JsonPropertyName("add_on_ids")] + public IEnumerable AddOnIds { get; set; } = + new List(); + + [JsonPropertyName("new_plan_id")] + public required string NewPlanId { get; set; } + + [JsonPropertyName("new_price_id")] + public required string NewPriceId { get; set; } + + [JsonPropertyName("pay_in_advance")] + public IEnumerable PayInAdvance { get; set; } = + new List(); + + [JsonPropertyName("payment_method_id")] + public string? PaymentMethodId { get; set; } + + [JsonPropertyName("promo_code")] + public string? PromoCode { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/CheckFlagOutputWithFlagKey.cs b/src/SchematicHQ.Client/Types/CheckFlagOutputWithFlagKey.cs index 6f07fba..a4d86d6 100644 --- a/src/SchematicHQ.Client/Types/CheckFlagOutputWithFlagKey.cs +++ b/src/SchematicHQ.Client/Types/CheckFlagOutputWithFlagKey.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,31 @@ namespace SchematicHQ.Client; public record CheckFlagOutputWithFlagKey { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("error")] - public string? Error { get; init; } + public string? Error { get; set; } [JsonPropertyName("flag")] - public required string Flag { get; init; } + public required string Flag { get; set; } + + [JsonPropertyName("flag_id")] + public string? FlagId { get; set; } [JsonPropertyName("reason")] - public required string Reason { get; init; } + public required string Reason { get; set; } [JsonPropertyName("rule_id")] - public string? RuleId { get; init; } + public string? RuleId { get; set; } [JsonPropertyName("user_id")] - public string? UserId { get; init; } + public string? UserId { get; set; } [JsonPropertyName("value")] - public required bool Value { get; init; } + public required bool Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CheckFlagRequestBody.cs b/src/SchematicHQ.Client/Types/CheckFlagRequestBody.cs index c5d3837..b89eea9 100644 --- a/src/SchematicHQ.Client/Types/CheckFlagRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CheckFlagRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,8 +8,13 @@ namespace SchematicHQ.Client; public record CheckFlagRequestBody { [JsonPropertyName("company")] - public Dictionary? Company { get; init; } + public Dictionary? Company { get; set; } [JsonPropertyName("user")] - public Dictionary? User { get; init; } + public Dictionary? User { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CheckFlagResponseData.cs b/src/SchematicHQ.Client/Types/CheckFlagResponseData.cs index 4c842d7..a1fe638 100644 --- a/src/SchematicHQ.Client/Types/CheckFlagResponseData.cs +++ b/src/SchematicHQ.Client/Types/CheckFlagResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,28 @@ namespace SchematicHQ.Client; public record CheckFlagResponseData { [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("error")] - public string? Error { get; init; } + public string? Error { get; set; } + + [JsonPropertyName("flag_id")] + public string? FlagId { get; set; } [JsonPropertyName("reason")] - public required string Reason { get; init; } + public required string Reason { get; set; } [JsonPropertyName("rule_id")] - public string? RuleId { get; init; } + public string? RuleId { get; set; } [JsonPropertyName("user_id")] - public string? UserId { get; init; } + public string? UserId { get; set; } [JsonPropertyName("value")] - public required bool Value { get; init; } + public required bool Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CheckFlagsResponseData.cs b/src/SchematicHQ.Client/Types/CheckFlagsResponseData.cs index ce378c2..3c6e034 100644 --- a/src/SchematicHQ.Client/Types/CheckFlagsResponseData.cs +++ b/src/SchematicHQ.Client/Types/CheckFlagsResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,6 +8,11 @@ namespace SchematicHQ.Client; public record CheckFlagsResponseData { [JsonPropertyName("flags")] - public IEnumerable Flags { get; init; } = + public IEnumerable Flags { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CompanyCrmDealsResponseData.cs b/src/SchematicHQ.Client/Types/CompanyCrmDealsResponseData.cs index 14ebd22..3a4b121 100644 --- a/src/SchematicHQ.Client/Types/CompanyCrmDealsResponseData.cs +++ b/src/SchematicHQ.Client/Types/CompanyCrmDealsResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,17 +8,22 @@ namespace SchematicHQ.Client; public record CompanyCrmDealsResponseData { [JsonPropertyName("deal_arr")] - public required string DealArr { get; init; } + public required string DealArr { get; set; } [JsonPropertyName("deal_external_id")] - public required string DealExternalId { get; init; } + public required string DealExternalId { get; set; } [JsonPropertyName("deal_mrr")] - public required string DealMrr { get; init; } + public required string DealMrr { get; set; } [JsonPropertyName("deal_name")] - public string? DealName { get; init; } + public string? DealName { get; set; } [JsonPropertyName("line_items")] - public IEnumerable LineItems { get; init; } = new List(); + public IEnumerable LineItems { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CompanyDetailResponseData.cs b/src/SchematicHQ.Client/Types/CompanyDetailResponseData.cs index 9d1acb3..232d69c 100644 --- a/src/SchematicHQ.Client/Types/CompanyDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/CompanyDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,49 +8,66 @@ namespace SchematicHQ.Client; public record CompanyDetailResponseData { [JsonPropertyName("add_ons")] - public IEnumerable AddOns { get; init; } = new List(); + public IEnumerable AddOns { get; set; } = + new List(); + + [JsonPropertyName("billing_subscription")] + public BillingSubscriptionView? BillingSubscription { get; set; } + + [JsonPropertyName("billing_subscriptions")] + public IEnumerable BillingSubscriptions { get; set; } = + new List(); [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("entity_traits")] - public IEnumerable EntityTraits { get; init; } = + public IEnumerable EntityTraits { get; set; } = new List(); [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("keys")] - public IEnumerable Keys { get; init; } = + public IEnumerable Keys { get; set; } = new List(); [JsonPropertyName("last_seen_at")] - public DateTime? LastSeenAt { get; init; } + public DateTime? LastSeenAt { get; set; } [JsonPropertyName("logo_url")] - public string? LogoUrl { get; init; } + public string? LogoUrl { get; set; } + + [JsonPropertyName("metrics")] + public IEnumerable Metrics { get; set; } = + new List(); [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("plan")] - public BillingPlan? Plan { get; init; } + public CompanyPlanWithBillingSubView? Plan { get; set; } [JsonPropertyName("plans")] - public IEnumerable Plans { get; init; } = new List(); + public IEnumerable Plans { get; set; } = new List(); /// /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary? Traits { get; init; } + public Dictionary? Traits { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("user_count")] - public required int UserCount { get; init; } + public required int UserCount { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CompanyEventPeriodMetricsResponseData.cs b/src/SchematicHQ.Client/Types/CompanyEventPeriodMetricsResponseData.cs new file mode 100644 index 0000000..702a074 --- /dev/null +++ b/src/SchematicHQ.Client/Types/CompanyEventPeriodMetricsResponseData.cs @@ -0,0 +1,47 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CompanyEventPeriodMetricsResponseData +{ + [JsonPropertyName("account_id")] + public required string AccountId { get; set; } + + [JsonPropertyName("captured_at_max")] + public required DateTime CapturedAtMax { get; set; } + + [JsonPropertyName("captured_at_min")] + public required DateTime CapturedAtMin { get; set; } + + [JsonPropertyName("company_id")] + public required string CompanyId { get; set; } + + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("environment_id")] + public required string EnvironmentId { get; set; } + + [JsonPropertyName("event_subtype")] + public required string EventSubtype { get; set; } + + [JsonPropertyName("month_reset")] + public required string MonthReset { get; set; } + + [JsonPropertyName("period")] + public required string Period { get; set; } + + [JsonPropertyName("valid_until")] + public DateTime? ValidUntil { get; set; } + + [JsonPropertyName("value")] + public required int Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/CompanyMembershipDetailResponseData.cs b/src/SchematicHQ.Client/Types/CompanyMembershipDetailResponseData.cs index 8685f51..63c8c9c 100644 --- a/src/SchematicHQ.Client/Types/CompanyMembershipDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/CompanyMembershipDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,20 +8,25 @@ namespace SchematicHQ.Client; public record CompanyMembershipDetailResponseData { [JsonPropertyName("company")] - public CompanyResponseData? Company { get; init; } + public CompanyResponseData? Company { get; set; } [JsonPropertyName("company_id")] - public required string CompanyId { get; init; } + public required string CompanyId { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("user_id")] - public required string UserId { get; init; } + public required string UserId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CompanyMembershipResponseData.cs b/src/SchematicHQ.Client/Types/CompanyMembershipResponseData.cs index 2c21dca..82cdab5 100644 --- a/src/SchematicHQ.Client/Types/CompanyMembershipResponseData.cs +++ b/src/SchematicHQ.Client/Types/CompanyMembershipResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,17 +8,22 @@ namespace SchematicHQ.Client; public record CompanyMembershipResponseData { [JsonPropertyName("company_id")] - public required string CompanyId { get; init; } + public required string CompanyId { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("user_id")] - public required string UserId { get; init; } + public required string UserId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CompanyOverrideResponseData.cs b/src/SchematicHQ.Client/Types/CompanyOverrideResponseData.cs index 2e2897d..fe191af 100644 --- a/src/SchematicHQ.Client/Types/CompanyOverrideResponseData.cs +++ b/src/SchematicHQ.Client/Types/CompanyOverrideResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,47 +8,58 @@ namespace SchematicHQ.Client; public record CompanyOverrideResponseData { [JsonPropertyName("company")] - public CompanyDetailResponseData? Company { get; init; } + public CompanyDetailResponseData? Company { get; set; } [JsonPropertyName("company_id")] - public required string CompanyId { get; init; } + public required string CompanyId { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } + + [JsonPropertyName("expiration_date")] + public DateTime? ExpirationDate { get; set; } [JsonPropertyName("feature")] - public FeatureResponseData? Feature { get; init; } + public FeatureResponseData? Feature { get; set; } [JsonPropertyName("feature_id")] - public required string FeatureId { get; init; } + public required string FeatureId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("metric_period")] - public string? MetricPeriod { get; init; } + public string? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public string? MetricPeriodMonthReset { get; set; } [JsonPropertyName("rule_id")] - public required string RuleId { get; init; } + public string? RuleId { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("value_bool")] - public bool? ValueBool { get; init; } + public bool? ValueBool { get; set; } [JsonPropertyName("value_numeric")] - public int? ValueNumeric { get; init; } + public int? ValueNumeric { get; set; } [JsonPropertyName("value_trait")] - public EntityTraitDefinitionResponseData? ValueTrait { get; init; } + public EntityTraitDefinitionResponseData? ValueTrait { get; set; } [JsonPropertyName("value_trait_id")] - public string? ValueTraitId { get; init; } + public string? ValueTraitId { get; set; } [JsonPropertyName("value_type")] - public required string ValueType { get; init; } + public required string ValueType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CompanyPlanDetailResponseData.cs b/src/SchematicHQ.Client/Types/CompanyPlanDetailResponseData.cs new file mode 100644 index 0000000..2899c0e --- /dev/null +++ b/src/SchematicHQ.Client/Types/CompanyPlanDetailResponseData.cs @@ -0,0 +1,79 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CompanyPlanDetailResponseData +{ + [JsonPropertyName("audience_type")] + public string? AudienceType { get; set; } + + [JsonPropertyName("billing_product")] + public BillingProductDetailResponseData? BillingProduct { get; set; } + + [JsonPropertyName("company_can_trial")] + public required bool CompanyCanTrial { get; set; } + + [JsonPropertyName("company_count")] + public required int CompanyCount { get; set; } + + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("current")] + public required bool Current { get; set; } + + [JsonPropertyName("description")] + public required string Description { get; set; } + + [JsonPropertyName("entitlements")] + public IEnumerable Entitlements { get; set; } = + new List(); + + [JsonPropertyName("features")] + public IEnumerable Features { get; set; } = + new List(); + + [JsonPropertyName("icon")] + public required string Icon { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("is_default")] + public required bool IsDefault { get; set; } + + [JsonPropertyName("is_free")] + public required bool IsFree { get; set; } + + [JsonPropertyName("is_trialable")] + public required bool IsTrialable { get; set; } + + [JsonPropertyName("monthly_price")] + public BillingPriceResponseData? MonthlyPrice { get; set; } + + [JsonPropertyName("name")] + public required string Name { get; set; } + + [JsonPropertyName("plan_type")] + public required string PlanType { get; set; } + + [JsonPropertyName("trial_days")] + public int? TrialDays { get; set; } + + [JsonPropertyName("updated_at")] + public required DateTime UpdatedAt { get; set; } + + [JsonPropertyName("valid")] + public required bool Valid { get; set; } + + [JsonPropertyName("yearly_price")] + public BillingPriceResponseData? YearlyPrice { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/CompanyPlanWithBillingSubView.cs b/src/SchematicHQ.Client/Types/CompanyPlanWithBillingSubView.cs new file mode 100644 index 0000000..9fdbf13 --- /dev/null +++ b/src/SchematicHQ.Client/Types/CompanyPlanWithBillingSubView.cs @@ -0,0 +1,35 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CompanyPlanWithBillingSubView +{ + [JsonPropertyName("billing_product_id")] + public string? BillingProductId { get; set; } + + [JsonPropertyName("description")] + public string? Description { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("image_url")] + public string? ImageUrl { get; set; } + + [JsonPropertyName("name")] + public required string Name { get; set; } + + [JsonPropertyName("plan_period")] + public string? PlanPeriod { get; set; } + + [JsonPropertyName("plan_price")] + public int? PlanPrice { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/CompanyResponseData.cs b/src/SchematicHQ.Client/Types/CompanyResponseData.cs index 38f70b0..8c6b41d 100644 --- a/src/SchematicHQ.Client/Types/CompanyResponseData.cs +++ b/src/SchematicHQ.Client/Types/CompanyResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record CompanyResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("last_seen_at")] - public DateTime? LastSeenAt { get; init; } + public DateTime? LastSeenAt { get; set; } [JsonPropertyName("logo_url")] - public string? LogoUrl { get; init; } + public string? LogoUrl { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CompanySubscriptionResponseData.cs b/src/SchematicHQ.Client/Types/CompanySubscriptionResponseData.cs index 295b985..64cbede 100644 --- a/src/SchematicHQ.Client/Types/CompanySubscriptionResponseData.cs +++ b/src/SchematicHQ.Client/Types/CompanySubscriptionResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -7,19 +7,46 @@ namespace SchematicHQ.Client; public record CompanySubscriptionResponseData { + [JsonPropertyName("currency")] + public required string Currency { get; set; } + [JsonPropertyName("customer_external_id")] - public required string CustomerExternalId { get; init; } + public required string CustomerExternalId { get; set; } + + [JsonPropertyName("discounts")] + public IEnumerable Discounts { get; set; } = + new List(); [JsonPropertyName("expired_at")] - public DateTime? ExpiredAt { get; init; } + public DateTime? ExpiredAt { get; set; } [JsonPropertyName("interval")] - public required string Interval { get; init; } + public required string Interval { get; set; } + + [JsonPropertyName("latest_invoice")] + public InvoiceResponseData? LatestInvoice { get; set; } + + [JsonPropertyName("payment_method")] + public PaymentMethodResponseData? PaymentMethod { get; set; } [JsonPropertyName("products")] - public IEnumerable Products { get; init; } = + public IEnumerable Products { get; set; } = new List(); + [JsonPropertyName("status")] + public required string Status { get; set; } + [JsonPropertyName("subscription_external_id")] - public required string SubscriptionExternalId { get; init; } + public required string SubscriptionExternalId { get; set; } + + [JsonPropertyName("total_price")] + public required int TotalPrice { get; set; } + + [JsonPropertyName("trial_end")] + public DateTime? TrialEnd { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/ComponentCapabilities.cs b/src/SchematicHQ.Client/Types/ComponentCapabilities.cs new file mode 100644 index 0000000..9e7f43f --- /dev/null +++ b/src/SchematicHQ.Client/Types/ComponentCapabilities.cs @@ -0,0 +1,17 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ComponentCapabilities +{ + [JsonPropertyName("checkout")] + public required bool Checkout { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/ComponentHydrateResponseData.cs b/src/SchematicHQ.Client/Types/ComponentHydrateResponseData.cs new file mode 100644 index 0000000..620d07a --- /dev/null +++ b/src/SchematicHQ.Client/Types/ComponentHydrateResponseData.cs @@ -0,0 +1,50 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ComponentHydrateResponseData +{ + [JsonPropertyName("active_add_ons")] + public IEnumerable ActiveAddOns { get; set; } = + new List(); + + [JsonPropertyName("active_plans")] + public IEnumerable ActivePlans { get; set; } = + new List(); + + [JsonPropertyName("active_usage_based_entitlements")] + public IEnumerable ActiveUsageBasedEntitlements { get; set; } = + new List(); + + [JsonPropertyName("capabilities")] + public ComponentCapabilities? Capabilities { get; set; } + + [JsonPropertyName("company")] + public CompanyDetailResponseData? Company { get; set; } + + [JsonPropertyName("component")] + public ComponentResponseData? Component { get; set; } + + [JsonPropertyName("feature_usage")] + public FeatureUsageDetailResponseData? FeatureUsage { get; set; } + + [JsonPropertyName("stripe_embed")] + public StripeEmbedInfo? StripeEmbed { get; set; } + + [JsonPropertyName("subscription")] + public CompanySubscriptionResponseData? Subscription { get; set; } + + [JsonPropertyName("trial_payment_method_required")] + public bool? TrialPaymentMethodRequired { get; set; } + + [JsonPropertyName("upcoming_invoice")] + public InvoiceResponseData? UpcomingInvoice { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/ComponentPreviewResponseData.cs b/src/SchematicHQ.Client/Types/ComponentPreviewResponseData.cs new file mode 100644 index 0000000..cd0001b --- /dev/null +++ b/src/SchematicHQ.Client/Types/ComponentPreviewResponseData.cs @@ -0,0 +1,54 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record ComponentPreviewResponseData +{ + [JsonPropertyName("active_add_ons")] + public IEnumerable ActiveAddOns { get; set; } = + new List(); + + [JsonPropertyName("active_plans")] + public IEnumerable ActivePlans { get; set; } = + new List(); + + [JsonPropertyName("active_usage_based_entitlements")] + public IEnumerable ActiveUsageBasedEntitlements { get; set; } = + new List(); + + [JsonPropertyName("capabilities")] + public ComponentCapabilities? Capabilities { get; set; } + + [JsonPropertyName("company")] + public CompanyDetailResponseData? Company { get; set; } + + [JsonPropertyName("component")] + public ComponentResponseData? Component { get; set; } + + [JsonPropertyName("feature_usage")] + public FeatureUsageDetailResponseData? FeatureUsage { get; set; } + + [JsonPropertyName("invoices")] + public IEnumerable Invoices { get; set; } = + new List(); + + [JsonPropertyName("stripe_embed")] + public StripeEmbedInfo? StripeEmbed { get; set; } + + [JsonPropertyName("subscription")] + public CompanySubscriptionResponseData? Subscription { get; set; } + + [JsonPropertyName("trial_payment_method_required")] + public bool? TrialPaymentMethodRequired { get; set; } + + [JsonPropertyName("upcoming_invoice")] + public InvoiceResponseData? UpcomingInvoice { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/ComponentResponseData.cs b/src/SchematicHQ.Client/Types/ComponentResponseData.cs index 94d43e1..2dc1cae 100644 --- a/src/SchematicHQ.Client/Types/ComponentResponseData.cs +++ b/src/SchematicHQ.Client/Types/ComponentResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record ComponentResponseData { [JsonPropertyName("ast")] - public Dictionary? Ast { get; init; } + public Dictionary? Ast { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("state")] - public required string State { get; init; } + public required string State { get; set; } [JsonPropertyName("type")] - public required string Type { get; init; } + public required string Type { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CountResponse.cs b/src/SchematicHQ.Client/Types/CountResponse.cs index ba7666b..9723a8e 100644 --- a/src/SchematicHQ.Client/Types/CountResponse.cs +++ b/src/SchematicHQ.Client/Types/CountResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,5 +8,10 @@ namespace SchematicHQ.Client; public record CountResponse { [JsonPropertyName("count")] - public required int Count { get; init; } + public required int Count { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CouponRequestBody.cs b/src/SchematicHQ.Client/Types/CouponRequestBody.cs new file mode 100644 index 0000000..99c9c0e --- /dev/null +++ b/src/SchematicHQ.Client/Types/CouponRequestBody.cs @@ -0,0 +1,38 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CouponRequestBody +{ + [JsonPropertyName("amount_off")] + public required int AmountOff { get; set; } + + [JsonPropertyName("currency")] + public string? Currency { get; set; } + + [JsonPropertyName("duration")] + public required string Duration { get; set; } + + [JsonPropertyName("duration_in_months")] + public required int DurationInMonths { get; set; } + + [JsonPropertyName("max_redemptions")] + public required int MaxRedemptions { get; set; } + + [JsonPropertyName("name")] + public required string Name { get; set; } + + [JsonPropertyName("percent_off")] + public required double PercentOff { get; set; } + + [JsonPropertyName("times_redeemed")] + public required int TimesRedeemed { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/CreateEntitlementReqCommon.cs b/src/SchematicHQ.Client/Types/CreateEntitlementReqCommon.cs new file mode 100644 index 0000000..832288b --- /dev/null +++ b/src/SchematicHQ.Client/Types/CreateEntitlementReqCommon.cs @@ -0,0 +1,35 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record CreateEntitlementReqCommon +{ + [JsonPropertyName("feature_id")] + public required string FeatureId { get; set; } + + [JsonPropertyName("metric_period")] + public CreateEntitlementReqCommonMetricPeriod? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public CreateEntitlementReqCommonMetricPeriodMonthReset? MetricPeriodMonthReset { get; set; } + + [JsonPropertyName("value_bool")] + public bool? ValueBool { get; set; } + + [JsonPropertyName("value_numeric")] + public int? ValueNumeric { get; set; } + + [JsonPropertyName("value_trait_id")] + public string? ValueTraitId { get; set; } + + [JsonPropertyName("value_type")] + public required CreateEntitlementReqCommonValueType ValueType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/UpdateReqCommonMetricPeriod.cs b/src/SchematicHQ.Client/Types/CreateEntitlementReqCommonMetricPeriod.cs similarity index 61% rename from src/SchematicHQ.Client/Types/UpdateReqCommonMetricPeriod.cs rename to src/SchematicHQ.Client/Types/CreateEntitlementReqCommonMetricPeriod.cs index 6e791aa..9cca193 100644 --- a/src/SchematicHQ.Client/Types/UpdateReqCommonMetricPeriod.cs +++ b/src/SchematicHQ.Client/Types/CreateEntitlementReqCommonMetricPeriod.cs @@ -1,15 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] -public enum UpdateReqCommonMetricPeriod +[JsonConverter(typeof(EnumSerializer))] +public enum CreateEntitlementReqCommonMetricPeriod { + [EnumMember(Value = "all_time")] + AllTime, + [EnumMember(Value = "current_month")] CurrentMonth, @@ -17,5 +19,5 @@ public enum UpdateReqCommonMetricPeriod CurrentWeek, [EnumMember(Value = "current_day")] - CurrentDay + CurrentDay, } diff --git a/src/SchematicHQ.Client/Types/CreateEntitlementReqCommonMetricPeriodMonthReset.cs b/src/SchematicHQ.Client/Types/CreateEntitlementReqCommonMetricPeriodMonthReset.cs new file mode 100644 index 0000000..fa7b18f --- /dev/null +++ b/src/SchematicHQ.Client/Types/CreateEntitlementReqCommonMetricPeriodMonthReset.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(EnumSerializer))] +public enum CreateEntitlementReqCommonMetricPeriodMonthReset +{ + [EnumMember(Value = "first_of_month")] + FirstOfMonth, + + [EnumMember(Value = "billing_cycle")] + BillingCycle, +} diff --git a/src/SchematicHQ.Client/Types/UpdateReqCommonValueType.cs b/src/SchematicHQ.Client/Types/CreateEntitlementReqCommonValueType.cs similarity index 69% rename from src/SchematicHQ.Client/Types/UpdateReqCommonValueType.cs rename to src/SchematicHQ.Client/Types/CreateEntitlementReqCommonValueType.cs index 2793331..e4d1eee 100644 --- a/src/SchematicHQ.Client/Types/UpdateReqCommonValueType.cs +++ b/src/SchematicHQ.Client/Types/CreateEntitlementReqCommonValueType.cs @@ -1,14 +1,13 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] -public enum UpdateReqCommonValueType +[JsonConverter(typeof(EnumSerializer))] +public enum CreateEntitlementReqCommonValueType { [EnumMember(Value = "boolean")] Boolean, @@ -20,5 +19,5 @@ public enum UpdateReqCommonValueType Trait, [EnumMember(Value = "unlimited")] - Unlimited + Unlimited, } diff --git a/src/SchematicHQ.Client/Types/CreateEventRequestBody.cs b/src/SchematicHQ.Client/Types/CreateEventRequestBody.cs index d1772e7..acd9459 100644 --- a/src/SchematicHQ.Client/Types/CreateEventRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateEventRequestBody.cs @@ -1,6 +1,5 @@ using System.Text.Json.Serialization; using OneOf; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable @@ -10,20 +9,22 @@ namespace SchematicHQ.Client; public record CreateEventRequestBody { [JsonPropertyName("body")] - [JsonConverter( - typeof(OneOfSerializer>) - )] - public OneOf? Body { get; init; } + public OneOf? Body { get; set; } /// /// Either 'identify' or 'track' /// [JsonPropertyName("event_type")] - public required CreateEventRequestBodyEventType EventType { get; init; } + public required CreateEventRequestBodyEventType EventType { get; set; } /// /// Optionally provide a timestamp at which the event was sent to Schematic /// [JsonPropertyName("sent_at")] - public DateTime? SentAt { get; init; } + public DateTime? SentAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CreateEventRequestBodyEventType.cs b/src/SchematicHQ.Client/Types/CreateEventRequestBodyEventType.cs index 49d8888..4cb967a 100644 --- a/src/SchematicHQ.Client/Types/CreateEventRequestBodyEventType.cs +++ b/src/SchematicHQ.Client/Types/CreateEventRequestBodyEventType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateEventRequestBodyEventType { [EnumMember(Value = "identify")] @@ -17,5 +16,5 @@ public enum CreateEventRequestBodyEventType Track, [EnumMember(Value = "flag_check")] - FlagCheck + FlagCheck, } diff --git a/src/SchematicHQ.Client/Types/CreateFlagRequestBody.cs b/src/SchematicHQ.Client/Types/CreateFlagRequestBody.cs index b371326..a0b43ef 100644 --- a/src/SchematicHQ.Client/Types/CreateFlagRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateFlagRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record CreateFlagRequestBody { [JsonPropertyName("default_value")] - public required bool DefaultValue { get; init; } + public required bool DefaultValue { get; set; } [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } [JsonPropertyName("flag_type")] - public required string FlagType { get; init; } + public required string FlagType { get; set; } [JsonPropertyName("key")] - public required string Key { get; init; } + public required string Key { get; set; } [JsonPropertyName("maintainer_id")] - public string? MaintainerId { get; init; } + public string? MaintainerId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionGroupRequestBody.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionGroupRequestBody.cs index 4997294..d19a047 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionGroupRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionGroupRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,15 +8,20 @@ namespace SchematicHQ.Client; public record CreateOrUpdateConditionGroupRequestBody { [JsonPropertyName("conditions")] - public IEnumerable Conditions { get; init; } = + public IEnumerable Conditions { get; set; } = new List(); [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } [JsonPropertyName("id")] - public string? Id { get; init; } + public string? Id { get; set; } [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBody.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBody.cs index ce8cca7..a0ad68c 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,50 +11,61 @@ public record CreateOrUpdateConditionRequestBody /// Optionally provide a trait ID to compare a metric or trait value against instead of a value /// [JsonPropertyName("comparison_trait_id")] - public string? ComparisonTraitId { get; init; } + public string? ComparisonTraitId { get; set; } [JsonPropertyName("condition_type")] - public required CreateOrUpdateConditionRequestBodyConditionType ConditionType { get; init; } + public required CreateOrUpdateConditionRequestBodyConditionType ConditionType { get; set; } /// /// Name of track event type used to measure this condition /// [JsonPropertyName("event_subtype")] - public string? EventSubtype { get; init; } + public string? EventSubtype { get; set; } [JsonPropertyName("id")] - public string? Id { get; init; } + public string? Id { get; set; } /// /// Period of time over which to measure the track event metric /// [JsonPropertyName("metric_period")] - public CreateOrUpdateConditionRequestBodyMetricPeriod? MetricPeriod { get; init; } + public CreateOrUpdateConditionRequestBodyMetricPeriod? MetricPeriod { get; set; } + + /// + /// When metric_period=current_month, specify whether the month restarts based on the calendar month or the billing period + /// + [JsonPropertyName("metric_period_month_reset")] + public CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset? MetricPeriodMonthReset { get; set; } /// /// Value to compare the track event metric against /// [JsonPropertyName("metric_value")] - public int? MetricValue { get; init; } + public int? MetricValue { get; set; } [JsonPropertyName("operator")] - public required CreateOrUpdateConditionRequestBodyOperator Operator { get; init; } + public required CreateOrUpdateConditionRequestBodyOperator Operator { get; set; } /// /// List of resource IDs (companies, users, or plans) targeted by this condition /// [JsonPropertyName("resource_ids")] - public IEnumerable ResourceIds { get; init; } = new List(); + public IEnumerable ResourceIds { get; set; } = new List(); /// /// ID of trait to use to measure this condition /// [JsonPropertyName("trait_id")] - public string? TraitId { get; init; } + public string? TraitId { get; set; } /// /// Value to compare the trait value against /// [JsonPropertyName("trait_value")] - public string? TraitValue { get; init; } + public string? TraitValue { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyConditionType.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyConditionType.cs index 7d9c24f..6eda505 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyConditionType.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyConditionType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateOrUpdateConditionRequestBodyConditionType { [EnumMember(Value = "company")] @@ -29,5 +28,8 @@ public enum CreateOrUpdateConditionRequestBodyConditionType BillingProduct, [EnumMember(Value = "crm_product")] - CrmProduct + CrmProduct, + + [EnumMember(Value = "base_plan")] + BasePlan, } diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyMetricPeriod.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyMetricPeriod.cs index 0607f2d..2bc0e0e 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyMetricPeriod.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyMetricPeriod.cs @@ -1,15 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateOrUpdateConditionRequestBodyMetricPeriod { + [EnumMember(Value = "all_time")] + AllTime, + [EnumMember(Value = "current_month")] CurrentMonth, @@ -17,5 +19,5 @@ public enum CreateOrUpdateConditionRequestBodyMetricPeriod CurrentWeek, [EnumMember(Value = "current_day")] - CurrentDay + CurrentDay, } diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset.cs new file mode 100644 index 0000000..25faa4b --- /dev/null +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(EnumSerializer))] +public enum CreateOrUpdateConditionRequestBodyMetricPeriodMonthReset +{ + [EnumMember(Value = "first_of_month")] + FirstOfMonth, + + [EnumMember(Value = "billing_cycle")] + BillingCycle, +} diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyOperator.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyOperator.cs index 9c55558..fb079a2 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyOperator.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBodyOperator.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateOrUpdateConditionRequestBodyOperator { [EnumMember(Value = "eq")] @@ -26,5 +25,11 @@ public enum CreateOrUpdateConditionRequestBodyOperator Lt, [EnumMember(Value = "lte")] - Lte + Lte, + + [EnumMember(Value = "is_empty")] + IsEmpty, + + [EnumMember(Value = "not_empty")] + NotEmpty, } diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateFlagRequestBody.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateFlagRequestBody.cs index 328d03d..dd3ef0d 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateFlagRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateFlagRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,26 +8,31 @@ namespace SchematicHQ.Client; public record CreateOrUpdateFlagRequestBody { [JsonPropertyName("default_value")] - public required bool DefaultValue { get; init; } + public required bool DefaultValue { get; set; } [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } [JsonPropertyName("flag_type")] - public required string FlagType { get; init; } + public required string FlagType { get; set; } [JsonPropertyName("id")] - public string? Id { get; init; } + public string? Id { get; set; } [JsonPropertyName("key")] - public required string Key { get; init; } + public required string Key { get; set; } [JsonPropertyName("maintainer_id")] - public string? MaintainerId { get; init; } + public string? MaintainerId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBody.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBody.cs index 15a7f9f..27f204e 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,25 +8,30 @@ namespace SchematicHQ.Client; public record CreateOrUpdateRuleRequestBody { [JsonPropertyName("condition_groups")] - public IEnumerable ConditionGroups { get; init; } = + public IEnumerable ConditionGroups { get; set; } = new List(); [JsonPropertyName("conditions")] - public IEnumerable Conditions { get; init; } = + public IEnumerable Conditions { get; set; } = new List(); [JsonPropertyName("id")] - public string? Id { get; init; } + public string? Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("priority")] - public required int Priority { get; init; } + public required int Priority { get; set; } [JsonPropertyName("rule_type")] - public CreateOrUpdateRuleRequestBodyRuleType? RuleType { get; init; } + public CreateOrUpdateRuleRequestBodyRuleType? RuleType { get; set; } [JsonPropertyName("value")] - public required bool Value { get; init; } + public required bool Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBodyRuleType.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBodyRuleType.cs index 7959174..290e997 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBodyRuleType.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBodyRuleType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateOrUpdateRuleRequestBodyRuleType { [EnumMember(Value = "global_override")] @@ -26,5 +25,5 @@ public enum CreateOrUpdateRuleRequestBodyRuleType Default, [EnumMember(Value = "plan_audience")] - PlanAudience + PlanAudience, } diff --git a/src/SchematicHQ.Client/Types/CreateReqCommon.cs b/src/SchematicHQ.Client/Types/CreateReqCommon.cs deleted file mode 100644 index 3a256f0..0000000 --- a/src/SchematicHQ.Client/Types/CreateReqCommon.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Text.Json.Serialization; -using SchematicHQ.Client; - -#nullable enable - -namespace SchematicHQ.Client; - -public record CreateReqCommon -{ - [JsonPropertyName("feature_id")] - public required string FeatureId { get; init; } - - [JsonPropertyName("metric_period")] - public CreateReqCommonMetricPeriod? MetricPeriod { get; init; } - - [JsonPropertyName("value_bool")] - public bool? ValueBool { get; init; } - - [JsonPropertyName("value_numeric")] - public int? ValueNumeric { get; init; } - - [JsonPropertyName("value_trait_id")] - public string? ValueTraitId { get; init; } - - [JsonPropertyName("value_type")] - public required CreateReqCommonValueType ValueType { get; init; } -} diff --git a/src/SchematicHQ.Client/Types/CrmDealLineItem.cs b/src/SchematicHQ.Client/Types/CrmDealLineItem.cs index cf410d6..f371b59 100644 --- a/src/SchematicHQ.Client/Types/CrmDealLineItem.cs +++ b/src/SchematicHQ.Client/Types/CrmDealLineItem.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,38 +8,43 @@ namespace SchematicHQ.Client; public record CrmDealLineItem { [JsonPropertyName("billing_frequency")] - public required string BillingFrequency { get; init; } + public required string BillingFrequency { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("currency")] - public required string Currency { get; init; } + public required string Currency { get; set; } [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("discount_percentage")] - public Dictionary? DiscountPercentage { get; init; } + public Dictionary? DiscountPercentage { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("price")] - public required double Price { get; init; } + public required double Price { get; set; } [JsonPropertyName("quantity")] - public required int Quantity { get; init; } + public required int Quantity { get; set; } [JsonPropertyName("term_month")] - public int? TermMonth { get; init; } + public int? TermMonth { get; set; } [JsonPropertyName("total_discount")] - public Dictionary? TotalDiscount { get; init; } + public Dictionary? TotalDiscount { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CrmDealResponseData.cs b/src/SchematicHQ.Client/Types/CrmDealResponseData.cs index fa49687..bc6e534 100644 --- a/src/SchematicHQ.Client/Types/CrmDealResponseData.cs +++ b/src/SchematicHQ.Client/Types/CrmDealResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,35 +8,40 @@ namespace SchematicHQ.Client; public record CrmDealResponseData { [JsonPropertyName("account_id")] - public required string AccountId { get; init; } + public required string AccountId { get; set; } [JsonPropertyName("arr")] - public required string Arr { get; init; } + public required string Arr { get; set; } [JsonPropertyName("company_external_id")] - public string? CompanyExternalId { get; init; } + public string? CompanyExternalId { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("deal_external_id")] - public required string DealExternalId { get; init; } + public required string DealExternalId { get; set; } [JsonPropertyName("deal_id")] - public required string DealId { get; init; } + public required string DealId { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("mrr")] - public required string Mrr { get; init; } + public required string Mrr { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } [JsonPropertyName("product_external_id")] - public string? ProductExternalId { get; init; } + public string? ProductExternalId { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CrmLineItemResponseData.cs b/src/SchematicHQ.Client/Types/CrmLineItemResponseData.cs index f4e1fe3..6d8acdb 100644 --- a/src/SchematicHQ.Client/Types/CrmLineItemResponseData.cs +++ b/src/SchematicHQ.Client/Types/CrmLineItemResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record CrmLineItemResponseData { [JsonPropertyName("account_id")] - public required string AccountId { get; init; } + public required string AccountId { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("deal_id")] - public string? DealId { get; init; } + public string? DealId { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("product_external_id")] - public string? ProductExternalId { get; init; } + public string? ProductExternalId { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/CrmProductResponseData.cs b/src/SchematicHQ.Client/Types/CrmProductResponseData.cs index 9335a5c..71c68b3 100644 --- a/src/SchematicHQ.Client/Types/CrmProductResponseData.cs +++ b/src/SchematicHQ.Client/Types/CrmProductResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,32 +8,37 @@ namespace SchematicHQ.Client; public record CrmProductResponseData { [JsonPropertyName("account_id")] - public required string AccountId { get; init; } + public required string AccountId { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("currency")] - public required string Currency { get; init; } + public required string Currency { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("external_id")] - public required string ExternalId { get; init; } + public required string ExternalId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("price")] - public required string Price { get; init; } + public required string Price { get; set; } [JsonPropertyName("product_id")] - public required string ProductId { get; init; } + public required string ProductId { get; set; } [JsonPropertyName("quantity")] - public required double Quantity { get; init; } + public required double Quantity { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/DeleteResponse.cs b/src/SchematicHQ.Client/Types/DeleteResponse.cs index 629b909..fd6d9f8 100644 --- a/src/SchematicHQ.Client/Types/DeleteResponse.cs +++ b/src/SchematicHQ.Client/Types/DeleteResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,5 +11,10 @@ public record DeleteResponse /// Whether the delete was successful /// [JsonPropertyName("deleted")] - public bool? Deleted { get; init; } + public bool? Deleted { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EntityKeyDefinitionResponseData.cs b/src/SchematicHQ.Client/Types/EntityKeyDefinitionResponseData.cs index 1276eb0..f1d1822 100644 --- a/src/SchematicHQ.Client/Types/EntityKeyDefinitionResponseData.cs +++ b/src/SchematicHQ.Client/Types/EntityKeyDefinitionResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,17 +8,22 @@ namespace SchematicHQ.Client; public record EntityKeyDefinitionResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("entity_type")] - public required string EntityType { get; init; } + public required string EntityType { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("key")] - public required string Key { get; init; } + public required string Key { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EntityKeyDetailResponseData.cs b/src/SchematicHQ.Client/Types/EntityKeyDetailResponseData.cs index 0909e9d..17b35d0 100644 --- a/src/SchematicHQ.Client/Types/EntityKeyDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/EntityKeyDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,32 +8,37 @@ namespace SchematicHQ.Client; public record EntityKeyDetailResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("definition")] - public EntityKeyDefinitionResponseData? Definition { get; init; } + public EntityKeyDefinitionResponseData? Definition { get; set; } [JsonPropertyName("definition_id")] - public required string DefinitionId { get; init; } + public required string DefinitionId { get; set; } [JsonPropertyName("entity_id")] - public required string EntityId { get; init; } + public required string EntityId { get; set; } [JsonPropertyName("entity_type")] - public required string EntityType { get; init; } + public required string EntityType { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("key")] - public required string Key { get; init; } + public required string Key { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("value")] - public required string Value { get; init; } + public required string Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EntityKeyResponseData.cs b/src/SchematicHQ.Client/Types/EntityKeyResponseData.cs index bad89ed..a0663d6 100644 --- a/src/SchematicHQ.Client/Types/EntityKeyResponseData.cs +++ b/src/SchematicHQ.Client/Types/EntityKeyResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,29 +8,34 @@ namespace SchematicHQ.Client; public record EntityKeyResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("definition_id")] - public required string DefinitionId { get; init; } + public required string DefinitionId { get; set; } [JsonPropertyName("entity_id")] - public required string EntityId { get; init; } + public required string EntityId { get; set; } [JsonPropertyName("entity_type")] - public required string EntityType { get; init; } + public required string EntityType { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("key")] - public required string Key { get; init; } + public required string Key { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("value")] - public required string Value { get; init; } + public required string Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EntityTraitDefinitionResponseData.cs b/src/SchematicHQ.Client/Types/EntityTraitDefinitionResponseData.cs index 87aac93..deb1c41 100644 --- a/src/SchematicHQ.Client/Types/EntityTraitDefinitionResponseData.cs +++ b/src/SchematicHQ.Client/Types/EntityTraitDefinitionResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record EntityTraitDefinitionResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("display_name")] - public required string DisplayName { get; init; } + public required string DisplayName { get; set; } [JsonPropertyName("entity_type")] - public required string EntityType { get; init; } + public required string EntityType { get; set; } [JsonPropertyName("hierarchy")] - public IEnumerable Hierarchy { get; init; } = new List(); + public IEnumerable Hierarchy { get; set; } = new List(); [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("trait_type")] - public required string TraitType { get; init; } + public required string TraitType { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EntityTraitDetailResponseData.cs b/src/SchematicHQ.Client/Types/EntityTraitDetailResponseData.cs index a53cddd..c067cf2 100644 --- a/src/SchematicHQ.Client/Types/EntityTraitDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/EntityTraitDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,23 +8,28 @@ namespace SchematicHQ.Client; public record EntityTraitDetailResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("definition")] - public EntityTraitDefinitionResponseData? Definition { get; init; } + public EntityTraitDefinitionResponseData? Definition { get; set; } [JsonPropertyName("definition_id")] - public required string DefinitionId { get; init; } + public required string DefinitionId { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("value")] - public required string Value { get; init; } + public required string Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EntityTraitResponseData.cs b/src/SchematicHQ.Client/Types/EntityTraitResponseData.cs index 590bd91..275289f 100644 --- a/src/SchematicHQ.Client/Types/EntityTraitResponseData.cs +++ b/src/SchematicHQ.Client/Types/EntityTraitResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record EntityTraitResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("definition_id")] - public required string DefinitionId { get; init; } + public required string DefinitionId { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("value")] - public required string Value { get; init; } + public required string Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EntityTraitValue.cs b/src/SchematicHQ.Client/Types/EntityTraitValue.cs index a3472bb..c6526b1 100644 --- a/src/SchematicHQ.Client/Types/EntityTraitValue.cs +++ b/src/SchematicHQ.Client/Types/EntityTraitValue.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,8 +8,13 @@ namespace SchematicHQ.Client; public record EntityTraitValue { [JsonPropertyName("definition_id")] - public required string DefinitionId { get; init; } + public required string DefinitionId { get; set; } [JsonPropertyName("value")] - public required string Value { get; init; } + public required string Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EnvironmentDetailResponseData.cs b/src/SchematicHQ.Client/Types/EnvironmentDetailResponseData.cs index 8c4e1d6..d7ce50d 100644 --- a/src/SchematicHQ.Client/Types/EnvironmentDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/EnvironmentDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,20 +8,25 @@ namespace SchematicHQ.Client; public record EnvironmentDetailResponseData { [JsonPropertyName("api_keys")] - public IEnumerable ApiKeys { get; init; } = new List(); + public IEnumerable ApiKeys { get; set; } = new List(); [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_type")] - public required string EnvironmentType { get; init; } + public required string EnvironmentType { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EnvironmentResponseData.cs b/src/SchematicHQ.Client/Types/EnvironmentResponseData.cs index 57f2221..083dd4a 100644 --- a/src/SchematicHQ.Client/Types/EnvironmentResponseData.cs +++ b/src/SchematicHQ.Client/Types/EnvironmentResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,17 +8,22 @@ namespace SchematicHQ.Client; public record EnvironmentResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_type")] - public required string EnvironmentType { get; init; } + public required string EnvironmentType { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EventBodyFlagCheck.cs b/src/SchematicHQ.Client/Types/EventBodyFlagCheck.cs index 4e166f9..db5ada5 100644 --- a/src/SchematicHQ.Client/Types/EventBodyFlagCheck.cs +++ b/src/SchematicHQ.Client/Types/EventBodyFlagCheck.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,62 +8,67 @@ namespace SchematicHQ.Client; public record EventBodyFlagCheck { /// - /// Schematic company ID (starting with 'comp\_') of the company evaluated, if any + /// Schematic company ID (starting with 'comp_') of the company evaluated, if any /// [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } /// /// Report an error that occurred during the flag check /// [JsonPropertyName("error")] - public string? Error { get; init; } + public string? Error { get; set; } /// - /// Schematic flag ID (starting with 'flag\_') for the flag matching the key, if any + /// Schematic flag ID (starting with 'flag_') for the flag matching the key, if any /// [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } /// /// The key of the flag being checked /// [JsonPropertyName("flag_key")] - public required string FlagKey { get; init; } + public required string FlagKey { get; set; } /// /// The reason why the value was returned /// [JsonPropertyName("reason")] - public required string Reason { get; init; } + public required string Reason { get; set; } /// /// Key-value pairs used to to identify company for which the flag was checked /// [JsonPropertyName("req_company")] - public Dictionary? ReqCompany { get; init; } + public Dictionary? ReqCompany { get; set; } /// /// Key-value pairs used to to identify user for which the flag was checked /// [JsonPropertyName("req_user")] - public Dictionary? ReqUser { get; init; } + public Dictionary? ReqUser { get; set; } /// - /// Schematic rule ID (starting with 'rule\_') of the rule that matched for the flag, if any + /// Schematic rule ID (starting with 'rule_') of the rule that matched for the flag, if any /// [JsonPropertyName("rule_id")] - public string? RuleId { get; init; } + public string? RuleId { get; set; } /// - /// Schematic user ID (starting with 'user\_') of the user evaluated, if any + /// Schematic user ID (starting with 'user_') of the user evaluated, if any /// [JsonPropertyName("user_id")] - public string? UserId { get; init; } + public string? UserId { get; set; } /// /// The value of the flag for the given company and/or user /// [JsonPropertyName("value")] - public required bool Value { get; init; } + public required bool Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EventBodyIdentify.cs b/src/SchematicHQ.Client/Types/EventBodyIdentify.cs index f1dfec5..7481eb4 100644 --- a/src/SchematicHQ.Client/Types/EventBodyIdentify.cs +++ b/src/SchematicHQ.Client/Types/EventBodyIdentify.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,23 +11,28 @@ public record EventBodyIdentify /// Information about the company associated with the user; required only if it is a new user /// [JsonPropertyName("company")] - public EventBodyIdentifyCompany? Company { get; init; } + public EventBodyIdentifyCompany? Company { get; set; } /// /// Key-value pairs to identify the user /// [JsonPropertyName("keys")] - public Dictionary Keys { get; init; } = new Dictionary(); + public Dictionary Keys { get; set; } = new Dictionary(); /// /// The display name of the user being identified; required only if it is a new user /// [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } /// /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary? Traits { get; init; } + public Dictionary? Traits { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EventBodyIdentifyCompany.cs b/src/SchematicHQ.Client/Types/EventBodyIdentifyCompany.cs index 669591d..ba131ea 100644 --- a/src/SchematicHQ.Client/Types/EventBodyIdentifyCompany.cs +++ b/src/SchematicHQ.Client/Types/EventBodyIdentifyCompany.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,17 +11,22 @@ public record EventBodyIdentifyCompany /// Key-value pairs to identify the company /// [JsonPropertyName("keys")] - public Dictionary Keys { get; init; } = new Dictionary(); + public Dictionary Keys { get; set; } = new Dictionary(); /// /// The display name of the company; required only if it is a new company /// [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } /// /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary? Traits { get; init; } + public Dictionary? Traits { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EventBodyTrack.cs b/src/SchematicHQ.Client/Types/EventBodyTrack.cs index 5a1f333..fd9bf03 100644 --- a/src/SchematicHQ.Client/Types/EventBodyTrack.cs +++ b/src/SchematicHQ.Client/Types/EventBodyTrack.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,23 +11,28 @@ public record EventBodyTrack /// Key-value pairs to identify company associated with track event /// [JsonPropertyName("company")] - public Dictionary? Company { get; init; } + public Dictionary? Company { get; set; } /// /// The name of the type of track event /// [JsonPropertyName("event")] - public required string Event { get; init; } + public required string Event { get; set; } /// /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary? Traits { get; init; } + public Dictionary? Traits { get; set; } /// /// Key-value pairs to identify user associated with track event /// [JsonPropertyName("user")] - public Dictionary? User { get; init; } + public Dictionary? User { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EventDetailResponseData.cs b/src/SchematicHQ.Client/Types/EventDetailResponseData.cs index cdd8ade..930fb27 100644 --- a/src/SchematicHQ.Client/Types/EventDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/EventDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,65 +8,70 @@ namespace SchematicHQ.Client; public record EventDetailResponseData { [JsonPropertyName("api_key")] - public string? ApiKey { get; init; } + public string? ApiKey { get; set; } [JsonPropertyName("body")] - public Dictionary Body { get; init; } = new Dictionary(); + public Dictionary Body { get; set; } = new Dictionary(); [JsonPropertyName("body_preview")] - public required string BodyPreview { get; init; } + public required string BodyPreview { get; set; } [JsonPropertyName("captured_at")] - public required DateTime CapturedAt { get; init; } + public required DateTime CapturedAt { get; set; } [JsonPropertyName("company")] - public PreviewObject? Company { get; init; } + public PreviewObject? Company { get; set; } [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("enriched_at")] - public DateTime? EnrichedAt { get; init; } + public DateTime? EnrichedAt { get; set; } [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } [JsonPropertyName("error_message")] - public string? ErrorMessage { get; init; } + public string? ErrorMessage { get; set; } [JsonPropertyName("feature_ids")] - public IEnumerable FeatureIds { get; init; } = new List(); + public IEnumerable FeatureIds { get; set; } = new List(); [JsonPropertyName("features")] - public IEnumerable Features { get; init; } = new List(); + public IEnumerable Features { get; set; } = new List(); [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("loaded_at")] - public DateTime? LoadedAt { get; init; } + public DateTime? LoadedAt { get; set; } [JsonPropertyName("processed_at")] - public DateTime? ProcessedAt { get; init; } + public DateTime? ProcessedAt { get; set; } [JsonPropertyName("sent_at")] - public DateTime? SentAt { get; init; } + public DateTime? SentAt { get; set; } [JsonPropertyName("status")] - public required string Status { get; init; } + public required string Status { get; set; } [JsonPropertyName("subtype")] - public string? Subtype { get; init; } + public string? Subtype { get; set; } [JsonPropertyName("type")] - public required string Type { get; init; } + public required string Type { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("user")] - public PreviewObject? User { get; init; } + public PreviewObject? User { get; set; } [JsonPropertyName("user_id")] - public string? UserId { get; init; } + public string? UserId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EventResponseData.cs b/src/SchematicHQ.Client/Types/EventResponseData.cs index cfd9abd..08da572 100644 --- a/src/SchematicHQ.Client/Types/EventResponseData.cs +++ b/src/SchematicHQ.Client/Types/EventResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,56 +8,61 @@ namespace SchematicHQ.Client; public record EventResponseData { [JsonPropertyName("api_key")] - public string? ApiKey { get; init; } + public string? ApiKey { get; set; } [JsonPropertyName("body")] - public Dictionary Body { get; init; } = new Dictionary(); + public Dictionary Body { get; set; } = new Dictionary(); [JsonPropertyName("body_preview")] - public required string BodyPreview { get; init; } + public required string BodyPreview { get; set; } [JsonPropertyName("captured_at")] - public required DateTime CapturedAt { get; init; } + public required DateTime CapturedAt { get; set; } [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } [JsonPropertyName("enriched_at")] - public DateTime? EnrichedAt { get; init; } + public DateTime? EnrichedAt { get; set; } [JsonPropertyName("environment_id")] - public string? EnvironmentId { get; init; } + public string? EnvironmentId { get; set; } [JsonPropertyName("error_message")] - public string? ErrorMessage { get; init; } + public string? ErrorMessage { get; set; } [JsonPropertyName("feature_ids")] - public IEnumerable FeatureIds { get; init; } = new List(); + public IEnumerable FeatureIds { get; set; } = new List(); [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("loaded_at")] - public DateTime? LoadedAt { get; init; } + public DateTime? LoadedAt { get; set; } [JsonPropertyName("processed_at")] - public DateTime? ProcessedAt { get; init; } + public DateTime? ProcessedAt { get; set; } [JsonPropertyName("sent_at")] - public DateTime? SentAt { get; init; } + public DateTime? SentAt { get; set; } [JsonPropertyName("status")] - public required string Status { get; init; } + public required string Status { get; set; } [JsonPropertyName("subtype")] - public string? Subtype { get; init; } + public string? Subtype { get; set; } [JsonPropertyName("type")] - public required string Type { get; init; } + public required string Type { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("user_id")] - public string? UserId { get; init; } + public string? UserId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/EventSummaryResponseData.cs b/src/SchematicHQ.Client/Types/EventSummaryResponseData.cs index 3ba2580..f988bca 100644 --- a/src/SchematicHQ.Client/Types/EventSummaryResponseData.cs +++ b/src/SchematicHQ.Client/Types/EventSummaryResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record EventSummaryResponseData { [JsonPropertyName("company_count")] - public required int CompanyCount { get; init; } + public required int CompanyCount { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("event_count")] - public required int EventCount { get; init; } + public required int EventCount { get; set; } [JsonPropertyName("event_subtype")] - public required string EventSubtype { get; init; } + public required string EventSubtype { get; set; } [JsonPropertyName("last_seen_at")] - public DateTime? LastSeenAt { get; init; } + public DateTime? LastSeenAt { get; set; } [JsonPropertyName("user_count")] - public required int UserCount { get; init; } + public required int UserCount { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/FeatureCompanyResponseData.cs b/src/SchematicHQ.Client/Types/FeatureCompanyResponseData.cs index 5af0617..80ea22c 100644 --- a/src/SchematicHQ.Client/Types/FeatureCompanyResponseData.cs +++ b/src/SchematicHQ.Client/Types/FeatureCompanyResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,44 +11,64 @@ public record FeatureCompanyResponseData /// Whether further usage is permitted. /// [JsonPropertyName("access")] - public required bool Access { get; init; } + public required bool Access { get; set; } /// /// The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted. /// [JsonPropertyName("allocation")] - public int? Allocation { get; init; } + public int? Allocation { get; set; } /// /// The type of allocation that is being used. /// [JsonPropertyName("allocation_type")] - public required FeatureCompanyResponseDataAllocationType AllocationType { get; init; } + public required FeatureCompanyResponseDataAllocationType AllocationType { get; set; } [JsonPropertyName("company")] - public CompanyDetailResponseData? Company { get; init; } + public CompanyDetailResponseData? Company { get; set; } + + [JsonPropertyName("entitlement_expiration_date")] + public DateTime? EntitlementExpirationDate { get; set; } [JsonPropertyName("entitlement_id")] - public required string EntitlementId { get; init; } + public required string EntitlementId { get; set; } [JsonPropertyName("entitlement_type")] - public required string EntitlementType { get; init; } + public required string EntitlementType { get; set; } [JsonPropertyName("feature")] - public FeatureDetailResponseData? Feature { get; init; } + public FeatureDetailResponseData? Feature { get; set; } + + /// + /// The time at which the metric will resets. + /// + [JsonPropertyName("metric_reset_at")] + public DateTime? MetricResetAt { get; set; } + + /// + /// If the period is current_month, when the month resets. + /// + [JsonPropertyName("month_reset")] + public string? MonthReset { get; set; } /// /// The period over which usage is measured. /// [JsonPropertyName("period")] - public string? Period { get; init; } + public string? Period { get; set; } [JsonPropertyName("plan")] - public PlanResponseData? Plan { get; init; } + public PlanResponseData? Plan { get; set; } /// /// The amount of usage that has been consumed; a null value indicates that usage is not being measured. /// [JsonPropertyName("usage")] - public int? Usage { get; init; } + public int? Usage { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/FeatureCompanyResponseDataAllocationType.cs b/src/SchematicHQ.Client/Types/FeatureCompanyResponseDataAllocationType.cs index 094e1e2..05dcd80 100644 --- a/src/SchematicHQ.Client/Types/FeatureCompanyResponseDataAllocationType.cs +++ b/src/SchematicHQ.Client/Types/FeatureCompanyResponseDataAllocationType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum FeatureCompanyResponseDataAllocationType { [EnumMember(Value = "boolean")] @@ -20,5 +19,5 @@ public enum FeatureCompanyResponseDataAllocationType Trait, [EnumMember(Value = "unlimited")] - Unlimited + Unlimited, } diff --git a/src/SchematicHQ.Client/Types/FeatureCompanyUserResponseData.cs b/src/SchematicHQ.Client/Types/FeatureCompanyUserResponseData.cs index 2aa2d5a..10c05bc 100644 --- a/src/SchematicHQ.Client/Types/FeatureCompanyUserResponseData.cs +++ b/src/SchematicHQ.Client/Types/FeatureCompanyUserResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,47 +11,64 @@ public record FeatureCompanyUserResponseData /// Whether further usage is permitted. /// [JsonPropertyName("access")] - public required bool Access { get; init; } + public required bool Access { get; set; } /// /// The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted. /// [JsonPropertyName("allocation")] - public int? Allocation { get; init; } + public int? Allocation { get; set; } /// /// The type of allocation that is being used. /// [JsonPropertyName("allocation_type")] - public required FeatureCompanyUserResponseDataAllocationType AllocationType { get; init; } + public required FeatureCompanyUserResponseDataAllocationType AllocationType { get; set; } [JsonPropertyName("company")] - public CompanyDetailResponseData? Company { get; init; } + public CompanyDetailResponseData? Company { get; set; } [JsonPropertyName("entitlement_id")] - public required string EntitlementId { get; init; } + public required string EntitlementId { get; set; } [JsonPropertyName("entitlement_type")] - public required string EntitlementType { get; init; } + public required string EntitlementType { get; set; } [JsonPropertyName("feature")] - public FeatureDetailResponseData? Feature { get; init; } + public FeatureDetailResponseData? Feature { get; set; } + + /// + /// The time at which the metric will resets. + /// + [JsonPropertyName("metric_reset_at")] + public DateTime? MetricResetAt { get; set; } + + /// + /// If the period is current_month, when the month resets. + /// + [JsonPropertyName("month_reset")] + public string? MonthReset { get; set; } /// /// The period over which usage is measured. /// [JsonPropertyName("period")] - public string? Period { get; init; } + public string? Period { get; set; } [JsonPropertyName("plan")] - public PlanResponseData? Plan { get; init; } + public PlanResponseData? Plan { get; set; } /// /// The amount of usage that has been consumed; a null value indicates that usage is not being measured. /// [JsonPropertyName("usage")] - public int? Usage { get; init; } + public int? Usage { get; set; } [JsonPropertyName("user")] - public UserResponseData? User { get; init; } + public UserResponseData? User { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/FeatureCompanyUserResponseDataAllocationType.cs b/src/SchematicHQ.Client/Types/FeatureCompanyUserResponseDataAllocationType.cs index 63b4652..d89ca4d 100644 --- a/src/SchematicHQ.Client/Types/FeatureCompanyUserResponseDataAllocationType.cs +++ b/src/SchematicHQ.Client/Types/FeatureCompanyUserResponseDataAllocationType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum FeatureCompanyUserResponseDataAllocationType { [EnumMember(Value = "boolean")] @@ -20,5 +19,5 @@ public enum FeatureCompanyUserResponseDataAllocationType Trait, [EnumMember(Value = "unlimited")] - Unlimited + Unlimited, } diff --git a/src/SchematicHQ.Client/Types/FeatureDetailResponseData.cs b/src/SchematicHQ.Client/Types/FeatureDetailResponseData.cs index eb30a4a..023fd6d 100644 --- a/src/SchematicHQ.Client/Types/FeatureDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/FeatureDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,48 +8,53 @@ namespace SchematicHQ.Client; public record FeatureDetailResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("event_subtype")] - public string? EventSubtype { get; init; } + public string? EventSubtype { get; set; } [JsonPropertyName("event_summary")] - public EventSummaryResponseData? EventSummary { get; init; } + public EventSummaryResponseData? EventSummary { get; set; } [JsonPropertyName("feature_type")] - public required string FeatureType { get; init; } + public required string FeatureType { get; set; } [JsonPropertyName("flags")] - public IEnumerable Flags { get; init; } = + public IEnumerable Flags { get; set; } = new List(); [JsonPropertyName("icon")] - public required string Icon { get; init; } + public required string Icon { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("lifecycle_phase")] - public string? LifecyclePhase { get; init; } + public string? LifecyclePhase { get; set; } [JsonPropertyName("maintainer_id")] - public string? MaintainerId { get; init; } + public string? MaintainerId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("plans")] - public IEnumerable Plans { get; init; } = new List(); + public IEnumerable Plans { get; set; } = new List(); [JsonPropertyName("trait")] - public EntityTraitDefinitionResponseData? Trait { get; init; } + public EntityTraitDefinitionResponseData? Trait { get; set; } [JsonPropertyName("trait_id")] - public string? TraitId { get; init; } + public string? TraitId { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/FeatureResponseData.cs b/src/SchematicHQ.Client/Types/FeatureResponseData.cs index e55d56d..f125911 100644 --- a/src/SchematicHQ.Client/Types/FeatureResponseData.cs +++ b/src/SchematicHQ.Client/Types/FeatureResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,35 +8,40 @@ namespace SchematicHQ.Client; public record FeatureResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("event_subtype")] - public string? EventSubtype { get; init; } + public string? EventSubtype { get; set; } [JsonPropertyName("feature_type")] - public required string FeatureType { get; init; } + public required string FeatureType { get; set; } [JsonPropertyName("icon")] - public required string Icon { get; init; } + public required string Icon { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("lifecycle_phase")] - public string? LifecyclePhase { get; init; } + public string? LifecyclePhase { get; set; } [JsonPropertyName("maintainer_id")] - public string? MaintainerId { get; init; } + public string? MaintainerId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("trait_id")] - public string? TraitId { get; init; } + public string? TraitId { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/FeatureUsageDetailResponseData.cs b/src/SchematicHQ.Client/Types/FeatureUsageDetailResponseData.cs index 52290bb..0751314 100644 --- a/src/SchematicHQ.Client/Types/FeatureUsageDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/FeatureUsageDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,6 +8,11 @@ namespace SchematicHQ.Client; public record FeatureUsageDetailResponseData { [JsonPropertyName("features")] - public IEnumerable Features { get; init; } = + public IEnumerable Features { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/FeatureUsageResponseData.cs b/src/SchematicHQ.Client/Types/FeatureUsageResponseData.cs index 91a88d6..5695f99 100644 --- a/src/SchematicHQ.Client/Types/FeatureUsageResponseData.cs +++ b/src/SchematicHQ.Client/Types/FeatureUsageResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,41 +11,70 @@ public record FeatureUsageResponseData /// Whether further usage is permitted. /// [JsonPropertyName("access")] - public required bool Access { get; init; } + public required bool Access { get; set; } /// /// The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted. /// [JsonPropertyName("allocation")] - public int? Allocation { get; init; } + public int? Allocation { get; set; } /// /// The type of allocation that is being used. /// [JsonPropertyName("allocation_type")] - public required FeatureUsageResponseDataAllocationType AllocationType { get; init; } + public required FeatureUsageResponseDataAllocationType AllocationType { get; set; } + + [JsonPropertyName("entitlement_expiration_date")] + public DateTime? EntitlementExpirationDate { get; set; } [JsonPropertyName("entitlement_id")] - public required string EntitlementId { get; init; } + public required string EntitlementId { get; set; } [JsonPropertyName("entitlement_type")] - public required string EntitlementType { get; init; } + public required string EntitlementType { get; set; } [JsonPropertyName("feature")] - public FeatureDetailResponseData? Feature { get; init; } + public FeatureDetailResponseData? Feature { get; set; } + + /// + /// The time at which the metric will reset. + /// + [JsonPropertyName("metric_reset_at")] + public DateTime? MetricResetAt { get; set; } + + /// + /// If the period is current_month, when the month resets. + /// + [JsonPropertyName("month_reset")] + public string? MonthReset { get; set; } + + [JsonPropertyName("monthly_usage_based_price")] + public BillingPriceView? MonthlyUsageBasedPrice { get; set; } /// /// The period over which usage is measured. /// [JsonPropertyName("period")] - public string? Period { get; init; } + public string? Period { get; set; } [JsonPropertyName("plan")] - public PlanResponseData? Plan { get; init; } + public PlanResponseData? Plan { get; set; } + + [JsonPropertyName("price_behavior")] + public string? PriceBehavior { get; set; } /// /// The amount of usage that has been consumed; a null value indicates that usage is not being measured. /// [JsonPropertyName("usage")] - public int? Usage { get; init; } + public int? Usage { get; set; } + + [JsonPropertyName("yearly_usage_based_price")] + public BillingPriceView? YearlyUsageBasedPrice { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/FeatureUsageResponseDataAllocationType.cs b/src/SchematicHQ.Client/Types/FeatureUsageResponseDataAllocationType.cs index 4d8725e..c2d7eef 100644 --- a/src/SchematicHQ.Client/Types/FeatureUsageResponseDataAllocationType.cs +++ b/src/SchematicHQ.Client/Types/FeatureUsageResponseDataAllocationType.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum FeatureUsageResponseDataAllocationType { [EnumMember(Value = "boolean")] @@ -20,5 +19,5 @@ public enum FeatureUsageResponseDataAllocationType Trait, [EnumMember(Value = "unlimited")] - Unlimited + Unlimited, } diff --git a/src/SchematicHQ.Client/Types/FlagDetailResponseData.cs b/src/SchematicHQ.Client/Types/FlagDetailResponseData.cs index 3df2581..808b05a 100644 --- a/src/SchematicHQ.Client/Types/FlagDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/FlagDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,42 +8,47 @@ namespace SchematicHQ.Client; public record FlagDetailResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("default_value")] - public required bool DefaultValue { get; init; } + public required bool DefaultValue { get; set; } [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("feature")] - public FeatureResponseData? Feature { get; init; } + public FeatureResponseData? Feature { get; set; } [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } [JsonPropertyName("flag_type")] - public required string FlagType { get; init; } + public required string FlagType { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("key")] - public required string Key { get; init; } + public required string Key { get; set; } [JsonPropertyName("last_checked_at")] - public DateTime? LastCheckedAt { get; init; } + public DateTime? LastCheckedAt { get; set; } [JsonPropertyName("maintainer_id")] - public string? MaintainerId { get; init; } + public string? MaintainerId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("rules")] - public IEnumerable Rules { get; init; } = + public IEnumerable Rules { get; set; } = new List(); [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/FlagResponseData.cs b/src/SchematicHQ.Client/Types/FlagResponseData.cs index d31e36e..c066dc0 100644 --- a/src/SchematicHQ.Client/Types/FlagResponseData.cs +++ b/src/SchematicHQ.Client/Types/FlagResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,32 +8,37 @@ namespace SchematicHQ.Client; public record FlagResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("default_value")] - public required bool DefaultValue { get; init; } + public required bool DefaultValue { get; set; } [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("feature_id")] - public string? FeatureId { get; init; } + public string? FeatureId { get; set; } [JsonPropertyName("flag_type")] - public required string FlagType { get; init; } + public required string FlagType { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("key")] - public required string Key { get; init; } + public required string Key { get; set; } [JsonPropertyName("maintainer_id")] - public string? MaintainerId { get; init; } + public string? MaintainerId { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/GenericPreviewObject.cs b/src/SchematicHQ.Client/Types/GenericPreviewObject.cs new file mode 100644 index 0000000..0033117 --- /dev/null +++ b/src/SchematicHQ.Client/Types/GenericPreviewObject.cs @@ -0,0 +1,26 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record GenericPreviewObject +{ + [JsonPropertyName("description")] + public string? Description { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("image_url")] + public string? ImageUrl { get; set; } + + [JsonPropertyName("name")] + public required string Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/InvoiceRequestBody.cs b/src/SchematicHQ.Client/Types/InvoiceRequestBody.cs new file mode 100644 index 0000000..9356407 --- /dev/null +++ b/src/SchematicHQ.Client/Types/InvoiceRequestBody.cs @@ -0,0 +1,47 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record InvoiceRequestBody +{ + [JsonPropertyName("amount_due")] + public required int AmountDue { get; set; } + + [JsonPropertyName("amount_paid")] + public required int AmountPaid { get; set; } + + [JsonPropertyName("amount_remaining")] + public required int AmountRemaining { get; set; } + + [JsonPropertyName("collection_method")] + public required string CollectionMethod { get; set; } + + [JsonPropertyName("currency")] + public required string Currency { get; set; } + + [JsonPropertyName("customer_external_id")] + public required string CustomerExternalId { get; set; } + + [JsonPropertyName("due_date")] + public DateTime? DueDate { get; set; } + + [JsonPropertyName("payment_method_external_id")] + public string? PaymentMethodExternalId { get; set; } + + [JsonPropertyName("subscription_external_id")] + public string? SubscriptionExternalId { get; set; } + + [JsonPropertyName("subtotal")] + public required int Subtotal { get; set; } + + [JsonPropertyName("url")] + public string? Url { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/InvoiceResponseData.cs b/src/SchematicHQ.Client/Types/InvoiceResponseData.cs new file mode 100644 index 0000000..e14ec6c --- /dev/null +++ b/src/SchematicHQ.Client/Types/InvoiceResponseData.cs @@ -0,0 +1,65 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record InvoiceResponseData +{ + [JsonPropertyName("amount_due")] + public required int AmountDue { get; set; } + + [JsonPropertyName("amount_paid")] + public required int AmountPaid { get; set; } + + [JsonPropertyName("amount_remaining")] + public required int AmountRemaining { get; set; } + + [JsonPropertyName("collection_method")] + public required string CollectionMethod { get; set; } + + [JsonPropertyName("company_id")] + public string? CompanyId { get; set; } + + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("currency")] + public required string Currency { get; set; } + + [JsonPropertyName("customer_external_id")] + public required string CustomerExternalId { get; set; } + + [JsonPropertyName("due_date")] + public DateTime? DueDate { get; set; } + + [JsonPropertyName("environment_id")] + public required string EnvironmentId { get; set; } + + [JsonPropertyName("external_id")] + public string? ExternalId { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("payment_method_external_id")] + public string? PaymentMethodExternalId { get; set; } + + [JsonPropertyName("subscription_external_id")] + public string? SubscriptionExternalId { get; set; } + + [JsonPropertyName("subtotal")] + public required int Subtotal { get; set; } + + [JsonPropertyName("updated_at")] + public required DateTime UpdatedAt { get; set; } + + [JsonPropertyName("url")] + public string? Url { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/IssueTemporaryAccessTokenResponseData.cs b/src/SchematicHQ.Client/Types/IssueTemporaryAccessTokenResponseData.cs index d4de43b..3f8669a 100644 --- a/src/SchematicHQ.Client/Types/IssueTemporaryAccessTokenResponseData.cs +++ b/src/SchematicHQ.Client/Types/IssueTemporaryAccessTokenResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,26 +8,31 @@ namespace SchematicHQ.Client; public record IssueTemporaryAccessTokenResponseData { [JsonPropertyName("api_key_id")] - public required string ApiKeyId { get; init; } + public required string ApiKeyId { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("expired_at")] - public required DateTime ExpiredAt { get; init; } + public required DateTime ExpiredAt { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("resource_type")] - public required string ResourceType { get; init; } + public required string ResourceType { get; set; } [JsonPropertyName("token")] - public required string Token { get; init; } + public required string Token { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/KeysRequestBody.cs b/src/SchematicHQ.Client/Types/KeysRequestBody.cs index 5c1c347..f3abbca 100644 --- a/src/SchematicHQ.Client/Types/KeysRequestBody.cs +++ b/src/SchematicHQ.Client/Types/KeysRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,5 +8,10 @@ namespace SchematicHQ.Client; public record KeysRequestBody { [JsonPropertyName("keys")] - public Dictionary Keys { get; init; } = new Dictionary(); + public Dictionary Keys { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/MeterRequestBody.cs b/src/SchematicHQ.Client/Types/MeterRequestBody.cs new file mode 100644 index 0000000..27c1df6 --- /dev/null +++ b/src/SchematicHQ.Client/Types/MeterRequestBody.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record MeterRequestBody +{ + [JsonPropertyName("display_name")] + public required string DisplayName { get; set; } + + [JsonPropertyName("event_name")] + public required string EventName { get; set; } + + [JsonPropertyName("event_payload_key")] + public required string EventPayloadKey { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/MetricCountsHourlyResponseData.cs b/src/SchematicHQ.Client/Types/MetricCountsHourlyResponseData.cs deleted file mode 100644 index 3fa7f82..0000000 --- a/src/SchematicHQ.Client/Types/MetricCountsHourlyResponseData.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Text.Json.Serialization; - -#nullable enable - -namespace SchematicHQ.Client; - -public record MetricCountsHourlyResponseData -{ - [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } - - [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } - - [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } - - [JsonPropertyName("event_subtype")] - public required string EventSubtype { get; init; } - - [JsonPropertyName("start_time")] - public required DateTime StartTime { get; init; } - - [JsonPropertyName("user_id")] - public string? UserId { get; init; } - - [JsonPropertyName("value")] - public required int Value { get; init; } -} diff --git a/src/SchematicHQ.Client/Types/PaginationFilter.cs b/src/SchematicHQ.Client/Types/PaginationFilter.cs index 9e863dc..cc18ab0 100644 --- a/src/SchematicHQ.Client/Types/PaginationFilter.cs +++ b/src/SchematicHQ.Client/Types/PaginationFilter.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,11 +11,16 @@ public record PaginationFilter /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/PaymentMethodRequestBody.cs b/src/SchematicHQ.Client/Types/PaymentMethodRequestBody.cs new file mode 100644 index 0000000..5d10977 --- /dev/null +++ b/src/SchematicHQ.Client/Types/PaymentMethodRequestBody.cs @@ -0,0 +1,50 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PaymentMethodRequestBody +{ + [JsonPropertyName("account_last4")] + public string? AccountLast4 { get; set; } + + [JsonPropertyName("account_name")] + public string? AccountName { get; set; } + + [JsonPropertyName("bank_name")] + public string? BankName { get; set; } + + [JsonPropertyName("billing_email")] + public string? BillingEmail { get; set; } + + [JsonPropertyName("billing_name")] + public string? BillingName { get; set; } + + [JsonPropertyName("card_brand")] + public string? CardBrand { get; set; } + + [JsonPropertyName("card_exp_month")] + public int? CardExpMonth { get; set; } + + [JsonPropertyName("card_exp_year")] + public int? CardExpYear { get; set; } + + [JsonPropertyName("card_last4")] + public string? CardLast4 { get; set; } + + [JsonPropertyName("customer_external_id")] + public required string CustomerExternalId { get; set; } + + [JsonPropertyName("payment_method_type")] + public required string PaymentMethodType { get; set; } + + [JsonPropertyName("subscription_external_id")] + public string? SubscriptionExternalId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/PaymentMethodResponseData.cs b/src/SchematicHQ.Client/Types/PaymentMethodResponseData.cs new file mode 100644 index 0000000..28a1de8 --- /dev/null +++ b/src/SchematicHQ.Client/Types/PaymentMethodResponseData.cs @@ -0,0 +1,68 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PaymentMethodResponseData +{ + [JsonPropertyName("account_last4")] + public string? AccountLast4 { get; set; } + + [JsonPropertyName("account_name")] + public string? AccountName { get; set; } + + [JsonPropertyName("bank_name")] + public string? BankName { get; set; } + + [JsonPropertyName("billing_email")] + public string? BillingEmail { get; set; } + + [JsonPropertyName("billing_name")] + public string? BillingName { get; set; } + + [JsonPropertyName("card_brand")] + public string? CardBrand { get; set; } + + [JsonPropertyName("card_exp_month")] + public int? CardExpMonth { get; set; } + + [JsonPropertyName("card_exp_year")] + public int? CardExpYear { get; set; } + + [JsonPropertyName("card_last4")] + public string? CardLast4 { get; set; } + + [JsonPropertyName("company_id")] + public string? CompanyId { get; set; } + + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("customer_external_id")] + public required string CustomerExternalId { get; set; } + + [JsonPropertyName("environment_id")] + public required string EnvironmentId { get; set; } + + [JsonPropertyName("external_id")] + public required string ExternalId { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("payment_method_type")] + public required string PaymentMethodType { get; set; } + + [JsonPropertyName("subscription_external_id")] + public string? SubscriptionExternalId { get; set; } + + [JsonPropertyName("updated_at")] + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/PlanAudienceDetailResponseData.cs b/src/SchematicHQ.Client/Types/PlanAudienceDetailResponseData.cs index cd4fa57..5f1a29c 100644 --- a/src/SchematicHQ.Client/Types/PlanAudienceDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/PlanAudienceDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,40 +8,45 @@ namespace SchematicHQ.Client; public record PlanAudienceDetailResponseData { [JsonPropertyName("condition_groups")] - public IEnumerable ConditionGroups { get; init; } = + public IEnumerable ConditionGroups { get; set; } = new List(); [JsonPropertyName("conditions")] - public IEnumerable Conditions { get; init; } = + public IEnumerable Conditions { get; set; } = new List(); [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } [JsonPropertyName("priority")] - public required int Priority { get; init; } + public required int Priority { get; set; } [JsonPropertyName("rule_type")] - public required string RuleType { get; init; } + public required string RuleType { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("value")] - public required bool Value { get; init; } + public required bool Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/PlanAudienceResponseData.cs b/src/SchematicHQ.Client/Types/PlanAudienceResponseData.cs index fa2a144..9e0c2c9 100644 --- a/src/SchematicHQ.Client/Types/PlanAudienceResponseData.cs +++ b/src/SchematicHQ.Client/Types/PlanAudienceResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,32 +8,37 @@ namespace SchematicHQ.Client; public record PlanAudienceResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } [JsonPropertyName("priority")] - public required int Priority { get; init; } + public required int Priority { get; set; } [JsonPropertyName("rule_type")] - public required string RuleType { get; init; } + public required string RuleType { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("value")] - public required bool Value { get; init; } + public required bool Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/PlanDetailResponseData.cs b/src/SchematicHQ.Client/Types/PlanDetailResponseData.cs index 73593c9..ee17c78 100644 --- a/src/SchematicHQ.Client/Types/PlanDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/PlanDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,36 +8,59 @@ namespace SchematicHQ.Client; public record PlanDetailResponseData { [JsonPropertyName("audience_type")] - public string? AudienceType { get; init; } + public string? AudienceType { get; set; } [JsonPropertyName("billing_product")] - public BillingProductDetailResponseData? BillingProduct { get; init; } + public BillingProductDetailResponseData? BillingProduct { get; set; } [JsonPropertyName("company_count")] - public required int CompanyCount { get; init; } + public required int CompanyCount { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("features")] - public IEnumerable Features { get; init; } = + public IEnumerable Features { get; set; } = new List(); [JsonPropertyName("icon")] - public required string Icon { get; init; } + public required string Icon { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } + + [JsonPropertyName("is_default")] + public required bool IsDefault { get; set; } + + [JsonPropertyName("is_free")] + public required bool IsFree { get; set; } + + [JsonPropertyName("is_trialable")] + public required bool IsTrialable { get; set; } + + [JsonPropertyName("monthly_price")] + public BillingPriceResponseData? MonthlyPrice { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("plan_type")] - public required string PlanType { get; init; } + public required string PlanType { get; set; } + + [JsonPropertyName("trial_days")] + public int? TrialDays { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + [JsonPropertyName("yearly_price")] + public BillingPriceResponseData? YearlyPrice { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/PlanEntitlementResponseData.cs b/src/SchematicHQ.Client/Types/PlanEntitlementResponseData.cs index 79db480..66b441f 100644 --- a/src/SchematicHQ.Client/Types/PlanEntitlementResponseData.cs +++ b/src/SchematicHQ.Client/Types/PlanEntitlementResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,47 +8,64 @@ namespace SchematicHQ.Client; public record PlanEntitlementResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("feature")] - public FeatureResponseData? Feature { get; init; } + public FeatureResponseData? Feature { get; set; } [JsonPropertyName("feature_id")] - public required string FeatureId { get; init; } + public required string FeatureId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } + + [JsonPropertyName("metered_monthly_price")] + public BillingPriceView? MeteredMonthlyPrice { get; set; } + + [JsonPropertyName("metered_yearly_price")] + public BillingPriceView? MeteredYearlyPrice { get; set; } [JsonPropertyName("metric_period")] - public string? MetricPeriod { get; init; } + public string? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public string? MetricPeriodMonthReset { get; set; } [JsonPropertyName("plan")] - public PlanResponseData? Plan { get; init; } + public PlanResponseData? Plan { get; set; } [JsonPropertyName("plan_id")] - public required string PlanId { get; init; } + public required string PlanId { get; set; } + + [JsonPropertyName("price_behavior")] + public string? PriceBehavior { get; set; } [JsonPropertyName("rule_id")] - public required string RuleId { get; init; } + public required string RuleId { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("value_bool")] - public bool? ValueBool { get; init; } + public bool? ValueBool { get; set; } [JsonPropertyName("value_numeric")] - public int? ValueNumeric { get; init; } + public int? ValueNumeric { get; set; } [JsonPropertyName("value_trait")] - public EntityTraitDefinitionResponseData? ValueTrait { get; init; } + public EntityTraitDefinitionResponseData? ValueTrait { get; set; } [JsonPropertyName("value_trait_id")] - public string? ValueTraitId { get; init; } + public string? ValueTraitId { get; set; } [JsonPropertyName("value_type")] - public required string ValueType { get; init; } + public required string ValueType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/PlanGroupDetailResponseData.cs b/src/SchematicHQ.Client/Types/PlanGroupDetailResponseData.cs new file mode 100644 index 0000000..e5afde2 --- /dev/null +++ b/src/SchematicHQ.Client/Types/PlanGroupDetailResponseData.cs @@ -0,0 +1,37 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PlanGroupDetailResponseData +{ + [JsonPropertyName("add_ons")] + public IEnumerable AddOns { get; set; } = + new List(); + + [JsonPropertyName("default_plan")] + public PlanGroupPlanDetailResponseData? DefaultPlan { get; set; } + + [JsonPropertyName("default_plan_id")] + public string? DefaultPlanId { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("plans")] + public IEnumerable Plans { get; set; } = + new List(); + + [JsonPropertyName("trial_days")] + public int? TrialDays { get; set; } + + [JsonPropertyName("trial_payment_method_required")] + public bool? TrialPaymentMethodRequired { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/PlanGroupPlanDetailResponseData.cs b/src/SchematicHQ.Client/Types/PlanGroupPlanDetailResponseData.cs new file mode 100644 index 0000000..94aba9a --- /dev/null +++ b/src/SchematicHQ.Client/Types/PlanGroupPlanDetailResponseData.cs @@ -0,0 +1,70 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PlanGroupPlanDetailResponseData +{ + [JsonPropertyName("audience_type")] + public string? AudienceType { get; set; } + + [JsonPropertyName("billing_product")] + public BillingProductDetailResponseData? BillingProduct { get; set; } + + [JsonPropertyName("company_count")] + public required int CompanyCount { get; set; } + + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("description")] + public required string Description { get; set; } + + [JsonPropertyName("entitlements")] + public IEnumerable Entitlements { get; set; } = + new List(); + + [JsonPropertyName("features")] + public IEnumerable Features { get; set; } = + new List(); + + [JsonPropertyName("icon")] + public required string Icon { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("is_default")] + public required bool IsDefault { get; set; } + + [JsonPropertyName("is_free")] + public required bool IsFree { get; set; } + + [JsonPropertyName("is_trialable")] + public required bool IsTrialable { get; set; } + + [JsonPropertyName("monthly_price")] + public BillingPriceResponseData? MonthlyPrice { get; set; } + + [JsonPropertyName("name")] + public required string Name { get; set; } + + [JsonPropertyName("plan_type")] + public required string PlanType { get; set; } + + [JsonPropertyName("trial_days")] + public int? TrialDays { get; set; } + + [JsonPropertyName("updated_at")] + public required DateTime UpdatedAt { get; set; } + + [JsonPropertyName("yearly_price")] + public BillingPriceResponseData? YearlyPrice { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/PlanGroupResponseData.cs b/src/SchematicHQ.Client/Types/PlanGroupResponseData.cs new file mode 100644 index 0000000..c355904 --- /dev/null +++ b/src/SchematicHQ.Client/Types/PlanGroupResponseData.cs @@ -0,0 +1,32 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PlanGroupResponseData +{ + [JsonPropertyName("add_on_ids")] + public IEnumerable AddOnIds { get; set; } = new List(); + + [JsonPropertyName("default_plan_id")] + public string? DefaultPlanId { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("plan_ids")] + public IEnumerable PlanIds { get; set; } = new List(); + + [JsonPropertyName("trial_days")] + public int? TrialDays { get; set; } + + [JsonPropertyName("trial_payment_method_required")] + public bool? TrialPaymentMethodRequired { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/PlanResponseData.cs b/src/SchematicHQ.Client/Types/PlanResponseData.cs index 26efff3..3d5fa7e 100644 --- a/src/SchematicHQ.Client/Types/PlanResponseData.cs +++ b/src/SchematicHQ.Client/Types/PlanResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,26 +8,31 @@ namespace SchematicHQ.Client; public record PlanResponseData { [JsonPropertyName("audience_type")] - public string? AudienceType { get; init; } + public string? AudienceType { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("description")] - public required string Description { get; init; } + public required string Description { get; set; } [JsonPropertyName("icon")] - public required string Icon { get; init; } + public required string Icon { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("plan_type")] - public required string PlanType { get; init; } + public required string PlanType { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/PreviewObject.cs b/src/SchematicHQ.Client/Types/PreviewObject.cs index 0e8f5fb..ca73a51 100644 --- a/src/SchematicHQ.Client/Types/PreviewObject.cs +++ b/src/SchematicHQ.Client/Types/PreviewObject.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,14 +8,19 @@ namespace SchematicHQ.Client; public record PreviewObject { [JsonPropertyName("description")] - public string? Description { get; init; } + public string? Description { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("image_url")] - public string? ImageUrl { get; init; } + public string? ImageUrl { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/PreviewObjectResponseData.cs b/src/SchematicHQ.Client/Types/PreviewObjectResponseData.cs new file mode 100644 index 0000000..4547769 --- /dev/null +++ b/src/SchematicHQ.Client/Types/PreviewObjectResponseData.cs @@ -0,0 +1,26 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PreviewObjectResponseData +{ + [JsonPropertyName("description")] + public string? Description { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("image_url")] + public string? ImageUrl { get; set; } + + [JsonPropertyName("name")] + public required string Name { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/PreviewSubscriptionChangeResponseData.cs b/src/SchematicHQ.Client/Types/PreviewSubscriptionChangeResponseData.cs new file mode 100644 index 0000000..082a9c5 --- /dev/null +++ b/src/SchematicHQ.Client/Types/PreviewSubscriptionChangeResponseData.cs @@ -0,0 +1,38 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record PreviewSubscriptionChangeResponseData +{ + [JsonPropertyName("amount_off")] + public required int AmountOff { get; set; } + + [JsonPropertyName("due_now")] + public required int DueNow { get; set; } + + [JsonPropertyName("new_charges")] + public required int NewCharges { get; set; } + + [JsonPropertyName("percent_off")] + public required double PercentOff { get; set; } + + [JsonPropertyName("period_start")] + public required DateTime PeriodStart { get; set; } + + [JsonPropertyName("promo_code_applied")] + public required bool PromoCodeApplied { get; set; } + + [JsonPropertyName("proration")] + public required int Proration { get; set; } + + [JsonPropertyName("trial_end")] + public DateTime? TrialEnd { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/RawEventBatchResponseData.cs b/src/SchematicHQ.Client/Types/RawEventBatchResponseData.cs index 4ad0a94..7dd2fcf 100644 --- a/src/SchematicHQ.Client/Types/RawEventBatchResponseData.cs +++ b/src/SchematicHQ.Client/Types/RawEventBatchResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,6 +8,11 @@ namespace SchematicHQ.Client; public record RawEventBatchResponseData { [JsonPropertyName("events")] - public IEnumerable Events { get; init; } = + public IEnumerable Events { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/RawEventResponseData.cs b/src/SchematicHQ.Client/Types/RawEventResponseData.cs index e66a0b8..46c728c 100644 --- a/src/SchematicHQ.Client/Types/RawEventResponseData.cs +++ b/src/SchematicHQ.Client/Types/RawEventResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,17 +8,22 @@ namespace SchematicHQ.Client; public record RawEventResponseData { [JsonPropertyName("captured_at")] - public required DateTime CapturedAt { get; init; } + public required DateTime CapturedAt { get; set; } [JsonPropertyName("event_id")] - public string? EventId { get; init; } + public string? EventId { get; set; } [JsonPropertyName("remote_addr")] - public required string RemoteAddr { get; init; } + public required string RemoteAddr { get; set; } [JsonPropertyName("remote_ip")] - public required string RemoteIp { get; init; } + public required string RemoteIp { get; set; } [JsonPropertyName("user_agent")] - public required string UserAgent { get; init; } + public required string UserAgent { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/RuleConditionDetailResponseData.cs b/src/SchematicHQ.Client/Types/RuleConditionDetailResponseData.cs index 2bf1f57..bf63d33 100644 --- a/src/SchematicHQ.Client/Types/RuleConditionDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/RuleConditionDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,66 +8,74 @@ namespace SchematicHQ.Client; public record RuleConditionDetailResponseData { [JsonPropertyName("comparison_trait")] - public EntityTraitDefinitionResponseData? ComparisonTrait { get; init; } + public EntityTraitDefinitionResponseData? ComparisonTrait { get; set; } [JsonPropertyName("comparison_trait_id")] - public string? ComparisonTraitId { get; init; } + public string? ComparisonTraitId { get; set; } [JsonPropertyName("condition_group_id")] - public string? ConditionGroupId { get; init; } + public string? ConditionGroupId { get; set; } [JsonPropertyName("condition_type")] - public required string ConditionType { get; init; } + public required string ConditionType { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("event_subtype")] - public string? EventSubtype { get; init; } + public string? EventSubtype { get; set; } [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("metric_period")] - public string? MetricPeriod { get; init; } + public string? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public string? MetricPeriodMonthReset { get; set; } [JsonPropertyName("metric_value")] - public int? MetricValue { get; init; } + public int? MetricValue { get; set; } [JsonPropertyName("operator")] - public required string Operator { get; init; } + public required string Operator { get; set; } [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } [JsonPropertyName("resource_ids")] - public IEnumerable ResourceIds { get; init; } = new List(); + public IEnumerable ResourceIds { get; set; } = new List(); [JsonPropertyName("resources")] - public IEnumerable Resources { get; init; } = - new List(); + public IEnumerable Resources { get; set; } = + new List(); [JsonPropertyName("rule_id")] - public required string RuleId { get; init; } + public required string RuleId { get; set; } [JsonPropertyName("trait")] - public EntityTraitDefinitionResponseData? Trait { get; init; } + public EntityTraitDefinitionResponseData? Trait { get; set; } [JsonPropertyName("trait_entity_type")] - public string? TraitEntityType { get; init; } + public string? TraitEntityType { get; set; } [JsonPropertyName("trait_id")] - public string? TraitId { get; init; } + public string? TraitId { get; set; } [JsonPropertyName("trait_value")] - public required string TraitValue { get; init; } + public required string TraitValue { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/RuleConditionGroupDetailResponseData.cs b/src/SchematicHQ.Client/Types/RuleConditionGroupDetailResponseData.cs index b2376d6..ac34b5e 100644 --- a/src/SchematicHQ.Client/Types/RuleConditionGroupDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/RuleConditionGroupDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,27 +8,32 @@ namespace SchematicHQ.Client; public record RuleConditionGroupDetailResponseData { [JsonPropertyName("conditions")] - public IEnumerable Conditions { get; init; } = + public IEnumerable Conditions { get; set; } = new List(); [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } [JsonPropertyName("rule_id")] - public required string RuleId { get; init; } + public required string RuleId { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/RuleConditionGroupResponseData.cs b/src/SchematicHQ.Client/Types/RuleConditionGroupResponseData.cs index ffdb21f..c0ac439 100644 --- a/src/SchematicHQ.Client/Types/RuleConditionGroupResponseData.cs +++ b/src/SchematicHQ.Client/Types/RuleConditionGroupResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record RuleConditionGroupResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } [JsonPropertyName("rule_id")] - public required string RuleId { get; init; } + public required string RuleId { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/RuleConditionResourceResponseData.cs b/src/SchematicHQ.Client/Types/RuleConditionResourceResponseData.cs deleted file mode 100644 index 4e55da7..0000000 --- a/src/SchematicHQ.Client/Types/RuleConditionResourceResponseData.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Text.Json.Serialization; - -#nullable enable - -namespace SchematicHQ.Client; - -public record RuleConditionResourceResponseData -{ - [JsonPropertyName("id")] - public required string Id { get; init; } - - [JsonPropertyName("name")] - public required string Name { get; init; } -} diff --git a/src/SchematicHQ.Client/Types/RuleConditionResponseData.cs b/src/SchematicHQ.Client/Types/RuleConditionResponseData.cs index 3882a75..5c0245d 100644 --- a/src/SchematicHQ.Client/Types/RuleConditionResponseData.cs +++ b/src/SchematicHQ.Client/Types/RuleConditionResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,56 +8,64 @@ namespace SchematicHQ.Client; public record RuleConditionResponseData { [JsonPropertyName("comparison_trait_id")] - public string? ComparisonTraitId { get; init; } + public string? ComparisonTraitId { get; set; } [JsonPropertyName("condition_group_id")] - public string? ConditionGroupId { get; init; } + public string? ConditionGroupId { get; set; } [JsonPropertyName("condition_type")] - public required string ConditionType { get; init; } + public required string ConditionType { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("event_subtype")] - public string? EventSubtype { get; init; } + public string? EventSubtype { get; set; } [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("metric_period")] - public string? MetricPeriod { get; init; } + public string? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public string? MetricPeriodMonthReset { get; set; } [JsonPropertyName("metric_value")] - public int? MetricValue { get; init; } + public int? MetricValue { get; set; } [JsonPropertyName("operator")] - public required string Operator { get; init; } + public required string Operator { get; set; } [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } [JsonPropertyName("resource_ids")] - public IEnumerable ResourceIds { get; init; } = new List(); + public IEnumerable ResourceIds { get; set; } = new List(); [JsonPropertyName("rule_id")] - public required string RuleId { get; init; } + public required string RuleId { get; set; } [JsonPropertyName("trait_entity_type")] - public string? TraitEntityType { get; init; } + public string? TraitEntityType { get; set; } [JsonPropertyName("trait_id")] - public string? TraitId { get; init; } + public string? TraitId { get; set; } [JsonPropertyName("trait_value")] - public required string TraitValue { get; init; } + public required string TraitValue { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/RuleDetailResponseData.cs b/src/SchematicHQ.Client/Types/RuleDetailResponseData.cs index b2e2559..bab77ec 100644 --- a/src/SchematicHQ.Client/Types/RuleDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/RuleDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,40 +8,45 @@ namespace SchematicHQ.Client; public record RuleDetailResponseData { [JsonPropertyName("condition_groups")] - public IEnumerable ConditionGroups { get; init; } = + public IEnumerable ConditionGroups { get; set; } = new List(); [JsonPropertyName("conditions")] - public IEnumerable Conditions { get; init; } = + public IEnumerable Conditions { get; set; } = new List(); [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } [JsonPropertyName("priority")] - public required int Priority { get; init; } + public required int Priority { get; set; } [JsonPropertyName("rule_type")] - public required string RuleType { get; init; } + public required string RuleType { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("value")] - public required bool Value { get; init; } + public required bool Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/RuleResponseData.cs b/src/SchematicHQ.Client/Types/RuleResponseData.cs index fb2f44c..def11f0 100644 --- a/src/SchematicHQ.Client/Types/RuleResponseData.cs +++ b/src/SchematicHQ.Client/Types/RuleResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,32 +8,37 @@ namespace SchematicHQ.Client; public record RuleResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("flag_id")] - public string? FlagId { get; init; } + public string? FlagId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("plan_id")] - public string? PlanId { get; init; } + public string? PlanId { get; set; } [JsonPropertyName("priority")] - public required int Priority { get; init; } + public required int Priority { get; set; } [JsonPropertyName("rule_type")] - public required string RuleType { get; init; } + public required string RuleType { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("value")] - public required bool Value { get; init; } + public required bool Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/RulesDetailResponseData.cs b/src/SchematicHQ.Client/Types/RulesDetailResponseData.cs index ca61084..7499f34 100644 --- a/src/SchematicHQ.Client/Types/RulesDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/RulesDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -7,10 +7,15 @@ namespace SchematicHQ.Client; public record RulesDetailResponseData { - [JsonPropertyName("Flag")] - public FlagResponseData? Flag { get; init; } + [JsonPropertyName("flag")] + public FlagResponseData? Flag { get; set; } [JsonPropertyName("rules")] - public IEnumerable Rules { get; init; } = + public IEnumerable Rules { get; set; } = new List(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/SegmentStatusResp.cs b/src/SchematicHQ.Client/Types/SegmentStatusResp.cs index 81ec04c..32c1da7 100644 --- a/src/SchematicHQ.Client/Types/SegmentStatusResp.cs +++ b/src/SchematicHQ.Client/Types/SegmentStatusResp.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,11 +8,16 @@ namespace SchematicHQ.Client; public record SegmentStatusResp { [JsonPropertyName("connected")] - public required bool Connected { get; init; } + public required bool Connected { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("last_event_at")] - public DateTime? LastEventAt { get; init; } + public DateTime? LastEventAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/StripeEmbedInfo.cs b/src/SchematicHQ.Client/Types/StripeEmbedInfo.cs new file mode 100644 index 0000000..104f3dd --- /dev/null +++ b/src/SchematicHQ.Client/Types/StripeEmbedInfo.cs @@ -0,0 +1,20 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record StripeEmbedInfo +{ + [JsonPropertyName("publishable_key")] + public required string PublishableKey { get; set; } + + [JsonPropertyName("setup_intent_client_secret")] + public string? SetupIntentClientSecret { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/TemporaryAccessTokenResponseData.cs b/src/SchematicHQ.Client/Types/TemporaryAccessTokenResponseData.cs index d8ab557..b2a8bbb 100644 --- a/src/SchematicHQ.Client/Types/TemporaryAccessTokenResponseData.cs +++ b/src/SchematicHQ.Client/Types/TemporaryAccessTokenResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record TemporaryAccessTokenResponseData { [JsonPropertyName("api_key_id")] - public required string ApiKeyId { get; init; } + public required string ApiKeyId { get; set; } [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("expired_at")] - public required DateTime ExpiredAt { get; init; } + public required DateTime ExpiredAt { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("resource_type")] - public required string ResourceType { get; init; } + public required string ResourceType { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/UpdateAddOnRequestBody.cs b/src/SchematicHQ.Client/Types/UpdateAddOnRequestBody.cs new file mode 100644 index 0000000..380512c --- /dev/null +++ b/src/SchematicHQ.Client/Types/UpdateAddOnRequestBody.cs @@ -0,0 +1,20 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpdateAddOnRequestBody +{ + [JsonPropertyName("add_on_id")] + public required string AddOnId { get; set; } + + [JsonPropertyName("price_id")] + public required string PriceId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/UpdateEntitlementReqCommon.cs b/src/SchematicHQ.Client/Types/UpdateEntitlementReqCommon.cs new file mode 100644 index 0000000..65a51d6 --- /dev/null +++ b/src/SchematicHQ.Client/Types/UpdateEntitlementReqCommon.cs @@ -0,0 +1,32 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpdateEntitlementReqCommon +{ + [JsonPropertyName("metric_period")] + public UpdateEntitlementReqCommonMetricPeriod? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public UpdateEntitlementReqCommonMetricPeriodMonthReset? MetricPeriodMonthReset { get; set; } + + [JsonPropertyName("value_bool")] + public bool? ValueBool { get; set; } + + [JsonPropertyName("value_numeric")] + public int? ValueNumeric { get; set; } + + [JsonPropertyName("value_trait_id")] + public string? ValueTraitId { get; set; } + + [JsonPropertyName("value_type")] + public required UpdateEntitlementReqCommonValueType ValueType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/CreateReqCommonMetricPeriod.cs b/src/SchematicHQ.Client/Types/UpdateEntitlementReqCommonMetricPeriod.cs similarity index 61% rename from src/SchematicHQ.Client/Types/CreateReqCommonMetricPeriod.cs rename to src/SchematicHQ.Client/Types/UpdateEntitlementReqCommonMetricPeriod.cs index 1510087..04fc558 100644 --- a/src/SchematicHQ.Client/Types/CreateReqCommonMetricPeriod.cs +++ b/src/SchematicHQ.Client/Types/UpdateEntitlementReqCommonMetricPeriod.cs @@ -1,15 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] -public enum CreateReqCommonMetricPeriod +[JsonConverter(typeof(EnumSerializer))] +public enum UpdateEntitlementReqCommonMetricPeriod { + [EnumMember(Value = "all_time")] + AllTime, + [EnumMember(Value = "current_month")] CurrentMonth, @@ -17,5 +19,5 @@ public enum CreateReqCommonMetricPeriod CurrentWeek, [EnumMember(Value = "current_day")] - CurrentDay + CurrentDay, } diff --git a/src/SchematicHQ.Client/Types/UpdateEntitlementReqCommonMetricPeriodMonthReset.cs b/src/SchematicHQ.Client/Types/UpdateEntitlementReqCommonMetricPeriodMonthReset.cs new file mode 100644 index 0000000..58daa27 --- /dev/null +++ b/src/SchematicHQ.Client/Types/UpdateEntitlementReqCommonMetricPeriodMonthReset.cs @@ -0,0 +1,17 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(EnumSerializer))] +public enum UpdateEntitlementReqCommonMetricPeriodMonthReset +{ + [EnumMember(Value = "first_of_month")] + FirstOfMonth, + + [EnumMember(Value = "billing_cycle")] + BillingCycle, +} diff --git a/src/SchematicHQ.Client/Types/CreateReqCommonValueType.cs b/src/SchematicHQ.Client/Types/UpdateEntitlementReqCommonValueType.cs similarity index 69% rename from src/SchematicHQ.Client/Types/CreateReqCommonValueType.cs rename to src/SchematicHQ.Client/Types/UpdateEntitlementReqCommonValueType.cs index d7b21c2..90478c2 100644 --- a/src/SchematicHQ.Client/Types/CreateReqCommonValueType.cs +++ b/src/SchematicHQ.Client/Types/UpdateEntitlementReqCommonValueType.cs @@ -1,14 +1,13 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] -public enum CreateReqCommonValueType +[JsonConverter(typeof(EnumSerializer))] +public enum UpdateEntitlementReqCommonValueType { [EnumMember(Value = "boolean")] Boolean, @@ -20,5 +19,5 @@ public enum CreateReqCommonValueType Trait, [EnumMember(Value = "unlimited")] - Unlimited + Unlimited, } diff --git a/src/SchematicHQ.Client/Types/UpdatePayInAdvanceRequestBody.cs b/src/SchematicHQ.Client/Types/UpdatePayInAdvanceRequestBody.cs new file mode 100644 index 0000000..40f466a --- /dev/null +++ b/src/SchematicHQ.Client/Types/UpdatePayInAdvanceRequestBody.cs @@ -0,0 +1,20 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UpdatePayInAdvanceRequestBody +{ + [JsonPropertyName("price_id")] + public required string PriceId { get; set; } + + [JsonPropertyName("quantity")] + public required int Quantity { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/UpdateReqCommon.cs b/src/SchematicHQ.Client/Types/UpdateReqCommon.cs deleted file mode 100644 index 385b76c..0000000 --- a/src/SchematicHQ.Client/Types/UpdateReqCommon.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Text.Json.Serialization; -using SchematicHQ.Client; - -#nullable enable - -namespace SchematicHQ.Client; - -public record UpdateReqCommon -{ - [JsonPropertyName("metric_period")] - public UpdateReqCommonMetricPeriod? MetricPeriod { get; init; } - - [JsonPropertyName("value_bool")] - public bool? ValueBool { get; init; } - - [JsonPropertyName("value_numeric")] - public int? ValueNumeric { get; init; } - - [JsonPropertyName("value_trait_id")] - public string? ValueTraitId { get; init; } - - [JsonPropertyName("value_type")] - public required UpdateReqCommonValueType ValueType { get; init; } -} diff --git a/src/SchematicHQ.Client/Types/UpdateRuleRequestBody.cs b/src/SchematicHQ.Client/Types/UpdateRuleRequestBody.cs index 6f8eca8..cb5703b 100644 --- a/src/SchematicHQ.Client/Types/UpdateRuleRequestBody.cs +++ b/src/SchematicHQ.Client/Types/UpdateRuleRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,19 +8,24 @@ namespace SchematicHQ.Client; public record UpdateRuleRequestBody { [JsonPropertyName("condition_groups")] - public IEnumerable ConditionGroups { get; init; } = + public IEnumerable ConditionGroups { get; set; } = new List(); [JsonPropertyName("conditions")] - public IEnumerable Conditions { get; init; } = + public IEnumerable Conditions { get; set; } = new List(); [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("priority")] - public required int Priority { get; init; } + public required int Priority { get; set; } [JsonPropertyName("value")] - public required bool Value { get; init; } + public required bool Value { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/UpsertCompanyRequestBody.cs b/src/SchematicHQ.Client/Types/UpsertCompanyRequestBody.cs index b60554a..4cbd42c 100644 --- a/src/SchematicHQ.Client/Types/UpsertCompanyRequestBody.cs +++ b/src/SchematicHQ.Client/Types/UpsertCompanyRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,23 +11,28 @@ public record UpsertCompanyRequestBody /// If you know the Schematic ID, you can use that here instead of keys /// [JsonPropertyName("id")] - public string? Id { get; init; } + public string? Id { get; set; } [JsonPropertyName("keys")] - public Dictionary Keys { get; init; } = new Dictionary(); + public Dictionary Keys { get; set; } = new Dictionary(); [JsonPropertyName("last_seen_at")] - public DateTime? LastSeenAt { get; init; } + public DateTime? LastSeenAt { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } /// /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary? Traits { get; init; } + public Dictionary? Traits { get; set; } [JsonPropertyName("update_only")] - public bool? UpdateOnly { get; init; } + public bool? UpdateOnly { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/UpsertTraitRequestBody.cs b/src/SchematicHQ.Client/Types/UpsertTraitRequestBody.cs index 407a1bb..a747949 100644 --- a/src/SchematicHQ.Client/Types/UpsertTraitRequestBody.cs +++ b/src/SchematicHQ.Client/Types/UpsertTraitRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,29 +11,34 @@ public record UpsertTraitRequestBody /// Amount to increment the trait by (positive or negative) /// [JsonPropertyName("incr")] - public int? Incr { get; init; } + public int? Incr { get; set; } /// /// Key/value pairs too identify a company or user /// [JsonPropertyName("keys")] - public Dictionary Keys { get; init; } = new Dictionary(); + public Dictionary Keys { get; set; } = new Dictionary(); /// /// Value to set the trait to /// [JsonPropertyName("set")] - public string? Set { get; init; } + public string? Set { get; set; } /// /// Name of the trait to update /// [JsonPropertyName("trait")] - public required string Trait { get; init; } + public required string Trait { get; set; } /// /// Unless this is set, the company or user will be created if it does not already exist /// [JsonPropertyName("update_only")] - public bool? UpdateOnly { get; init; } + public bool? UpdateOnly { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/UpsertUserRequestBody.cs b/src/SchematicHQ.Client/Types/UpsertUserRequestBody.cs index 300be24..0c98de8 100644 --- a/src/SchematicHQ.Client/Types/UpsertUserRequestBody.cs +++ b/src/SchematicHQ.Client/Types/UpsertUserRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,35 +11,40 @@ public record UpsertUserRequestBody /// Optionally specify company using key/value pairs /// [JsonPropertyName("company")] - public Dictionary Company { get; init; } = new Dictionary(); + public Dictionary Company { get; set; } = new Dictionary(); /// /// Optionally specify company using Schematic company ID /// [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } /// /// If you know the Schematic ID, you can use that here instead of keys /// [JsonPropertyName("id")] - public string? Id { get; init; } + public string? Id { get; set; } [JsonPropertyName("keys")] - public Dictionary Keys { get; init; } = new Dictionary(); + public Dictionary Keys { get; set; } = new Dictionary(); [JsonPropertyName("last_seen_at")] - public DateTime? LastSeenAt { get; init; } + public DateTime? LastSeenAt { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } /// /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary? Traits { get; init; } + public Dictionary? Traits { get; set; } [JsonPropertyName("update_only")] - public bool? UpdateOnly { get; init; } + public bool? UpdateOnly { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/UpsertUserSubRequestBody.cs b/src/SchematicHQ.Client/Types/UpsertUserSubRequestBody.cs index 45de8b3..90c1e72 100644 --- a/src/SchematicHQ.Client/Types/UpsertUserSubRequestBody.cs +++ b/src/SchematicHQ.Client/Types/UpsertUserSubRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,29 +11,34 @@ public record UpsertUserSubRequestBody /// Optionally specify company using Schematic company ID /// [JsonPropertyName("company_id")] - public string? CompanyId { get; init; } + public string? CompanyId { get; set; } /// /// If you know the Schematic ID, you can use that here instead of keys /// [JsonPropertyName("id")] - public string? Id { get; init; } + public string? Id { get; set; } [JsonPropertyName("keys")] - public Dictionary Keys { get; init; } = new Dictionary(); + public Dictionary Keys { get; set; } = new Dictionary(); [JsonPropertyName("last_seen_at")] - public DateTime? LastSeenAt { get; init; } + public DateTime? LastSeenAt { get; set; } [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } /// /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary? Traits { get; init; } + public Dictionary? Traits { get; set; } [JsonPropertyName("update_only")] - public bool? UpdateOnly { get; init; } + public bool? UpdateOnly { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/UsageBasedEntitlementResponseData.cs b/src/SchematicHQ.Client/Types/UsageBasedEntitlementResponseData.cs new file mode 100644 index 0000000..673467e --- /dev/null +++ b/src/SchematicHQ.Client/Types/UsageBasedEntitlementResponseData.cs @@ -0,0 +1,38 @@ +using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +public record UsageBasedEntitlementResponseData +{ + [JsonPropertyName("feature_id")] + public required string FeatureId { get; set; } + + [JsonPropertyName("metered_price")] + public BillingPriceView? MeteredPrice { get; set; } + + [JsonPropertyName("metric_period")] + public string? MetricPeriod { get; set; } + + [JsonPropertyName("metric_period_month_reset")] + public string? MetricPeriodMonthReset { get; set; } + + [JsonPropertyName("price_behavior")] + public string? PriceBehavior { get; set; } + + [JsonPropertyName("value_bool")] + public bool? ValueBool { get; set; } + + [JsonPropertyName("value_numeric")] + public int? ValueNumeric { get; set; } + + [JsonPropertyName("value_type")] + public required string ValueType { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/UserDetailResponseData.cs b/src/SchematicHQ.Client/Types/UserDetailResponseData.cs index 2895a1e..60b5e29 100644 --- a/src/SchematicHQ.Client/Types/UserDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/UserDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,38 +8,43 @@ namespace SchematicHQ.Client; public record UserDetailResponseData { [JsonPropertyName("company_memberships")] - public IEnumerable CompanyMemberships { get; init; } = + public IEnumerable CompanyMemberships { get; set; } = new List(); [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("entity_traits")] - public IEnumerable EntityTraits { get; init; } = + public IEnumerable EntityTraits { get; set; } = new List(); [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("keys")] - public IEnumerable Keys { get; init; } = + public IEnumerable Keys { get; set; } = new List(); [JsonPropertyName("last_seen_at")] - public DateTime? LastSeenAt { get; init; } + public DateTime? LastSeenAt { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } /// /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary? Traits { get; init; } + public Dictionary? Traits { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/UserResponseData.cs b/src/SchematicHQ.Client/Types/UserResponseData.cs index 5e56be1..9ccee4d 100644 --- a/src/SchematicHQ.Client/Types/UserResponseData.cs +++ b/src/SchematicHQ.Client/Types/UserResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,20 +8,25 @@ namespace SchematicHQ.Client; public record UserResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("environment_id")] - public required string EnvironmentId { get; init; } + public required string EnvironmentId { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("last_seen_at")] - public DateTime? LastSeenAt { get; init; } + public DateTime? LastSeenAt { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/WebhookEventDetailResponseData.cs b/src/SchematicHQ.Client/Types/WebhookEventDetailResponseData.cs index c00cf25..7dcaede 100644 --- a/src/SchematicHQ.Client/Types/WebhookEventDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/WebhookEventDetailResponseData.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,32 +8,37 @@ namespace SchematicHQ.Client; public record WebhookEventDetailResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("payload")] - public string? Payload { get; init; } + public string? Payload { get; set; } [JsonPropertyName("request_type")] - public required string RequestType { get; init; } + public required string RequestType { get; set; } [JsonPropertyName("response_code")] - public int? ResponseCode { get; init; } + public int? ResponseCode { get; set; } [JsonPropertyName("sent_at")] - public DateTime? SentAt { get; init; } + public DateTime? SentAt { get; set; } [JsonPropertyName("status")] - public required string Status { get; init; } + public required string Status { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("webhook")] - public WebhookResponseData? Webhook { get; init; } + public WebhookResponseData? Webhook { get; set; } [JsonPropertyName("webhook_id")] - public required string WebhookId { get; init; } + public required string WebhookId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/WebhookEventResponseData.cs b/src/SchematicHQ.Client/Types/WebhookEventResponseData.cs index fbf9738..992f728 100644 --- a/src/SchematicHQ.Client/Types/WebhookEventResponseData.cs +++ b/src/SchematicHQ.Client/Types/WebhookEventResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,29 +8,34 @@ namespace SchematicHQ.Client; public record WebhookEventResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("payload")] - public string? Payload { get; init; } + public string? Payload { get; set; } [JsonPropertyName("request_type")] - public required string RequestType { get; init; } + public required string RequestType { get; set; } [JsonPropertyName("response_code")] - public int? ResponseCode { get; init; } + public int? ResponseCode { get; set; } [JsonPropertyName("sent_at")] - public DateTime? SentAt { get; init; } + public DateTime? SentAt { get; set; } [JsonPropertyName("status")] - public required string Status { get; init; } + public required string Status { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("webhook_id")] - public required string WebhookId { get; init; } + public required string WebhookId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Types/WebhookResponseData.cs b/src/SchematicHQ.Client/Types/WebhookResponseData.cs index a279248..de8d313 100644 --- a/src/SchematicHQ.Client/Types/WebhookResponseData.cs +++ b/src/SchematicHQ.Client/Types/WebhookResponseData.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record WebhookResponseData { [JsonPropertyName("created_at")] - public required DateTime CreatedAt { get; init; } + public required DateTime CreatedAt { get; set; } [JsonPropertyName("id")] - public required string Id { get; init; } + public required string Id { get; set; } [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("request_types")] - public IEnumerable RequestTypes { get; init; } = new List(); + public IEnumerable RequestTypes { get; set; } = new List(); [JsonPropertyName("status")] - public required string Status { get; init; } + public required string Status { get; set; } [JsonPropertyName("updated_at")] - public required DateTime UpdatedAt { get; init; } + public required DateTime UpdatedAt { get; set; } [JsonPropertyName("url")] - public required string Url { get; init; } + public required string Url { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Requests/CountWebhookEventsRequest.cs b/src/SchematicHQ.Client/Webhooks/Requests/CountWebhookEventsRequest.cs index d0091e2..0fe719a 100644 --- a/src/SchematicHQ.Client/Webhooks/Requests/CountWebhookEventsRequest.cs +++ b/src/SchematicHQ.Client/Webhooks/Requests/CountWebhookEventsRequest.cs @@ -1,20 +1,29 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountWebhookEventsRequest { - public string? WebhookId { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Ids { get; init; } + public string? Q { get; set; } - public string? Q { get; init; } + public string? WebhookId { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Requests/CountWebhooksRequest.cs b/src/SchematicHQ.Client/Webhooks/Requests/CountWebhooksRequest.cs index 1c104c3..b493bdd 100644 --- a/src/SchematicHQ.Client/Webhooks/Requests/CountWebhooksRequest.cs +++ b/src/SchematicHQ.Client/Webhooks/Requests/CountWebhooksRequest.cs @@ -1,16 +1,25 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record CountWebhooksRequest { - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Requests/CreateWebhookRequestBody.cs b/src/SchematicHQ.Client/Webhooks/Requests/CreateWebhookRequestBody.cs index a2c210b..9d98f99 100644 --- a/src/SchematicHQ.Client/Webhooks/Requests/CreateWebhookRequestBody.cs +++ b/src/SchematicHQ.Client/Webhooks/Requests/CreateWebhookRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,12 +8,17 @@ namespace SchematicHQ.Client; public record CreateWebhookRequestBody { [JsonPropertyName("name")] - public required string Name { get; init; } + public required string Name { get; set; } [JsonPropertyName("request_types")] - public IEnumerable RequestTypes { get; init; } = + public IEnumerable RequestTypes { get; set; } = new List(); [JsonPropertyName("url")] - public required string Url { get; init; } + public required string Url { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Requests/ListWebhookEventsRequest.cs b/src/SchematicHQ.Client/Webhooks/Requests/ListWebhookEventsRequest.cs index 4311988..bf847c6 100644 --- a/src/SchematicHQ.Client/Webhooks/Requests/ListWebhookEventsRequest.cs +++ b/src/SchematicHQ.Client/Webhooks/Requests/ListWebhookEventsRequest.cs @@ -1,20 +1,29 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListWebhookEventsRequest { - public string? WebhookId { get; init; } + public IEnumerable Ids { get; set; } = new List(); - public string? Ids { get; init; } + public string? Q { get; set; } - public string? Q { get; init; } + public string? WebhookId { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Requests/ListWebhooksRequest.cs b/src/SchematicHQ.Client/Webhooks/Requests/ListWebhooksRequest.cs index 02222b0..0f3fc25 100644 --- a/src/SchematicHQ.Client/Webhooks/Requests/ListWebhooksRequest.cs +++ b/src/SchematicHQ.Client/Webhooks/Requests/ListWebhooksRequest.cs @@ -1,16 +1,25 @@ +using SchematicHQ.Client.Core; + +#nullable enable + namespace SchematicHQ.Client; public record ListWebhooksRequest { - public string? Q { get; init; } + public string? Q { get; set; } /// /// Page limit (default 100) /// - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// - public int? Offset { get; init; } + public int? Offset { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Requests/UpdateWebhookRequestBody.cs b/src/SchematicHQ.Client/Webhooks/Requests/UpdateWebhookRequestBody.cs index fdd980b..ad96661 100644 --- a/src/SchematicHQ.Client/Webhooks/Requests/UpdateWebhookRequestBody.cs +++ b/src/SchematicHQ.Client/Webhooks/Requests/UpdateWebhookRequestBody.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,14 +8,19 @@ namespace SchematicHQ.Client; public record UpdateWebhookRequestBody { [JsonPropertyName("name")] - public string? Name { get; init; } + public string? Name { get; set; } [JsonPropertyName("request_types")] - public IEnumerable? RequestTypes { get; init; } + public IEnumerable? RequestTypes { get; set; } [JsonPropertyName("status")] - public UpdateWebhookRequestBodyStatus? Status { get; init; } + public UpdateWebhookRequestBodyStatus? Status { get; set; } [JsonPropertyName("url")] - public string? Url { get; init; } + public string? Url { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsParams.cs b/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsParams.cs index 29564ff..b39d08b 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsParams.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record CountWebhookEventsParams { [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } [JsonPropertyName("webhook_id")] - public string? WebhookId { get; init; } + public string? WebhookId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsResponse.cs index 3481dbd..0ba7914 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountWebhookEventsResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountWebhookEventsParams Params { get; init; } + public required CountWebhookEventsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/CountWebhooksParams.cs b/src/SchematicHQ.Client/Webhooks/Types/CountWebhooksParams.cs index 0f8f41d..9966032 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/CountWebhooksParams.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/CountWebhooksParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,14 +11,19 @@ public record CountWebhooksParams /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/CountWebhooksResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/CountWebhooksResponse.cs index 4f7c98e..3411404 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/CountWebhooksResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/CountWebhooksResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CountWebhooksResponse { [JsonPropertyName("data")] - public required CountResponse Data { get; init; } + public required CountResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public required CountWebhooksParams Params { get; init; } + public required CountWebhooksParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookRequestBodyRequestTypesItem.cs b/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookRequestBodyRequestTypesItem.cs index 270eda3..6581237 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookRequestBodyRequestTypesItem.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookRequestBodyRequestTypesItem.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum CreateWebhookRequestBodyRequestTypesItem { [EnumMember(Value = "company.updated")] @@ -77,5 +76,5 @@ public enum CreateWebhookRequestBodyRequestTypesItem FlagDeleted, [EnumMember(Value = "test.send")] - TestSend + TestSend, } diff --git a/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookResponse.cs index 15166dc..a648419 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record CreateWebhookResponse { [JsonPropertyName("data")] - public required WebhookResponseData Data { get; init; } + public required WebhookResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/DeleteWebhookResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/DeleteWebhookResponse.cs index b035e94..642c984 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/DeleteWebhookResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/DeleteWebhookResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record DeleteWebhookResponse { [JsonPropertyName("data")] - public required DeleteResponse Data { get; init; } + public required DeleteResponse Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/GetWebhookEventResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/GetWebhookEventResponse.cs index b637372..6e4443d 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/GetWebhookEventResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/GetWebhookEventResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetWebhookEventResponse { [JsonPropertyName("data")] - public required WebhookEventDetailResponseData Data { get; init; } + public required WebhookEventDetailResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/GetWebhookResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/GetWebhookResponse.cs index 44398c2..b5985ee 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/GetWebhookResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/GetWebhookResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record GetWebhookResponse { [JsonPropertyName("data")] - public required WebhookResponseData Data { get; init; } + public required WebhookResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsParams.cs b/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsParams.cs index c83d011..7c12f12 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsParams.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -7,23 +8,28 @@ namespace SchematicHQ.Client; public record ListWebhookEventsParams { [JsonPropertyName("ids")] - public IEnumerable? Ids { get; init; } + public IEnumerable? Ids { get; set; } /// /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } [JsonPropertyName("webhook_id")] - public string? WebhookId { get; init; } + public string? WebhookId { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsResponse.cs index f753d52..675e319 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,12 +11,17 @@ public record ListWebhookEventsResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListWebhookEventsParams Params { get; init; } + public required ListWebhookEventsParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksParams.cs b/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksParams.cs index 4f5c8c2..f23a154 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksParams.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client.Core; #nullable enable @@ -10,14 +11,19 @@ public record ListWebhooksParams /// Page limit (default 100) /// [JsonPropertyName("limit")] - public int? Limit { get; init; } + public int? Limit { get; set; } /// /// Page offset (default 0) /// [JsonPropertyName("offset")] - public int? Offset { get; init; } + public int? Offset { get; set; } [JsonPropertyName("q")] - public string? Q { get; init; } + public string? Q { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksResponse.cs index 5ef19ee..0400ede 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -11,11 +11,16 @@ public record ListWebhooksResponse /// The returned resources /// [JsonPropertyName("data")] - public IEnumerable Data { get; init; } = new List(); + public IEnumerable Data { get; set; } = new List(); /// /// Input parameters /// [JsonPropertyName("params")] - public required ListWebhooksParams Params { get; init; } + public required ListWebhooksParams Params { get; set; } + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyRequestTypesItem.cs b/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyRequestTypesItem.cs index 3e49ea2..3c6223d 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyRequestTypesItem.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyRequestTypesItem.cs @@ -1,13 +1,12 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdateWebhookRequestBodyRequestTypesItem { [EnumMember(Value = "company.updated")] @@ -77,5 +76,5 @@ public enum UpdateWebhookRequestBodyRequestTypesItem FlagDeleted, [EnumMember(Value = "test.send")] - TestSend + TestSend, } diff --git a/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyStatus.cs b/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyStatus.cs index 7e4b8ce..64f07ce 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyStatus.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyStatus.cs @@ -1,18 +1,17 @@ using System.Runtime.Serialization; using System.Text.Json.Serialization; -using SchematicHQ.Client; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -[JsonConverter(typeof(StringEnumSerializer))] +[JsonConverter(typeof(EnumSerializer))] public enum UpdateWebhookRequestBodyStatus { [EnumMember(Value = "active")] Active, [EnumMember(Value = "inactive")] - Inactive + Inactive, } diff --git a/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookResponse.cs index c788ff3..abeec78 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookResponse.cs @@ -1,5 +1,5 @@ using System.Text.Json.Serialization; -using SchematicHQ.Client; +using SchematicHQ.Client.Core; #nullable enable @@ -8,11 +8,16 @@ namespace SchematicHQ.Client; public record UpdateWebhookResponse { [JsonPropertyName("data")] - public required WebhookResponseData Data { get; init; } + public required WebhookResponseData Data { get; set; } /// /// Input parameters /// [JsonPropertyName("params")] - public Dictionary Params { get; init; } = new Dictionary(); + public Dictionary Params { get; set; } = new Dictionary(); + + public override string ToString() + { + return JsonUtils.Serialize(this); + } } diff --git a/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs b/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs index 1538de3..9121fc6 100644 --- a/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs +++ b/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs @@ -1,38 +1,42 @@ using System.Net.Http; using System.Text.Json; -using SchematicHQ.Client; +using System.Threading; using SchematicHQ.Client.Core; #nullable enable namespace SchematicHQ.Client; -public class WebhooksClient +public partial class WebhooksClient { private RawClient _client; - public WebhooksClient(RawClient client) + internal WebhooksClient(RawClient client) { _client = client; } + /// + /// + /// await client.Webhooks.ListWebhookEventsAsync(new ListWebhookEventsRequest()); + /// + /// public async Task ListWebhookEventsAsync( - ListWebhookEventsRequest request + ListWebhookEventsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { - var _query = new Dictionary() { }; - if (request.WebhookId != null) - { - _query["webhook_id"] = request.WebhookId; - } - if (request.Ids != null) - { - _query["ids"] = request.Ids; - } + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.Q != null) { _query["q"] = request.Q; } + if (request.WebhookId != null) + { + _query["webhook_id"] = request.WebhookId; + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -44,53 +48,132 @@ ListWebhookEventsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "webhook-events", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetWebhookEventAsync(string webhookEventId) + /// + /// + /// await client.Webhooks.GetWebhookEventAsync("webhook_event_id"); + /// + /// + public async Task GetWebhookEventAsync( + string webhookEventId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, - Path = $"webhook-events/{webhookEventId}" - } + Path = $"webhook-events/{webhookEventId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); - } - public async Task CountWebhookEventsAsync( - CountWebhookEventsRequest request - ) - { - var _query = new Dictionary() { }; - if (request.WebhookId != null) + try { - _query["webhook_id"] = request.WebhookId; + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - if (request.Ids != null) + catch (JsonException) { - _query["ids"] = request.Ids; + // unable to map error response, throwing generic error } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + + /// + /// + /// await client.Webhooks.CountWebhookEventsAsync(new CountWebhookEventsRequest()); + /// + /// + public async Task CountWebhookEventsAsync( + CountWebhookEventsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _query = new Dictionary(); + _query["ids"] = request.Ids; if (request.Q != null) { _query["q"] = request.Q; } + if (request.WebhookId != null) + { + _query["webhook_id"] = request.WebhookId; + } if (request.Limit != null) { _query["limit"] = request.Limit.ToString(); @@ -102,22 +185,64 @@ CountWebhookEventsRequest request var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "webhook-events/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task ListWebhooksAsync(ListWebhooksRequest request) + /// + /// + /// await client.Webhooks.ListWebhooksAsync(new ListWebhooksRequest()); + /// + /// + public async Task ListWebhooksAsync( + ListWebhooksRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.Q != null) { _query["q"] = request.Q; @@ -133,91 +258,317 @@ public async Task ListWebhooksAsync(ListWebhooksRequest re var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "webhooks", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CreateWebhookAsync(CreateWebhookRequestBody request) + /// + /// + /// await client.Webhooks.CreateWebhookAsync( + /// new CreateWebhookRequestBody + /// { + /// Name = "name", + /// RequestTypes = new List<CreateWebhookRequestBodyRequestTypesItem>() + /// { + /// CreateWebhookRequestBodyRequestTypesItem.CompanyUpdated, + /// }, + /// Url = "url", + /// } + /// ); + /// + /// + public async Task CreateWebhookAsync( + CreateWebhookRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Post, Path = "webhooks", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task GetWebhookAsync(string webhookId) + /// + /// + /// await client.Webhooks.GetWebhookAsync("webhook_id"); + /// + /// + public async Task GetWebhookAsync( + string webhookId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( - new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"webhooks/{webhookId}" } + new RawClient.JsonApiRequest + { + BaseUrl = _client.Options.BaseUrl, + Method = HttpMethod.Get, + Path = $"webhooks/{webhookId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } } - throw new Exception(responseBody); + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } + /// + /// + /// await client.Webhooks.UpdateWebhookAsync("webhook_id", new UpdateWebhookRequestBody()); + /// + /// public async Task UpdateWebhookAsync( string webhookId, - UpdateWebhookRequestBody request + UpdateWebhookRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Put, Path = $"webhooks/{webhookId}", - Body = request - } + Body = request, + ContentType = "application/json", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task DeleteWebhookAsync(string webhookId) + /// + /// + /// await client.Webhooks.DeleteWebhookAsync("webhook_id"); + /// + /// + public async Task DeleteWebhookAsync( + string webhookId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Delete, - Path = $"webhooks/{webhookId}" - } + Path = $"webhooks/{webhookId}", + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } } - throw new Exception(responseBody); + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } - public async Task CountWebhooksAsync(CountWebhooksRequest request) + /// + /// + /// await client.Webhooks.CountWebhooksAsync(new CountWebhooksRequest()); + /// + /// + public async Task CountWebhooksAsync( + CountWebhooksRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) { - var _query = new Dictionary() { }; + var _query = new Dictionary(); if (request.Q != null) { _query["q"] = request.Q; @@ -233,16 +584,49 @@ public async Task CountWebhooksAsync(CountWebhooksRequest var response = await _client.MakeRequestAsync( new RawClient.JsonApiRequest { + BaseUrl = _client.Options.BaseUrl, Method = HttpMethod.Get, Path = "webhooks/count", - Query = _query - } + Query = _query, + Options = options, + }, + cancellationToken ); var responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode is >= 200 and < 400) { - return JsonSerializer.Deserialize(responseBody)!; + try + { + return JsonUtils.Deserialize(responseBody)!; + } + catch (JsonException e) + { + throw new SchematicApiException("Failed to deserialize response", e); + } + } + + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError(JsonUtils.Deserialize(responseBody)); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error } - throw new Exception(responseBody); + throw new SchematicApiApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); } }