diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2f37018..a973c526 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET uses: actions/setup-dotnet@v3 @@ -39,7 +39,7 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET uses: actions/setup-dotnet@v3 @@ -55,7 +55,7 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/courier-csharp' && 'depot-windows-2022' || 'windows-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET uses: actions/setup-dotnet@v5 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index b29b3b64..41010749 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "5.2.0" + ".": "5.3.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 92aa6915..98ae2b6d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 78 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-e3e54d99e2a73fd87519270f2685131050d342e86a4e96130247b854deae5c20.yml -openapi_spec_hash: 897a3fbee24f24d021d6af0df480220c -config_hash: 66a5c28bb74d78454456d9ce7d1c0a0c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9a543994a29d199daec5228c34a90caf017db9a1084289f58645c6849b606940.yml +openapi_spec_hash: f2f64858daadb0a1978b0e4a4d8ed149 +config_hash: ba6cf7f4dbdf6b9d03c6962dd1770569 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e6374ca..919a05f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## 5.3.0 (2026-01-17) + +Full Changelog: [v5.2.0...v5.3.0](https://github.com/trycourier/courier-csharp/compare/v5.2.0...v5.3.0) + +### Features + +* **client:** add `ToString` to `ApiEnum` ([afae7cb](https://github.com/trycourier/courier-csharp/commit/afae7cbcdd55579b25181b4a18b219516df860ac)) +* **client:** add Equals and ToString to params ([111ddf3](https://github.com/trycourier/courier-csharp/commit/111ddf3b539a5019db0ec88157585dd8fbdc4389)) + + +### Bug Fixes + +* **ci:** don't throw an error about missing lsof ([1677a29](https://github.com/trycourier/courier-csharp/commit/1677a29c8ca275b6a612623e9a709acbd28f29cb)) + + +### Chores + +* **internal:** simplify imports ([85e6232](https://github.com/trycourier/courier-csharp/commit/85e6232e04704906c159b7ef8f121d032a7ced57)) +* **internal:** update `actions/checkout` version ([853c44c](https://github.com/trycourier/courier-csharp/commit/853c44cf00ccd9a0731569edd1386b6e7c6936ce)) + ## 5.2.0 (2026-01-14) Full Changelog: [v5.1.0...v5.2.0](https://github.com/trycourier/courier-csharp/compare/v5.1.0...v5.2.0) diff --git a/scripts/test b/scripts/test index a562fa22..f47e4b7f 100755 --- a/scripts/test +++ b/scripts/test @@ -14,6 +14,10 @@ function prism_is_running() { } kill_server_on_port() { + if [ ! "$(which lsof)" ]; then + echo "Warning: lsof not found. Prism will not be killed." + return 0 + fi pids=$(lsof -t -i tcp:"$1" || echo "") if [ "$pids" != "" ]; then kill "$pids" diff --git a/src/Courier.Tests/Models/Audiences/AudienceDeleteParamsTest.cs b/src/Courier.Tests/Models/Audiences/AudienceDeleteParamsTest.cs index 6cf4ea2e..8e9d6f2b 100644 --- a/src/Courier.Tests/Models/Audiences/AudienceDeleteParamsTest.cs +++ b/src/Courier.Tests/Models/Audiences/AudienceDeleteParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/audiences/audience_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AudienceDeleteParams { AudienceID = "audience_id" }; + + AudienceDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Audiences/AudienceListMembersParamsTest.cs b/src/Courier.Tests/Models/Audiences/AudienceListMembersParamsTest.cs index 1fbc080c..faec6765 100644 --- a/src/Courier.Tests/Models/Audiences/AudienceListMembersParamsTest.cs +++ b/src/Courier.Tests/Models/Audiences/AudienceListMembersParamsTest.cs @@ -60,4 +60,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AudienceListMembersParams + { + AudienceID = "audience_id", + Cursor = "cursor", + }; + + AudienceListMembersParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Audiences/AudienceListParamsTest.cs b/src/Courier.Tests/Models/Audiences/AudienceListParamsTest.cs index 3a72279e..0b70a7f8 100644 --- a/src/Courier.Tests/Models/Audiences/AudienceListParamsTest.cs +++ b/src/Courier.Tests/Models/Audiences/AudienceListParamsTest.cs @@ -42,4 +42,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/audiences?cursor=cursor"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AudienceListParams { Cursor = "cursor" }; + + AudienceListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Audiences/AudienceRetrieveParamsTest.cs b/src/Courier.Tests/Models/Audiences/AudienceRetrieveParamsTest.cs index 45e4558b..48ddcae4 100644 --- a/src/Courier.Tests/Models/Audiences/AudienceRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Audiences/AudienceRetrieveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/audiences/audience_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AudienceRetrieveParams { AudienceID = "audience_id" }; + + AudienceRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Audiences/AudienceUpdateParamsTest.cs b/src/Courier.Tests/Models/Audiences/AudienceUpdateParamsTest.cs index 0635e9d4..2ea048ac 100644 --- a/src/Courier.Tests/Models/Audiences/AudienceUpdateParamsTest.cs +++ b/src/Courier.Tests/Models/Audiences/AudienceUpdateParamsTest.cs @@ -101,6 +101,33 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/audiences/audience_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AudienceUpdateParams + { + AudienceID = "audience_id", + Description = "description", + Filter = new( + [ + new() + { + Operator = "operator", + Filters = [], + Path = "path", + Value = "value", + }, + ] + ), + Name = "name", + Operator = Operator.And, + }; + + AudienceUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class OperatorTest : TestBase diff --git a/src/Courier.Tests/Models/AuditEvents/AuditEventListParamsTest.cs b/src/Courier.Tests/Models/AuditEvents/AuditEventListParamsTest.cs index 0cf83378..fc71d071 100644 --- a/src/Courier.Tests/Models/AuditEvents/AuditEventListParamsTest.cs +++ b/src/Courier.Tests/Models/AuditEvents/AuditEventListParamsTest.cs @@ -42,4 +42,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/audit-events?cursor=cursor"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AuditEventListParams { Cursor = "cursor" }; + + AuditEventListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/AuditEvents/AuditEventRetrieveParamsTest.cs b/src/Courier.Tests/Models/AuditEvents/AuditEventRetrieveParamsTest.cs index 632c4f8d..16c4d86f 100644 --- a/src/Courier.Tests/Models/AuditEvents/AuditEventRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/AuditEvents/AuditEventRetrieveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/audit-events/audit-event-id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AuditEventRetrieveParams { AuditEventID = "audit-event-id" }; + + AuditEventRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Auth/AuthIssueTokenParamsTest.cs b/src/Courier.Tests/Models/Auth/AuthIssueTokenParamsTest.cs index 4dda5b61..f4ccb67a 100644 --- a/src/Courier.Tests/Models/Auth/AuthIssueTokenParamsTest.cs +++ b/src/Courier.Tests/Models/Auth/AuthIssueTokenParamsTest.cs @@ -37,4 +37,19 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/auth/issue-token"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AuthIssueTokenParams + { + ExpiresIn = "$YOUR_NUMBER days", + Scope = + "user_id:$YOUR_USER_ID write:user-tokens inbox:read:messages inbox:write:events read:preferences write:preferences read:brands", + }; + + AuthIssueTokenParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Automations/AutomationListParamsTest.cs b/src/Courier.Tests/Models/Automations/AutomationListParamsTest.cs index 930d51ed..8fc49b22 100644 --- a/src/Courier.Tests/Models/Automations/AutomationListParamsTest.cs +++ b/src/Courier.Tests/Models/Automations/AutomationListParamsTest.cs @@ -67,6 +67,20 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Automations::AutomationListParams + { + Cursor = "cursor", + Version = Automations::Version.Published, + }; + + Automations::AutomationListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class VersionTest : TestBase diff --git a/src/Courier.Tests/Models/Automations/Invoke/InvokeInvokeAdHocParamsTest.cs b/src/Courier.Tests/Models/Automations/Invoke/InvokeInvokeAdHocParamsTest.cs index 385a8e8a..a2975273 100644 --- a/src/Courier.Tests/Models/Automations/Invoke/InvokeInvokeAdHocParamsTest.cs +++ b/src/Courier.Tests/Models/Automations/Invoke/InvokeInvokeAdHocParamsTest.cs @@ -256,6 +256,57 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/automations/invoke"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Invoke::InvokeInvokeAdHocParams + { + Automation = new() + { + Steps = + [ + new Invoke::AutomationDelayStep() + { + Action = Invoke::Action.Delay, + Duration = "duration", + Until = "20240408T080910.123", + }, + new Invoke::AutomationSendStep() + { + Action = Invoke::AutomationSendStepAction.Send, + Brand = "brand", + Data = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Profile = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Recipient = "recipient", + Template = "64TP5HKPFTM8VTK1Y75SJDQX9JK0", + }, + ], + CancelationToken = "delay-send--user-yes--abc-123", + }, + Brand = "brand", + Data = new Dictionary() + { + { "name", JsonSerializer.SerializeToElement("bar") }, + }, + Profile = new Dictionary() + { + { "tenant_id", JsonSerializer.SerializeToElement("bar") }, + }, + Recipient = "user-yes", + Template = "template", + }; + + Invoke::InvokeInvokeAdHocParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class AutomationTest : TestBase diff --git a/src/Courier.Tests/Models/Automations/Invoke/InvokeInvokeByTemplateParamsTest.cs b/src/Courier.Tests/Models/Automations/Invoke/InvokeInvokeByTemplateParamsTest.cs index b98e79ff..91cdd9b1 100644 --- a/src/Courier.Tests/Models/Automations/Invoke/InvokeInvokeByTemplateParamsTest.cs +++ b/src/Courier.Tests/Models/Automations/Invoke/InvokeInvokeByTemplateParamsTest.cs @@ -117,4 +117,28 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/automations/templateId/invoke"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvokeInvokeByTemplateParams + { + TemplateID = "templateId", + Recipient = "recipient", + Brand = "brand", + Data = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Profile = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Template = "template", + }; + + InvokeInvokeByTemplateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Brands/BrandCreateParamsTest.cs b/src/Courier.Tests/Models/Brands/BrandCreateParamsTest.cs index 7b8ce5c8..f29ba34d 100644 --- a/src/Courier.Tests/Models/Brands/BrandCreateParamsTest.cs +++ b/src/Courier.Tests/Models/Brands/BrandCreateParamsTest.cs @@ -164,4 +164,66 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/brands"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BrandCreateParams + { + Name = "name", + ID = "id", + Settings = new() + { + Colors = new() { Primary = "primary", Secondary = "secondary" }, + Email = new() + { + Footer = new() { Content = "content", InheritDefault = true }, + Head = new() { InheritDefault = true, Content = "content" }, + Header = new() + { + Logo = new() { Href = "href", Image = "image" }, + BarColor = "barColor", + InheritDefault = true, + }, + TemplateOverride = new() + { + Enabled = true, + BackgroundColor = "backgroundColor", + BlocksBackgroundColor = "blocksBackgroundColor", + Footer = "footer", + Head = "head", + Header = "header", + Width = "width", + Mjml = new() + { + Enabled = true, + BackgroundColor = "backgroundColor", + BlocksBackgroundColor = "blocksBackgroundColor", + Footer = "footer", + Head = "head", + Header = "header", + Width = "width", + }, + FooterBackgroundColor = "footerBackgroundColor", + FooterFullWidth = true, + }, + }, + Inapp = new() + { + Colors = new() { Primary = "primary", Secondary = "secondary" }, + Icons = new() { Bell = "bell", Message = "message" }, + WidgetBackground = new() { BottomColor = "bottomColor", TopColor = "topColor" }, + BorderRadius = "borderRadius", + DisableMessageIcon = true, + FontFamily = "fontFamily", + Placement = Placement.Top, + }, + }, + Snippets = new() { Items = [new() { Name = "name", Value = "value" }] }, + }; + + BrandCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Brands/BrandDeleteParamsTest.cs b/src/Courier.Tests/Models/Brands/BrandDeleteParamsTest.cs index 47467596..085238f9 100644 --- a/src/Courier.Tests/Models/Brands/BrandDeleteParamsTest.cs +++ b/src/Courier.Tests/Models/Brands/BrandDeleteParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/brands/brand_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BrandDeleteParams { BrandID = "brand_id" }; + + BrandDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Brands/BrandListParamsTest.cs b/src/Courier.Tests/Models/Brands/BrandListParamsTest.cs index 9333bfff..a9b7f19e 100644 --- a/src/Courier.Tests/Models/Brands/BrandListParamsTest.cs +++ b/src/Courier.Tests/Models/Brands/BrandListParamsTest.cs @@ -42,4 +42,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/brands?cursor=cursor"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BrandListParams { Cursor = "cursor" }; + + BrandListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Brands/BrandRetrieveParamsTest.cs b/src/Courier.Tests/Models/Brands/BrandRetrieveParamsTest.cs index 7ac245af..242c9ccf 100644 --- a/src/Courier.Tests/Models/Brands/BrandRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Brands/BrandRetrieveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/brands/brand_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BrandRetrieveParams { BrandID = "brand_id" }; + + BrandRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Brands/BrandUpdateParamsTest.cs b/src/Courier.Tests/Models/Brands/BrandUpdateParamsTest.cs index 62408ae3..f65b5bd4 100644 --- a/src/Courier.Tests/Models/Brands/BrandUpdateParamsTest.cs +++ b/src/Courier.Tests/Models/Brands/BrandUpdateParamsTest.cs @@ -160,4 +160,66 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/brands/brand_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BrandUpdateParams + { + BrandID = "brand_id", + Name = "name", + Settings = new() + { + Colors = new() { Primary = "primary", Secondary = "secondary" }, + Email = new() + { + Footer = new() { Content = "content", InheritDefault = true }, + Head = new() { InheritDefault = true, Content = "content" }, + Header = new() + { + Logo = new() { Href = "href", Image = "image" }, + BarColor = "barColor", + InheritDefault = true, + }, + TemplateOverride = new() + { + Enabled = true, + BackgroundColor = "backgroundColor", + BlocksBackgroundColor = "blocksBackgroundColor", + Footer = "footer", + Head = "head", + Header = "header", + Width = "width", + Mjml = new() + { + Enabled = true, + BackgroundColor = "backgroundColor", + BlocksBackgroundColor = "blocksBackgroundColor", + Footer = "footer", + Head = "head", + Header = "header", + Width = "width", + }, + FooterBackgroundColor = "footerBackgroundColor", + FooterFullWidth = true, + }, + }, + Inapp = new() + { + Colors = new() { Primary = "primary", Secondary = "secondary" }, + Icons = new() { Bell = "bell", Message = "message" }, + WidgetBackground = new() { BottomColor = "bottomColor", TopColor = "topColor" }, + BorderRadius = "borderRadius", + DisableMessageIcon = true, + FontFamily = "fontFamily", + Placement = Placement.Top, + }, + }, + Snippets = new() { Items = [new() { Name = "name", Value = "value" }] }, + }; + + BrandUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Bulk/BulkAddUsersParamsTest.cs b/src/Courier.Tests/Models/Bulk/BulkAddUsersParamsTest.cs index c4b2147b..448448b6 100644 --- a/src/Courier.Tests/Models/Bulk/BulkAddUsersParamsTest.cs +++ b/src/Courier.Tests/Models/Bulk/BulkAddUsersParamsTest.cs @@ -302,4 +302,107 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/bulk/job_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BulkAddUsersParams + { + JobID = "job_id", + Users = + [ + new() + { + Data = JsonSerializer.Deserialize("{}"), + Preferences = new() + { + Categories = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + Notifications = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + }, + Profile = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Recipient = "recipient", + To = new() + { + AccountID = "account_id", + Context = new() { TenantID = "tenant_id" }, + Data = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Email = "email", + ListID = "list_id", + Locale = "locale", + PhoneNumber = "phone_number", + Preferences = new() + { + Notifications = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = + [ + new(ChannelClassification.DirectMessage), + ], + Rules = [new() { Until = "until", Start = "start" }], + Source = Source.Subscription, + } + }, + }, + Categories = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = + [ + new(ChannelClassification.DirectMessage), + ], + Rules = [new() { Until = "until", Start = "start" }], + Source = Source.Subscription, + } + }, + }, + TemplateID = "templateId", + }, + TenantID = "tenant_id", + UserID = "user_id", + }, + }, + ], + }; + + BulkAddUsersParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Bulk/BulkCreateJobParamsTest.cs b/src/Courier.Tests/Models/Bulk/BulkCreateJobParamsTest.cs index 818028a9..91090a6b 100644 --- a/src/Courier.Tests/Models/Bulk/BulkCreateJobParamsTest.cs +++ b/src/Courier.Tests/Models/Bulk/BulkCreateJobParamsTest.cs @@ -105,4 +105,41 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/bulk"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BulkCreateJobParams + { + Message = new() + { + Event = "event", + Brand = "brand", + Content = new ElementalContentSugar() { Body = "body", Title = "title" }, + Data = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Locale = new Dictionary>() + { + { + "foo", + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + } + }, + }, + Override = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Template = "template", + }, + }; + + BulkCreateJobParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Bulk/BulkListUsersParamsTest.cs b/src/Courier.Tests/Models/Bulk/BulkListUsersParamsTest.cs index d6c02e5f..f680dc79 100644 --- a/src/Courier.Tests/Models/Bulk/BulkListUsersParamsTest.cs +++ b/src/Courier.Tests/Models/Bulk/BulkListUsersParamsTest.cs @@ -49,4 +49,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/bulk/job_id/users?cursor=cursor"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BulkListUsersParams { JobID = "job_id", Cursor = "cursor" }; + + BulkListUsersParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Bulk/BulkRetrieveJobParamsTest.cs b/src/Courier.Tests/Models/Bulk/BulkRetrieveJobParamsTest.cs index a5cea00b..f77c25df 100644 --- a/src/Courier.Tests/Models/Bulk/BulkRetrieveJobParamsTest.cs +++ b/src/Courier.Tests/Models/Bulk/BulkRetrieveJobParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/bulk/job_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BulkRetrieveJobParams { JobID = "job_id" }; + + BulkRetrieveJobParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Bulk/BulkRunJobParamsTest.cs b/src/Courier.Tests/Models/Bulk/BulkRunJobParamsTest.cs index 945570c8..458faba5 100644 --- a/src/Courier.Tests/Models/Bulk/BulkRunJobParamsTest.cs +++ b/src/Courier.Tests/Models/Bulk/BulkRunJobParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/bulk/job_id/run"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new BulkRunJobParams { JobID = "job_id" }; + + BulkRunJobParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Inbound/InboundTrackEventParamsTest.cs b/src/Courier.Tests/Models/Inbound/InboundTrackEventParamsTest.cs index ffe5b962..3774f005 100644 --- a/src/Courier.Tests/Models/Inbound/InboundTrackEventParamsTest.cs +++ b/src/Courier.Tests/Models/Inbound/InboundTrackEventParamsTest.cs @@ -112,6 +112,28 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/inbound/courier"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new Inbound::InboundTrackEventParams + { + Event = "New Order Placed", + MessageID = "4c62c457-b329-4bea-9bfc-17bba86c393f", + Properties = new Dictionary() + { + { "order_id", JsonSerializer.SerializeToElement("bar") }, + { "total_orders", JsonSerializer.SerializeToElement("bar") }, + { "last_order_id", JsonSerializer.SerializeToElement("bar") }, + }, + Type = Inbound::Type.Track, + UserID = "1234", + }; + + Inbound::InboundTrackEventParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class TypeTest : TestBase diff --git a/src/Courier.Tests/Models/Lists/ListDeleteParamsTest.cs b/src/Courier.Tests/Models/Lists/ListDeleteParamsTest.cs index b725049c..9f2b76ee 100644 --- a/src/Courier.Tests/Models/Lists/ListDeleteParamsTest.cs +++ b/src/Courier.Tests/Models/Lists/ListDeleteParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/lists/list_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ListDeleteParams { ListID = "list_id" }; + + ListDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Lists/ListListParamsTest.cs b/src/Courier.Tests/Models/Lists/ListListParamsTest.cs index f7bd7c29..bc2fff87 100644 --- a/src/Courier.Tests/Models/Lists/ListListParamsTest.cs +++ b/src/Courier.Tests/Models/Lists/ListListParamsTest.cs @@ -48,4 +48,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/lists?cursor=cursor&pattern=pattern"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ListListParams { Cursor = "cursor", Pattern = "pattern" }; + + ListListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Lists/ListRestoreParamsTest.cs b/src/Courier.Tests/Models/Lists/ListRestoreParamsTest.cs index 713b8631..6288b547 100644 --- a/src/Courier.Tests/Models/Lists/ListRestoreParamsTest.cs +++ b/src/Courier.Tests/Models/Lists/ListRestoreParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/lists/list_id/restore"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ListRestoreParams { ListID = "list_id" }; + + ListRestoreParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Lists/ListRetrieveParamsTest.cs b/src/Courier.Tests/Models/Lists/ListRetrieveParamsTest.cs index 38d44e66..52de1928 100644 --- a/src/Courier.Tests/Models/Lists/ListRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Lists/ListRetrieveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/lists/list_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ListRetrieveParams { ListID = "list_id" }; + + ListRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Lists/ListUpdateParamsTest.cs b/src/Courier.Tests/Models/Lists/ListUpdateParamsTest.cs index d33e858f..f7a4944a 100644 --- a/src/Courier.Tests/Models/Lists/ListUpdateParamsTest.cs +++ b/src/Courier.Tests/Models/Lists/ListUpdateParamsTest.cs @@ -111,4 +111,45 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/lists/list_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ListUpdateParams + { + ListID = "list_id", + Name = "name", + Preferences = new() + { + Categories = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + Notifications = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + }, + }; + + ListUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionAddParamsTest.cs b/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionAddParamsTest.cs index a66d20c0..565362e1 100644 --- a/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionAddParamsTest.cs +++ b/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionAddParamsTest.cs @@ -140,4 +140,51 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/lists/list_id/subscriptions"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionAddParams + { + ListID = "list_id", + Recipients = + [ + new() + { + RecipientID = "recipientId", + Preferences = new() + { + Categories = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + Notifications = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + }, + }, + ], + }; + + SubscriptionAddParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionListParamsTest.cs b/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionListParamsTest.cs index fdd76dbd..c66b3679 100644 --- a/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionListParamsTest.cs +++ b/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionListParamsTest.cs @@ -52,4 +52,14 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionListParams { ListID = "list_id", Cursor = "cursor" }; + + SubscriptionListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionSubscribeParamsTest.cs b/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionSubscribeParamsTest.cs index fd498953..785cc236 100644 --- a/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionSubscribeParamsTest.cs +++ b/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionSubscribeParamsTest.cs @@ -140,4 +140,51 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/lists/list_id/subscriptions"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionSubscribeParams + { + ListID = "list_id", + Recipients = + [ + new() + { + RecipientID = "recipientId", + Preferences = new() + { + Categories = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + Notifications = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + }, + }, + ], + }; + + SubscriptionSubscribeParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionSubscribeUserParamsTest.cs b/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionSubscribeUserParamsTest.cs index 921c40cb..c3a2029c 100644 --- a/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionSubscribeUserParamsTest.cs +++ b/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionSubscribeUserParamsTest.cs @@ -119,4 +119,45 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/lists/list_id/subscriptions/user_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionSubscribeUserParams + { + ListID = "list_id", + UserID = "user_id", + Preferences = new() + { + Categories = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + Notifications = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + }, + }; + + SubscriptionSubscribeUserParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionUnsubscribeUserParamsTest.cs b/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionUnsubscribeUserParamsTest.cs index ae6e2751..c80dc870 100644 --- a/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionUnsubscribeUserParamsTest.cs +++ b/src/Courier.Tests/Models/Lists/Subscriptions/SubscriptionUnsubscribeUserParamsTest.cs @@ -34,4 +34,18 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/lists/list_id/subscriptions/user_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SubscriptionUnsubscribeUserParams + { + ListID = "list_id", + UserID = "user_id", + }; + + SubscriptionUnsubscribeUserParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Messages/MessageCancelParamsTest.cs b/src/Courier.Tests/Models/Messages/MessageCancelParamsTest.cs index 45d5983f..fc1632d8 100644 --- a/src/Courier.Tests/Models/Messages/MessageCancelParamsTest.cs +++ b/src/Courier.Tests/Models/Messages/MessageCancelParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/messages/message_id/cancel"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MessageCancelParams { MessageID = "message_id" }; + + MessageCancelParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Messages/MessageContentParamsTest.cs b/src/Courier.Tests/Models/Messages/MessageContentParamsTest.cs index 50fca07d..2edbf00b 100644 --- a/src/Courier.Tests/Models/Messages/MessageContentParamsTest.cs +++ b/src/Courier.Tests/Models/Messages/MessageContentParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/messages/message_id/output"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MessageContentParams { MessageID = "message_id" }; + + MessageContentParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Messages/MessageHistoryParamsTest.cs b/src/Courier.Tests/Models/Messages/MessageHistoryParamsTest.cs index 1125ab78..29a9aad6 100644 --- a/src/Courier.Tests/Models/Messages/MessageHistoryParamsTest.cs +++ b/src/Courier.Tests/Models/Messages/MessageHistoryParamsTest.cs @@ -49,4 +49,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/messages/message_id/history?type=type"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MessageHistoryParams { MessageID = "message_id", Type = "type" }; + + MessageHistoryParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Messages/MessageListParamsTest.cs b/src/Courier.Tests/Models/Messages/MessageListParamsTest.cs index 2efd1b63..fcec411c 100644 --- a/src/Courier.Tests/Models/Messages/MessageListParamsTest.cs +++ b/src/Courier.Tests/Models/Messages/MessageListParamsTest.cs @@ -240,4 +240,30 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MessageListParams + { + Archived = true, + Cursor = "cursor", + EnqueuedAfter = "enqueued_after", + Event = "event", + List = "list", + MessageID = "messageId", + Notification = "notification", + Provider = ["string"], + Recipient = "recipient", + Status = ["string"], + Tag = ["string"], + Tags = "tags", + TenantID = "tenant_id", + TraceID = "traceId", + }; + + MessageListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Messages/MessageRetrieveParamsTest.cs b/src/Courier.Tests/Models/Messages/MessageRetrieveParamsTest.cs index a7d7b1a9..b1754862 100644 --- a/src/Courier.Tests/Models/Messages/MessageRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Messages/MessageRetrieveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/messages/message_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new MessageRetrieveParams { MessageID = "message_id" }; + + MessageRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Notifications/Checks/CheckDeleteParamsTest.cs b/src/Courier.Tests/Models/Notifications/Checks/CheckDeleteParamsTest.cs index d1fb5b45..e743704b 100644 --- a/src/Courier.Tests/Models/Notifications/Checks/CheckDeleteParamsTest.cs +++ b/src/Courier.Tests/Models/Notifications/Checks/CheckDeleteParamsTest.cs @@ -26,4 +26,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/notifications/id/submissionId/checks"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CheckDeleteParams { ID = "id", SubmissionID = "submissionId" }; + + CheckDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Notifications/Checks/CheckListParamsTest.cs b/src/Courier.Tests/Models/Notifications/Checks/CheckListParamsTest.cs index 20ad369d..782e7ebf 100644 --- a/src/Courier.Tests/Models/Notifications/Checks/CheckListParamsTest.cs +++ b/src/Courier.Tests/Models/Notifications/Checks/CheckListParamsTest.cs @@ -26,4 +26,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/notifications/id/submissionId/checks"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CheckListParams { ID = "id", SubmissionID = "submissionId" }; + + CheckListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Notifications/Checks/CheckUpdateParamsTest.cs b/src/Courier.Tests/Models/Notifications/Checks/CheckUpdateParamsTest.cs index 31858baf..347cd547 100644 --- a/src/Courier.Tests/Models/Notifications/Checks/CheckUpdateParamsTest.cs +++ b/src/Courier.Tests/Models/Notifications/Checks/CheckUpdateParamsTest.cs @@ -68,4 +68,27 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/notifications/id/submissionId/checks"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CheckUpdateParams + { + ID = "id", + SubmissionID = "submissionId", + Checks = + [ + new() + { + ID = "id", + Status = Notifications::Status.Resolved, + Type = Notifications::Type.Custom, + }, + ], + }; + + CheckUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Notifications/Draft/DraftRetrieveContentParamsTest.cs b/src/Courier.Tests/Models/Notifications/Draft/DraftRetrieveContentParamsTest.cs index 0de12f1d..4810190f 100644 --- a/src/Courier.Tests/Models/Notifications/Draft/DraftRetrieveContentParamsTest.cs +++ b/src/Courier.Tests/Models/Notifications/Draft/DraftRetrieveContentParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/notifications/id/draft/content"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new DraftRetrieveContentParams { ID = "id" }; + + DraftRetrieveContentParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Notifications/NotificationListParamsTest.cs b/src/Courier.Tests/Models/Notifications/NotificationListParamsTest.cs index 41748424..9decca5b 100644 --- a/src/Courier.Tests/Models/Notifications/NotificationListParamsTest.cs +++ b/src/Courier.Tests/Models/Notifications/NotificationListParamsTest.cs @@ -51,4 +51,14 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new NotificationListParams { Cursor = "cursor", Notes = true }; + + NotificationListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Notifications/NotificationRetrieveContentParamsTest.cs b/src/Courier.Tests/Models/Notifications/NotificationRetrieveContentParamsTest.cs index aad365c8..4dab0da5 100644 --- a/src/Courier.Tests/Models/Notifications/NotificationRetrieveContentParamsTest.cs +++ b/src/Courier.Tests/Models/Notifications/NotificationRetrieveContentParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/notifications/id/content"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new NotificationRetrieveContentParams { ID = "id" }; + + NotificationRetrieveContentParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Profiles/Lists/ListDeleteParamsTest.cs b/src/Courier.Tests/Models/Profiles/Lists/ListDeleteParamsTest.cs index ee638987..a9a46185 100644 --- a/src/Courier.Tests/Models/Profiles/Lists/ListDeleteParamsTest.cs +++ b/src/Courier.Tests/Models/Profiles/Lists/ListDeleteParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/profiles/user_id/lists"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ListDeleteParams { UserID = "user_id" }; + + ListDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Profiles/Lists/ListRetrieveParamsTest.cs b/src/Courier.Tests/Models/Profiles/Lists/ListRetrieveParamsTest.cs index 73b9ea84..ed786580 100644 --- a/src/Courier.Tests/Models/Profiles/Lists/ListRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Profiles/Lists/ListRetrieveParamsTest.cs @@ -49,4 +49,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/profiles/user_id/lists?cursor=cursor"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ListRetrieveParams { UserID = "user_id", Cursor = "cursor" }; + + ListRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Profiles/Lists/ListSubscribeParamsTest.cs b/src/Courier.Tests/Models/Profiles/Lists/ListSubscribeParamsTest.cs index aa7fb8ac..9be29ed6 100644 --- a/src/Courier.Tests/Models/Profiles/Lists/ListSubscribeParamsTest.cs +++ b/src/Courier.Tests/Models/Profiles/Lists/ListSubscribeParamsTest.cs @@ -140,4 +140,51 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/profiles/user_id/lists"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ListSubscribeParams + { + UserID = "user_id", + Lists = + [ + new() + { + ListID = "listId", + Preferences = new() + { + Categories = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + Notifications = new Dictionary() + { + { + "foo", + new() + { + Status = PreferenceStatus.OptedIn, + ChannelPreferences = [new(ChannelClassification.DirectMessage)], + Rules = [new() { Until = "until", Start = "start" }], + } + }, + }, + }, + }, + ], + }; + + ListSubscribeParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Profiles/ProfileCreateParamsTest.cs b/src/Courier.Tests/Models/Profiles/ProfileCreateParamsTest.cs index 3bd07af9..194b56ac 100644 --- a/src/Courier.Tests/Models/Profiles/ProfileCreateParamsTest.cs +++ b/src/Courier.Tests/Models/Profiles/ProfileCreateParamsTest.cs @@ -51,4 +51,21 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/profiles/user_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ProfileCreateParams + { + UserID = "user_id", + Profile = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + }; + + ProfileCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Profiles/ProfileDeleteParamsTest.cs b/src/Courier.Tests/Models/Profiles/ProfileDeleteParamsTest.cs index 81669262..c7248cc2 100644 --- a/src/Courier.Tests/Models/Profiles/ProfileDeleteParamsTest.cs +++ b/src/Courier.Tests/Models/Profiles/ProfileDeleteParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/profiles/user_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ProfileDeleteParams { UserID = "user_id" }; + + ProfileDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Profiles/ProfileReplaceParamsTest.cs b/src/Courier.Tests/Models/Profiles/ProfileReplaceParamsTest.cs index 936d29e0..087506c6 100644 --- a/src/Courier.Tests/Models/Profiles/ProfileReplaceParamsTest.cs +++ b/src/Courier.Tests/Models/Profiles/ProfileReplaceParamsTest.cs @@ -51,4 +51,21 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/profiles/user_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ProfileReplaceParams + { + UserID = "user_id", + Profile = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + }; + + ProfileReplaceParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Profiles/ProfileRetrieveParamsTest.cs b/src/Courier.Tests/Models/Profiles/ProfileRetrieveParamsTest.cs index 6800f3ab..010f6754 100644 --- a/src/Courier.Tests/Models/Profiles/ProfileRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Profiles/ProfileRetrieveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/profiles/user_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ProfileRetrieveParams { UserID = "user_id" }; + + ProfileRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Profiles/ProfileUpdateParamsTest.cs b/src/Courier.Tests/Models/Profiles/ProfileUpdateParamsTest.cs index 56c0b5ed..eac7355e 100644 --- a/src/Courier.Tests/Models/Profiles/ProfileUpdateParamsTest.cs +++ b/src/Courier.Tests/Models/Profiles/ProfileUpdateParamsTest.cs @@ -65,6 +65,28 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/profiles/user_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ProfileUpdateParams + { + UserID = "user_id", + Patch = + [ + new() + { + Op = "op", + Path = "path", + Value = "value", + }, + ], + }; + + ProfileUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class PatchTest : TestBase diff --git a/src/Courier.Tests/Models/Requests/RequestArchiveParamsTest.cs b/src/Courier.Tests/Models/Requests/RequestArchiveParamsTest.cs index 7adfd3ce..74ca991e 100644 --- a/src/Courier.Tests/Models/Requests/RequestArchiveParamsTest.cs +++ b/src/Courier.Tests/Models/Requests/RequestArchiveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/requests/request_id/archive"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new RequestArchiveParams { RequestID = "request_id" }; + + RequestArchiveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Send/SendMessageParamsTest.cs b/src/Courier.Tests/Models/Send/SendMessageParamsTest.cs index cad30cd9..79b99d29 100644 --- a/src/Courier.Tests/Models/Send/SendMessageParamsTest.cs +++ b/src/Courier.Tests/Models/Send/SendMessageParamsTest.cs @@ -476,6 +476,166 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/send"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new SendMessageParams + { + Message = new() + { + BrandID = "brand_id", + Channels = new Dictionary() + { + { + "foo", + new() + { + BrandID = "brand_id", + If = "if", + Metadata = new() + { + Utm = new() + { + Campaign = "campaign", + Content = "content", + Medium = "medium", + Source = "source", + Term = "term", + }, + }, + Override = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Providers = ["string"], + RoutingMethod = RoutingMethod.All, + Timeouts = new() { Channel = 0, Provider = 0 }, + } + }, + }, + Content = new Models::ElementalContentSugar() { Body = "body", Title = "title" }, + Context = new() { TenantID = "tenant_id" }, + Data = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Delay = new() + { + Duration = 0, + Timezone = "timezone", + Until = "until", + }, + Expiry = new() { ExpiresIn = "string", ExpiresAt = "expires_at" }, + Metadata = new() + { + Event = "event", + Tags = ["string"], + TraceID = "trace_id", + Utm = new() + { + Campaign = "campaign", + Content = "content", + Medium = "medium", + Source = "source", + Term = "term", + }, + }, + Preferences = new("subscription_topic_id"), + Providers = new Dictionary() + { + { + "foo", + new() + { + If = "if", + Metadata = new() + { + Utm = new() + { + Campaign = "campaign", + Content = "content", + Medium = "medium", + Source = "source", + Term = "term", + }, + }, + Override = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Timeouts = 0, + } + }, + }, + Routing = new() { Channels = ["string"], Method = Method.All }, + Template = "template_id", + Timeout = new() + { + Channel = new Dictionary() { { "foo", 0 } }, + Criteria = Criteria.NoEscalation, + Escalation = 0, + Message = 0, + Provider = new Dictionary() { { "foo", 0 } }, + }, + To = new Models::UserRecipient() + { + AccountID = "account_id", + Context = new() { TenantID = "tenant_id" }, + Data = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Email = "email", + ListID = "list_id", + Locale = "locale", + PhoneNumber = "phone_number", + Preferences = new() + { + Notifications = new Dictionary() + { + { + "foo", + new() + { + Status = Models::PreferenceStatus.OptedIn, + ChannelPreferences = + [ + new(Models::ChannelClassification.DirectMessage), + ], + Rules = [new() { Until = "until", Start = "start" }], + Source = Models::Source.Subscription, + } + }, + }, + Categories = new Dictionary() + { + { + "foo", + new() + { + Status = Models::PreferenceStatus.OptedIn, + ChannelPreferences = + [ + new(Models::ChannelClassification.DirectMessage), + ], + Rules = [new() { Until = "until", Start = "start" }], + Source = Models::Source.Subscription, + } + }, + }, + TemplateID = "templateId", + }, + TenantID = "tenant_id", + UserID = "user_id", + }, + }, + }; + + SendMessageParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class MessageTest : TestBase diff --git a/src/Courier.Tests/Models/Tenants/Preferences/Items/ItemDeleteParamsTest.cs b/src/Courier.Tests/Models/Tenants/Preferences/Items/ItemDeleteParamsTest.cs index bffdcd96..9b7838f7 100644 --- a/src/Courier.Tests/Models/Tenants/Preferences/Items/ItemDeleteParamsTest.cs +++ b/src/Courier.Tests/Models/Tenants/Preferences/Items/ItemDeleteParamsTest.cs @@ -29,4 +29,14 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ItemDeleteParams { TenantID = "tenant_id", TopicID = "topic_id" }; + + ItemDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Tenants/Preferences/Items/ItemUpdateParamsTest.cs b/src/Courier.Tests/Models/Tenants/Preferences/Items/ItemUpdateParamsTest.cs index 5d6069f5..abf72c25 100644 --- a/src/Courier.Tests/Models/Tenants/Preferences/Items/ItemUpdateParamsTest.cs +++ b/src/Courier.Tests/Models/Tenants/Preferences/Items/ItemUpdateParamsTest.cs @@ -95,6 +95,23 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new ItemUpdateParams + { + TenantID = "tenant_id", + TopicID = "topic_id", + Status = Status.OptedIn, + CustomRouting = [ChannelClassification.Inbox], + HasCustomRouting = true, + }; + + ItemUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class StatusTest : TestBase diff --git a/src/Courier.Tests/Models/Tenants/Templates/TemplateListParamsTest.cs b/src/Courier.Tests/Models/Tenants/Templates/TemplateListParamsTest.cs index 9f7649f3..16ba1faf 100644 --- a/src/Courier.Tests/Models/Tenants/Templates/TemplateListParamsTest.cs +++ b/src/Courier.Tests/Models/Tenants/Templates/TemplateListParamsTest.cs @@ -69,4 +69,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TemplateListParams + { + TenantID = "tenant_id", + Cursor = "cursor", + Limit = 0, + }; + + TemplateListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Tenants/Templates/TemplateRetrieveParamsTest.cs b/src/Courier.Tests/Models/Tenants/Templates/TemplateRetrieveParamsTest.cs index f8503a8e..1a32311a 100644 --- a/src/Courier.Tests/Models/Tenants/Templates/TemplateRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Tenants/Templates/TemplateRetrieveParamsTest.cs @@ -37,4 +37,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TemplateRetrieveParams + { + TenantID = "tenant_id", + TemplateID = "template_id", + }; + + TemplateRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Tenants/TenantDeleteParamsTest.cs b/src/Courier.Tests/Models/Tenants/TenantDeleteParamsTest.cs index 31284754..43ea5d51 100644 --- a/src/Courier.Tests/Models/Tenants/TenantDeleteParamsTest.cs +++ b/src/Courier.Tests/Models/Tenants/TenantDeleteParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/tenants/tenant_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TenantDeleteParams { TenantID = "tenant_id" }; + + TenantDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Tenants/TenantListParamsTest.cs b/src/Courier.Tests/Models/Tenants/TenantListParamsTest.cs index a76a467b..a67a7cb3 100644 --- a/src/Courier.Tests/Models/Tenants/TenantListParamsTest.cs +++ b/src/Courier.Tests/Models/Tenants/TenantListParamsTest.cs @@ -74,4 +74,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TenantListParams + { + Cursor = "cursor", + Limit = 0, + ParentTenantID = "parent_tenant_id", + }; + + TenantListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Tenants/TenantListUsersParamsTest.cs b/src/Courier.Tests/Models/Tenants/TenantListUsersParamsTest.cs index b984ca97..29c8b639 100644 --- a/src/Courier.Tests/Models/Tenants/TenantListUsersParamsTest.cs +++ b/src/Courier.Tests/Models/Tenants/TenantListUsersParamsTest.cs @@ -69,4 +69,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TenantListUsersParams + { + TenantID = "tenant_id", + Cursor = "cursor", + Limit = 0, + }; + + TenantListUsersParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Tenants/TenantRetrieveParamsTest.cs b/src/Courier.Tests/Models/Tenants/TenantRetrieveParamsTest.cs index 23b9b3bd..6d56d240 100644 --- a/src/Courier.Tests/Models/Tenants/TenantRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Tenants/TenantRetrieveParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/tenants/tenant_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TenantRetrieveParams { TenantID = "tenant_id" }; + + TenantRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Tenants/TenantUpdateParamsTest.cs b/src/Courier.Tests/Models/Tenants/TenantUpdateParamsTest.cs index 5cdfc6eb..5b97b995 100644 --- a/src/Courier.Tests/Models/Tenants/TenantUpdateParamsTest.cs +++ b/src/Courier.Tests/Models/Tenants/TenantUpdateParamsTest.cs @@ -142,4 +142,41 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/tenants/tenant_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TenantUpdateParams + { + TenantID = "tenant_id", + Name = "name", + BrandID = "brand_id", + DefaultPreferences = new() + { + Items = + [ + new() + { + Status = Status.OptedOut, + CustomRouting = [ChannelClassification.DirectMessage], + HasCustomRouting = true, + ID = "id", + }, + ], + }, + ParentTenantID = "parent_tenant_id", + Properties = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + UserProfile = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + }; + + TenantUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Translations/TranslationRetrieveParamsTest.cs b/src/Courier.Tests/Models/Translations/TranslationRetrieveParamsTest.cs index e5b88ee0..087717d0 100644 --- a/src/Courier.Tests/Models/Translations/TranslationRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Translations/TranslationRetrieveParamsTest.cs @@ -26,4 +26,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/translations/domain/locale"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TranslationRetrieveParams { Domain = "domain", Locale = "locale" }; + + TranslationRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Translations/TranslationUpdateParamsTest.cs b/src/Courier.Tests/Models/Translations/TranslationUpdateParamsTest.cs index c7a16cde..97ac079e 100644 --- a/src/Courier.Tests/Models/Translations/TranslationUpdateParamsTest.cs +++ b/src/Courier.Tests/Models/Translations/TranslationUpdateParamsTest.cs @@ -38,4 +38,19 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/translations/domain/locale"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TranslationUpdateParams + { + Domain = "domain", + Locale = "locale", + Body = "body", + }; + + TranslationUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Preferences/PreferenceRetrieveParamsTest.cs b/src/Courier.Tests/Models/Users/Preferences/PreferenceRetrieveParamsTest.cs index 3d56f636..85b1649d 100644 --- a/src/Courier.Tests/Models/Users/Preferences/PreferenceRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Preferences/PreferenceRetrieveParamsTest.cs @@ -56,4 +56,18 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PreferenceRetrieveParams + { + UserID = "user_id", + TenantID = "tenant_id", + }; + + PreferenceRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Preferences/PreferenceRetrieveTopicParamsTest.cs b/src/Courier.Tests/Models/Users/Preferences/PreferenceRetrieveTopicParamsTest.cs index 08281847..c0055f87 100644 --- a/src/Courier.Tests/Models/Users/Preferences/PreferenceRetrieveTopicParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Preferences/PreferenceRetrieveTopicParamsTest.cs @@ -71,4 +71,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PreferenceRetrieveTopicParams + { + UserID = "user_id", + TopicID = "topic_id", + TenantID = "tenant_id", + }; + + PreferenceRetrieveTopicParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Preferences/PreferenceUpdateOrCreateTopicParamsTest.cs b/src/Courier.Tests/Models/Users/Preferences/PreferenceUpdateOrCreateTopicParamsTest.cs index 70a76125..caf93f94 100644 --- a/src/Courier.Tests/Models/Users/Preferences/PreferenceUpdateOrCreateTopicParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Preferences/PreferenceUpdateOrCreateTopicParamsTest.cs @@ -106,6 +106,27 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new PreferenceUpdateOrCreateTopicParams + { + UserID = "user_id", + TopicID = "topic_id", + Topic = new() + { + Status = PreferenceStatus.OptedIn, + CustomRouting = [ChannelClassification.Inbox, ChannelClassification.Email], + HasCustomRouting = true, + }, + TenantID = "tenant_id", + }; + + PreferenceUpdateOrCreateTopicParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class TopicTest : TestBase diff --git a/src/Courier.Tests/Models/Users/Tenants/TenantAddMultipleParamsTest.cs b/src/Courier.Tests/Models/Users/Tenants/TenantAddMultipleParamsTest.cs index daf775c7..5571ee24 100644 --- a/src/Courier.Tests/Models/Users/Tenants/TenantAddMultipleParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tenants/TenantAddMultipleParamsTest.cs @@ -77,4 +77,30 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/users/user_id/tenants"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TenantAddMultipleParams + { + UserID = "user_id", + Tenants = + [ + new() + { + TenantID = "tenant_id", + Profile = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + Type = Tenants::Type.User, + UserID = "user_id", + }, + ], + }; + + TenantAddMultipleParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Tenants/TenantAddSingleParamsTest.cs b/src/Courier.Tests/Models/Users/Tenants/TenantAddSingleParamsTest.cs index 55c6f4ab..13c42412 100644 --- a/src/Courier.Tests/Models/Users/Tenants/TenantAddSingleParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tenants/TenantAddSingleParamsTest.cs @@ -72,4 +72,22 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/users/user_id/tenants/tenant_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TenantAddSingleParams + { + UserID = "user_id", + TenantID = "tenant_id", + Profile = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + }; + + TenantAddSingleParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Tenants/TenantListParamsTest.cs b/src/Courier.Tests/Models/Users/Tenants/TenantListParamsTest.cs index abef8569..1935c8d9 100644 --- a/src/Courier.Tests/Models/Users/Tenants/TenantListParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tenants/TenantListParamsTest.cs @@ -69,4 +69,19 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TenantListParams + { + UserID = "user_id", + Cursor = "cursor", + Limit = 0, + }; + + TenantListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Tenants/TenantRemoveAllParamsTest.cs b/src/Courier.Tests/Models/Users/Tenants/TenantRemoveAllParamsTest.cs index 3f0bccc3..00171546 100644 --- a/src/Courier.Tests/Models/Users/Tenants/TenantRemoveAllParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tenants/TenantRemoveAllParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/users/user_id/tenants"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TenantRemoveAllParams { UserID = "user_id" }; + + TenantRemoveAllParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Tenants/TenantRemoveSingleParamsTest.cs b/src/Courier.Tests/Models/Users/Tenants/TenantRemoveSingleParamsTest.cs index a14d16fd..e16fc5f4 100644 --- a/src/Courier.Tests/Models/Users/Tenants/TenantRemoveSingleParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tenants/TenantRemoveSingleParamsTest.cs @@ -30,4 +30,18 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/users/user_id/tenants/tenant_id"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TenantRemoveSingleParams + { + UserID = "user_id", + TenantID = "tenant_id", + }; + + TenantRemoveSingleParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Tokens/TokenAddMultipleParamsTest.cs b/src/Courier.Tests/Models/Users/Tokens/TokenAddMultipleParamsTest.cs index c2e567d7..e2f735e4 100644 --- a/src/Courier.Tests/Models/Users/Tokens/TokenAddMultipleParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tokens/TokenAddMultipleParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/users/user_id/tokens"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TokenAddMultipleParams { UserID = "user_id" }; + + TokenAddMultipleParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Tokens/TokenAddSingleParamsTest.cs b/src/Courier.Tests/Models/Users/Tokens/TokenAddSingleParamsTest.cs index 7b5feec9..7fc37e74 100644 --- a/src/Courier.Tests/Models/Users/Tokens/TokenAddSingleParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tokens/TokenAddSingleParamsTest.cs @@ -197,6 +197,40 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/users/user_id/tokens/token"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TokenAddSingleParams + { + UserID = "user_id", + Token = "token", + TokenValue = "token", + ProviderKey = ProviderKey.FirebaseFcm, + Device = new() + { + AdID = "ad_id", + AppID = "app_id", + DeviceID = "device_id", + Manufacturer = "manufacturer", + Model = "model", + Platform = "platform", + }, + ExpiryDate = "string", + Properties = JsonSerializer.Deserialize("{}"), + Tracking = new() + { + IP = "ip", + Lat = "lat", + Long = "long", + OsVersion = "os_version", + }, + }; + + TokenAddSingleParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class ProviderKeyTest : TestBase diff --git a/src/Courier.Tests/Models/Users/Tokens/TokenDeleteParamsTest.cs b/src/Courier.Tests/Models/Users/Tokens/TokenDeleteParamsTest.cs index b8bc5c6d..b2724fa5 100644 --- a/src/Courier.Tests/Models/Users/Tokens/TokenDeleteParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tokens/TokenDeleteParamsTest.cs @@ -26,4 +26,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/users/user_id/tokens/token"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TokenDeleteParams { UserID = "user_id", Token = "token" }; + + TokenDeleteParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Tokens/TokenListParamsTest.cs b/src/Courier.Tests/Models/Users/Tokens/TokenListParamsTest.cs index b806177d..27bf671c 100644 --- a/src/Courier.Tests/Models/Users/Tokens/TokenListParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tokens/TokenListParamsTest.cs @@ -24,4 +24,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/users/user_id/tokens"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TokenListParams { UserID = "user_id" }; + + TokenListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Tokens/TokenRetrieveParamsTest.cs b/src/Courier.Tests/Models/Users/Tokens/TokenRetrieveParamsTest.cs index 70bb3cf5..d0c73c6c 100644 --- a/src/Courier.Tests/Models/Users/Tokens/TokenRetrieveParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tokens/TokenRetrieveParamsTest.cs @@ -26,4 +26,14 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/users/user_id/tokens/token"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TokenRetrieveParams { UserID = "user_id", Token = "token" }; + + TokenRetrieveParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Courier.Tests/Models/Users/Tokens/TokenUpdateParamsTest.cs b/src/Courier.Tests/Models/Users/Tokens/TokenUpdateParamsTest.cs index debfa6f6..54f2a18c 100644 --- a/src/Courier.Tests/Models/Users/Tokens/TokenUpdateParamsTest.cs +++ b/src/Courier.Tests/Models/Users/Tokens/TokenUpdateParamsTest.cs @@ -69,6 +69,29 @@ public void Url_Works() Assert.Equal(new Uri("https://api.courier.com/users/user_id/tokens/token"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new TokenUpdateParams + { + UserID = "user_id", + Token = "token", + Patch = + [ + new() + { + Op = "op", + Path = "path", + Value = "value", + }, + ], + }; + + TokenUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class PatchTest : TestBase diff --git a/src/Courier/Core/ApiEnum.cs b/src/Courier/Core/ApiEnum.cs index 2f4f844e..245f3757 100644 --- a/src/Courier/Core/ApiEnum.cs +++ b/src/Courier/Core/ApiEnum.cs @@ -94,6 +94,9 @@ public virtual bool Equals(ApiEnum? other) return other != null && JsonElement.DeepEquals(this.Json, other.Json); } + public override string ToString() => + JsonSerializer.Serialize(this.Json, ModelBase.ToStringSerializerOptions); + public override int GetHashCode() { return 0; diff --git a/src/Courier/Courier.csproj b/src/Courier/Courier.csproj index 7cae330a..76c546ae 100644 --- a/src/Courier/Courier.csproj +++ b/src/Courier/Courier.csproj @@ -3,7 +3,7 @@ Courier C# Courier - 5.2.0 + 5.3.0 The official .NET library for the Courier API. Library README.md diff --git a/src/Courier/Models/Audiences/AudienceDeleteParams.cs b/src/Courier/Models/Audiences/AudienceDeleteParams.cs index 96e47975..0b514581 100644 --- a/src/Courier/Models/Audiences/AudienceDeleteParams.cs +++ b/src/Courier/Models/Audiences/AudienceDeleteParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Audiences; /// /// Deletes the specified audience. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AudienceDeleteParams : ParamsBase +public record class AudienceDeleteParams : ParamsBase { public string? AudienceID { get; init; } public AudienceDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AudienceDeleteParams(AudienceDeleteParams audienceDeleteParams) : base(audienceDeleteParams) { this.AudienceID = audienceDeleteParams.AudienceID; } +#pragma warning restore CS8618 public AudienceDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["AudienceID"] = this.AudienceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AudienceDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.AudienceID?.Equals(other.AudienceID) ?? other.AudienceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Audiences/AudienceListMembersParams.cs b/src/Courier/Models/Audiences/AudienceListMembersParams.cs index d54936f7..498ab3a2 100644 --- a/src/Courier/Models/Audiences/AudienceListMembersParams.cs +++ b/src/Courier/Models/Audiences/AudienceListMembersParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Audiences; /// /// Get list of members of an audience. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AudienceListMembersParams : ParamsBase +public record class AudienceListMembersParams : ParamsBase { public string? AudienceID { get; init; } @@ -30,11 +34,14 @@ public string? Cursor public AudienceListMembersParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AudienceListMembersParams(AudienceListMembersParams audienceListMembersParams) : base(audienceListMembersParams) { this.AudienceID = audienceListMembersParams.AudienceID; } +#pragma warning restore CS8618 public AudienceListMembersParams( IReadOnlyDictionary rawHeaderData, @@ -69,6 +76,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["AudienceID"] = this.AudienceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AudienceListMembersParams? other) + { + if (other == null) + { + return false; + } + return (this.AudienceID?.Equals(other.AudienceID) ?? other.AudienceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -88,4 +117,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Audiences/AudienceListParams.cs b/src/Courier/Models/Audiences/AudienceListParams.cs index b640d494..480df4d0 100644 --- a/src/Courier/Models/Audiences/AudienceListParams.cs +++ b/src/Courier/Models/Audiences/AudienceListParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Audiences; /// /// Get the audiences associated with the authorization token. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AudienceListParams : ParamsBase +public record class AudienceListParams : ParamsBase { /// /// A unique identifier that allows for fetching the next set of audiences @@ -28,8 +32,11 @@ public string? Cursor public AudienceListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AudienceListParams(AudienceListParams audienceListParams) : base(audienceListParams) { } +#pragma warning restore CS8618 public AudienceListParams( IReadOnlyDictionary rawHeaderData, @@ -64,6 +71,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AudienceListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/audiences") @@ -80,4 +107,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Audiences/AudienceRetrieveParams.cs b/src/Courier/Models/Audiences/AudienceRetrieveParams.cs index 6f234913..25c374c1 100644 --- a/src/Courier/Models/Audiences/AudienceRetrieveParams.cs +++ b/src/Courier/Models/Audiences/AudienceRetrieveParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Audiences; /// /// Returns the specified audience by id. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AudienceRetrieveParams : ParamsBase +public record class AudienceRetrieveParams : ParamsBase { public string? AudienceID { get; init; } public AudienceRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AudienceRetrieveParams(AudienceRetrieveParams audienceRetrieveParams) : base(audienceRetrieveParams) { this.AudienceID = audienceRetrieveParams.AudienceID; } +#pragma warning restore CS8618 public AudienceRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["AudienceID"] = this.AudienceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AudienceRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.AudienceID?.Equals(other.AudienceID) ?? other.AudienceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Audiences/AudienceUpdateParams.cs b/src/Courier/Models/Audiences/AudienceUpdateParams.cs index 410296f7..aa806eca 100644 --- a/src/Courier/Models/Audiences/AudienceUpdateParams.cs +++ b/src/Courier/Models/Audiences/AudienceUpdateParams.cs @@ -13,8 +13,12 @@ namespace Courier.Models.Audiences; /// /// Creates or updates audience. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AudienceUpdateParams : ParamsBase +public record class AudienceUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -66,20 +70,20 @@ public string? Name /// /// The logical operator (AND/OR) for the top-level filter /// - public ApiEnum? Operator + public ApiEnum? Operator { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableClass< - ApiEnum - >("operator"); + return this._rawBodyData.GetNullableClass>("operator"); } init { this._rawBodyData.Set("operator", value); } } public AudienceUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AudienceUpdateParams(AudienceUpdateParams audienceUpdateParams) : base(audienceUpdateParams) { @@ -87,6 +91,7 @@ public AudienceUpdateParams(AudienceUpdateParams audienceUpdateParams) this._rawBodyData = new(audienceUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public AudienceUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -127,6 +132,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["AudienceID"] = this.AudienceID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AudienceUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.AudienceID?.Equals(other.AudienceID) ?? other.AudienceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -155,21 +184,26 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// /// The logical operator (AND/OR) for the top-level filter /// -[JsonConverter(typeof(global::Courier.Models.Audiences.OperatorConverter))] +[JsonConverter(typeof(OperatorConverter))] public enum Operator { And, Or, } -sealed class OperatorConverter : JsonConverter +sealed class OperatorConverter : JsonConverter { - public override global::Courier.Models.Audiences.Operator Read( + public override Operator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -177,24 +211,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "AND" => global::Courier.Models.Audiences.Operator.And, - "OR" => global::Courier.Models.Audiences.Operator.Or, - _ => (global::Courier.Models.Audiences.Operator)(-1), + "AND" => Operator.And, + "OR" => Operator.Or, + _ => (Operator)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Courier.Models.Audiences.Operator value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Operator value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Courier.Models.Audiences.Operator.And => "AND", - global::Courier.Models.Audiences.Operator.Or => "OR", + Operator.And => "AND", + Operator.Or => "OR", _ => throw new CourierInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Courier/Models/AuditEvents/AuditEventListParams.cs b/src/Courier/Models/AuditEvents/AuditEventListParams.cs index c3907e05..29e1df50 100644 --- a/src/Courier/Models/AuditEvents/AuditEventListParams.cs +++ b/src/Courier/Models/AuditEvents/AuditEventListParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.AuditEvents; /// /// Fetch the list of audit events +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AuditEventListParams : ParamsBase +public record class AuditEventListParams : ParamsBase { /// /// A unique identifier that allows for fetching the next set of audit events. @@ -28,8 +32,11 @@ public string? Cursor public AuditEventListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AuditEventListParams(AuditEventListParams auditEventListParams) : base(auditEventListParams) { } +#pragma warning restore CS8618 public AuditEventListParams( IReadOnlyDictionary rawHeaderData, @@ -64,6 +71,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AuditEventListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/audit-events") @@ -80,4 +107,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/AuditEvents/AuditEventRetrieveParams.cs b/src/Courier/Models/AuditEvents/AuditEventRetrieveParams.cs index c8665a24..3b908a78 100644 --- a/src/Courier/Models/AuditEvents/AuditEventRetrieveParams.cs +++ b/src/Courier/Models/AuditEvents/AuditEventRetrieveParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.AuditEvents; /// /// Fetch a specific audit event by ID. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AuditEventRetrieveParams : ParamsBase +public record class AuditEventRetrieveParams : ParamsBase { public string? AuditEventID { get; init; } public AuditEventRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AuditEventRetrieveParams(AuditEventRetrieveParams auditEventRetrieveParams) : base(auditEventRetrieveParams) { this.AuditEventID = auditEventRetrieveParams.AuditEventID; } +#pragma warning restore CS8618 public AuditEventRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["AuditEventID"] = this.AuditEventID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AuditEventRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.AuditEventID?.Equals(other.AuditEventID) ?? other.AuditEventID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Auth/AuthIssueTokenParams.cs b/src/Courier/Models/Auth/AuthIssueTokenParams.cs index 74889dc3..4b8aaabe 100644 --- a/src/Courier/Models/Auth/AuthIssueTokenParams.cs +++ b/src/Courier/Models/Auth/AuthIssueTokenParams.cs @@ -11,8 +11,12 @@ namespace Courier.Models.Auth; /// /// Returns a new access token. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AuthIssueTokenParams : ParamsBase +public record class AuthIssueTokenParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -61,11 +65,14 @@ public required string Scope public AuthIssueTokenParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AuthIssueTokenParams(AuthIssueTokenParams authIssueTokenParams) : base(authIssueTokenParams) { this._rawBodyData = new(authIssueTokenParams._rawBodyData); } +#pragma warning restore CS8618 public AuthIssueTokenParams( IReadOnlyDictionary rawHeaderData, @@ -106,6 +113,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AuthIssueTokenParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/auth/issue-token") @@ -131,4 +160,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Automations/AutomationListParams.cs b/src/Courier/Models/Automations/AutomationListParams.cs index d7b8408e..73eef005 100644 --- a/src/Courier/Models/Automations/AutomationListParams.cs +++ b/src/Courier/Models/Automations/AutomationListParams.cs @@ -12,8 +12,12 @@ namespace Courier.Models.Automations; /// /// Get the list of automations. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class AutomationListParams : ParamsBase +public record class AutomationListParams : ParamsBase { /// /// A cursor token for pagination. Use the cursor from the previous response @@ -61,8 +65,11 @@ public ApiEnum? Version public AutomationListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AutomationListParams(AutomationListParams automationListParams) : base(automationListParams) { } +#pragma warning restore CS8618 public AutomationListParams( IReadOnlyDictionary rawHeaderData, @@ -97,6 +104,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(AutomationListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/automations") @@ -113,6 +140,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Courier/Models/Automations/Invoke/InvokeInvokeAdHocParams.cs b/src/Courier/Models/Automations/Invoke/InvokeInvokeAdHocParams.cs index bdb0f6c2..1841c44c 100644 --- a/src/Courier/Models/Automations/Invoke/InvokeInvokeAdHocParams.cs +++ b/src/Courier/Models/Automations/Invoke/InvokeInvokeAdHocParams.cs @@ -16,8 +16,12 @@ namespace Courier.Models.Automations.Invoke; /// Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a /// series of automation steps. For information about what steps are available, checkout /// the ad hoc automation guide [here](https://www.courier.com/docs/automations/steps/). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvokeInvokeAdHocParams : ParamsBase +public record class InvokeInvokeAdHocParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -103,11 +107,14 @@ public string? Template public InvokeInvokeAdHocParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvokeInvokeAdHocParams(InvokeInvokeAdHocParams invokeInvokeAdHocParams) : base(invokeInvokeAdHocParams) { this._rawBodyData = new(invokeInvokeAdHocParams._rawBodyData); } +#pragma warning restore CS8618 public InvokeInvokeAdHocParams( IReadOnlyDictionary rawHeaderData, @@ -148,6 +155,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvokeInvokeAdHocParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -175,6 +204,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -1630,14 +1664,12 @@ JsonSerializerOptions options [JsonConverter(typeof(JsonModelConverter))] public sealed record class Webhook : JsonModel { - public required ApiEnum Method + public required ApiEnum Method { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("method"); + return this._rawData.GetNotNullClass>("method"); } init { this._rawData.Set("method", value); } } @@ -1719,7 +1751,7 @@ public Webhook FromRawUnchecked(IReadOnlyDictionary rawData Webhook.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Courier.Models.Automations.Invoke.MethodConverter))] +[JsonConverter(typeof(MethodConverter))] public enum Method { Get, @@ -1729,9 +1761,9 @@ public enum Method Delete, } -sealed class MethodConverter : JsonConverter +sealed class MethodConverter : JsonConverter { - public override global::Courier.Models.Automations.Invoke.Method Read( + public override Method Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1739,30 +1771,26 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "GET" => global::Courier.Models.Automations.Invoke.Method.Get, - "POST" => global::Courier.Models.Automations.Invoke.Method.Post, - "PUT" => global::Courier.Models.Automations.Invoke.Method.Put, - "PATCH" => global::Courier.Models.Automations.Invoke.Method.Patch, - "DELETE" => global::Courier.Models.Automations.Invoke.Method.Delete, - _ => (global::Courier.Models.Automations.Invoke.Method)(-1), + "GET" => Method.Get, + "POST" => Method.Post, + "PUT" => Method.Put, + "PATCH" => Method.Patch, + "DELETE" => Method.Delete, + _ => (Method)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Courier.Models.Automations.Invoke.Method value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Method value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Courier.Models.Automations.Invoke.Method.Get => "GET", - global::Courier.Models.Automations.Invoke.Method.Post => "POST", - global::Courier.Models.Automations.Invoke.Method.Put => "PUT", - global::Courier.Models.Automations.Invoke.Method.Patch => "PATCH", - global::Courier.Models.Automations.Invoke.Method.Delete => "DELETE", + Method.Get => "GET", + Method.Post => "POST", + Method.Put => "PUT", + Method.Patch => "PATCH", + Method.Delete => "DELETE", _ => throw new CourierInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Courier/Models/Automations/Invoke/InvokeInvokeByTemplateParams.cs b/src/Courier/Models/Automations/Invoke/InvokeInvokeByTemplateParams.cs index 777597a7..4f5ae30a 100644 --- a/src/Courier/Models/Automations/Invoke/InvokeInvokeByTemplateParams.cs +++ b/src/Courier/Models/Automations/Invoke/InvokeInvokeByTemplateParams.cs @@ -11,8 +11,12 @@ namespace Courier.Models.Automations.Invoke; /// /// Invoke an automation run from an automation template. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvokeInvokeByTemplateParams : ParamsBase +public record class InvokeInvokeByTemplateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -90,6 +94,8 @@ public string? Template public InvokeInvokeByTemplateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvokeInvokeByTemplateParams(InvokeInvokeByTemplateParams invokeInvokeByTemplateParams) : base(invokeInvokeByTemplateParams) { @@ -97,6 +103,7 @@ public InvokeInvokeByTemplateParams(InvokeInvokeByTemplateParams invokeInvokeByT this._rawBodyData = new(invokeInvokeByTemplateParams._rawBodyData); } +#pragma warning restore CS8618 public InvokeInvokeByTemplateParams( IReadOnlyDictionary rawHeaderData, @@ -137,6 +144,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["TemplateID"] = this.TemplateID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvokeInvokeByTemplateParams? other) + { + if (other == null) + { + return false; + } + return (this.TemplateID?.Equals(other.TemplateID) ?? other.TemplateID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -165,4 +196,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Brands/BrandCreateParams.cs b/src/Courier/Models/Brands/BrandCreateParams.cs index 846924a1..afd18595 100644 --- a/src/Courier/Models/Brands/BrandCreateParams.cs +++ b/src/Courier/Models/Brands/BrandCreateParams.cs @@ -11,8 +11,12 @@ namespace Courier.Models.Brands; /// /// Create a new brand +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BrandCreateParams : ParamsBase +public record class BrandCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -62,11 +66,14 @@ public BrandSnippets? Snippets public BrandCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BrandCreateParams(BrandCreateParams brandCreateParams) : base(brandCreateParams) { this._rawBodyData = new(brandCreateParams._rawBodyData); } +#pragma warning restore CS8618 public BrandCreateParams( IReadOnlyDictionary rawHeaderData, @@ -107,6 +114,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BrandCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/brands") @@ -132,4 +161,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Brands/BrandDeleteParams.cs b/src/Courier/Models/Brands/BrandDeleteParams.cs index fadfae34..a4a7a00e 100644 --- a/src/Courier/Models/Brands/BrandDeleteParams.cs +++ b/src/Courier/Models/Brands/BrandDeleteParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Brands; /// /// Delete a brand by brand ID. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BrandDeleteParams : ParamsBase +public record class BrandDeleteParams : ParamsBase { public string? BrandID { get; init; } public BrandDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BrandDeleteParams(BrandDeleteParams brandDeleteParams) : base(brandDeleteParams) { this.BrandID = brandDeleteParams.BrandID; } +#pragma warning restore CS8618 public BrandDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["BrandID"] = this.BrandID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BrandDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.BrandID?.Equals(other.BrandID) ?? other.BrandID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Brands/BrandListParams.cs b/src/Courier/Models/Brands/BrandListParams.cs index cf2292bf..19b649ec 100644 --- a/src/Courier/Models/Brands/BrandListParams.cs +++ b/src/Courier/Models/Brands/BrandListParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Brands; /// /// Get the list of brands. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BrandListParams : ParamsBase +public record class BrandListParams : ParamsBase { /// /// A unique identifier that allows for fetching the next set of brands. @@ -28,8 +32,11 @@ public string? Cursor public BrandListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BrandListParams(BrandListParams brandListParams) : base(brandListParams) { } +#pragma warning restore CS8618 public BrandListParams( IReadOnlyDictionary rawHeaderData, @@ -64,6 +71,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BrandListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/brands") @@ -80,4 +107,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Brands/BrandRetrieveParams.cs b/src/Courier/Models/Brands/BrandRetrieveParams.cs index 21dfab22..28695cc9 100644 --- a/src/Courier/Models/Brands/BrandRetrieveParams.cs +++ b/src/Courier/Models/Brands/BrandRetrieveParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Brands; /// /// Fetch a specific brand by brand ID. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BrandRetrieveParams : ParamsBase +public record class BrandRetrieveParams : ParamsBase { public string? BrandID { get; init; } public BrandRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BrandRetrieveParams(BrandRetrieveParams brandRetrieveParams) : base(brandRetrieveParams) { this.BrandID = brandRetrieveParams.BrandID; } +#pragma warning restore CS8618 public BrandRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["BrandID"] = this.BrandID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BrandRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.BrandID?.Equals(other.BrandID) ?? other.BrandID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Brands/BrandSettingsEmail.cs b/src/Courier/Models/Brands/BrandSettingsEmail.cs index 80a2a3be..722b2631 100644 --- a/src/Courier/Models/Brands/BrandSettingsEmail.cs +++ b/src/Courier/Models/Brands/BrandSettingsEmail.cs @@ -257,12 +257,7 @@ public TemplateOverride FromRawUnchecked(IReadOnlyDictionary) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class IntersectionMember1 : JsonModel { public required BrandTemplate Mjml @@ -305,9 +300,7 @@ public override void Validate() public IntersectionMember1() { } - public IntersectionMember1( - global::Courier.Models.Brands.IntersectionMember1 intersectionMember1 - ) + public IntersectionMember1(IntersectionMember1 intersectionMember1) : base(intersectionMember1) { } public IntersectionMember1(IReadOnlyDictionary rawData) @@ -323,8 +316,8 @@ public IntersectionMember1(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Courier.Models.Brands.IntersectionMember1 FromRawUnchecked( + /// + public static IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -339,10 +332,9 @@ public IntersectionMember1(BrandTemplate mjml) } } -class IntersectionMember1FromRaw : IFromRawJson +class IntersectionMember1FromRaw : IFromRawJson { /// - public global::Courier.Models.Brands.IntersectionMember1 FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Courier.Models.Brands.IntersectionMember1.FromRawUnchecked(rawData); + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/Courier/Models/Brands/BrandUpdateParams.cs b/src/Courier/Models/Brands/BrandUpdateParams.cs index b224ab11..e1b8d751 100644 --- a/src/Courier/Models/Brands/BrandUpdateParams.cs +++ b/src/Courier/Models/Brands/BrandUpdateParams.cs @@ -11,8 +11,12 @@ namespace Courier.Models.Brands; /// /// Replace an existing brand with the supplied values. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BrandUpdateParams : ParamsBase +public record class BrandUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -57,6 +61,8 @@ public BrandSnippets? Snippets public BrandUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BrandUpdateParams(BrandUpdateParams brandUpdateParams) : base(brandUpdateParams) { @@ -64,6 +70,7 @@ public BrandUpdateParams(BrandUpdateParams brandUpdateParams) this._rawBodyData = new(brandUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public BrandUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -104,6 +111,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["BrandID"] = this.BrandID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BrandUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.BrandID?.Equals(other.BrandID) ?? other.BrandID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -131,4 +162,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Bulk/BulkAddUsersParams.cs b/src/Courier/Models/Bulk/BulkAddUsersParams.cs index 11901f18..533cbdb7 100644 --- a/src/Courier/Models/Bulk/BulkAddUsersParams.cs +++ b/src/Courier/Models/Bulk/BulkAddUsersParams.cs @@ -15,9 +15,13 @@ namespace Courier.Models.Bulk; /// /// **Important**: For email-based bulk jobs, each user must include `profile.email` /// for provider routing to work correctly. The `to.email` field is not sufficient -/// for email provider routing. +/// for email provider routing. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BulkAddUsersParams : ParamsBase +public record class BulkAddUsersParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -47,6 +51,8 @@ public required IReadOnlyList Users public BulkAddUsersParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkAddUsersParams(BulkAddUsersParams bulkAddUsersParams) : base(bulkAddUsersParams) { @@ -54,6 +60,7 @@ public BulkAddUsersParams(BulkAddUsersParams bulkAddUsersParams) this._rawBodyData = new(bulkAddUsersParams._rawBodyData); } +#pragma warning restore CS8618 public BulkAddUsersParams( IReadOnlyDictionary rawHeaderData, @@ -94,6 +101,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["JobID"] = this.JobID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BulkAddUsersParams? other) + { + if (other == null) + { + return false; + } + return (this.JobID?.Equals(other.JobID) ?? other.JobID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -121,4 +152,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Bulk/BulkCreateJobParams.cs b/src/Courier/Models/Bulk/BulkCreateJobParams.cs index 57459ce9..3a1ede1b 100644 --- a/src/Courier/Models/Bulk/BulkCreateJobParams.cs +++ b/src/Courier/Models/Bulk/BulkCreateJobParams.cs @@ -16,9 +16,13 @@ namespace Courier.Models.Bulk; /// /// **Optional (V2 format)**: `message.template` (notification ID) or `message.content` /// (Elemental content) can be provided to override the notification associated -/// with the event. +/// with the event. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BulkCreateJobParams : ParamsBase +public record class BulkCreateJobParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -43,11 +47,14 @@ public required InboundBulkMessage Message public BulkCreateJobParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkCreateJobParams(BulkCreateJobParams bulkCreateJobParams) : base(bulkCreateJobParams) { this._rawBodyData = new(bulkCreateJobParams._rawBodyData); } +#pragma warning restore CS8618 public BulkCreateJobParams( IReadOnlyDictionary rawHeaderData, @@ -88,6 +95,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BulkCreateJobParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/bulk") @@ -113,4 +142,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Bulk/BulkListUsersParams.cs b/src/Courier/Models/Bulk/BulkListUsersParams.cs index 45cb4620..282803d6 100644 --- a/src/Courier/Models/Bulk/BulkListUsersParams.cs +++ b/src/Courier/Models/Bulk/BulkListUsersParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Bulk; /// /// Get Bulk Job Users +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BulkListUsersParams : ParamsBase +public record class BulkListUsersParams : ParamsBase { public string? JobID { get; init; } @@ -31,11 +35,14 @@ public string? Cursor public BulkListUsersParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkListUsersParams(BulkListUsersParams bulkListUsersParams) : base(bulkListUsersParams) { this.JobID = bulkListUsersParams.JobID; } +#pragma warning restore CS8618 public BulkListUsersParams( IReadOnlyDictionary rawHeaderData, @@ -70,6 +77,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["JobID"] = this.JobID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BulkListUsersParams? other) + { + if (other == null) + { + return false; + } + return (this.JobID?.Equals(other.JobID) ?? other.JobID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -88,4 +117,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Bulk/BulkListUsersResponse.cs b/src/Courier/Models/Bulk/BulkListUsersResponse.cs index b460063e..d2d79b6d 100644 --- a/src/Courier/Models/Bulk/BulkListUsersResponse.cs +++ b/src/Courier/Models/Bulk/BulkListUsersResponse.cs @@ -259,12 +259,7 @@ public Item FromRawUnchecked(IReadOnlyDictionary rawData) = Item.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Courier.Models.Bulk.IntersectionMember1, - global::Courier.Models.Bulk.IntersectionMember1FromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class IntersectionMember1 : JsonModel { public required ApiEnum Status @@ -296,7 +291,7 @@ public override void Validate() public IntersectionMember1() { } - public IntersectionMember1(global::Courier.Models.Bulk.IntersectionMember1 intersectionMember1) + public IntersectionMember1(IntersectionMember1 intersectionMember1) : base(intersectionMember1) { } public IntersectionMember1(IReadOnlyDictionary rawData) @@ -312,8 +307,8 @@ public IntersectionMember1(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Courier.Models.Bulk.IntersectionMember1 FromRawUnchecked( + /// + public static IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -328,12 +323,11 @@ public IntersectionMember1(ApiEnum status) } } -class IntersectionMember1FromRaw : IFromRawJson +class IntersectionMember1FromRaw : IFromRawJson { /// - public global::Courier.Models.Bulk.IntersectionMember1 FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Courier.Models.Bulk.IntersectionMember1.FromRawUnchecked(rawData); + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); } [JsonConverter(typeof(StatusConverter))] diff --git a/src/Courier/Models/Bulk/BulkRetrieveJobParams.cs b/src/Courier/Models/Bulk/BulkRetrieveJobParams.cs index 24aacaef..c2584878 100644 --- a/src/Courier/Models/Bulk/BulkRetrieveJobParams.cs +++ b/src/Courier/Models/Bulk/BulkRetrieveJobParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Bulk; /// /// Get a bulk job +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BulkRetrieveJobParams : ParamsBase +public record class BulkRetrieveJobParams : ParamsBase { public string? JobID { get; init; } public BulkRetrieveJobParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkRetrieveJobParams(BulkRetrieveJobParams bulkRetrieveJobParams) : base(bulkRetrieveJobParams) { this.JobID = bulkRetrieveJobParams.JobID; } +#pragma warning restore CS8618 public BulkRetrieveJobParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["JobID"] = this.JobID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BulkRetrieveJobParams? other) + { + if (other == null) + { + return false; + } + return (this.JobID?.Equals(other.JobID) ?? other.JobID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Bulk/BulkRunJobParams.cs b/src/Courier/Models/Bulk/BulkRunJobParams.cs index dacbebe8..b4fd8f9d 100644 --- a/src/Courier/Models/Bulk/BulkRunJobParams.cs +++ b/src/Courier/Models/Bulk/BulkRunJobParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Bulk; /// /// Run a bulk job +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BulkRunJobParams : ParamsBase +public record class BulkRunJobParams : ParamsBase { public string? JobID { get; init; } public BulkRunJobParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkRunJobParams(BulkRunJobParams bulkRunJobParams) : base(bulkRunJobParams) { this.JobID = bulkRunJobParams.JobID; } +#pragma warning restore CS8618 public BulkRunJobParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["JobID"] = this.JobID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BulkRunJobParams? other) + { + if (other == null) + { + return false; + } + return (this.JobID?.Equals(other.JobID) ?? other.JobID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Inbound/InboundTrackEventParams.cs b/src/Courier/Models/Inbound/InboundTrackEventParams.cs index 7c9ceca2..3f67ad92 100644 --- a/src/Courier/Models/Inbound/InboundTrackEventParams.cs +++ b/src/Courier/Models/Inbound/InboundTrackEventParams.cs @@ -13,8 +13,12 @@ namespace Courier.Models.Inbound; /// /// Courier Track Event +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InboundTrackEventParams : ParamsBase +public record class InboundTrackEventParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -95,11 +99,14 @@ public string? UserID public InboundTrackEventParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InboundTrackEventParams(InboundTrackEventParams inboundTrackEventParams) : base(inboundTrackEventParams) { this._rawBodyData = new(inboundTrackEventParams._rawBodyData); } +#pragma warning restore CS8618 public InboundTrackEventParams( IReadOnlyDictionary rawHeaderData, @@ -140,6 +147,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InboundTrackEventParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/inbound/courier") @@ -165,9 +194,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(global::Courier.Models.Inbound.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { Track, diff --git a/src/Courier/Models/Lists/ListDeleteParams.cs b/src/Courier/Models/Lists/ListDeleteParams.cs index eeaaca67..cda7042c 100644 --- a/src/Courier/Models/Lists/ListDeleteParams.cs +++ b/src/Courier/Models/Lists/ListDeleteParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Lists; /// /// Delete a list by list ID. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ListDeleteParams : ParamsBase +public record class ListDeleteParams : ParamsBase { public string? ListID { get; init; } public ListDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ListDeleteParams(ListDeleteParams listDeleteParams) : base(listDeleteParams) { this.ListID = listDeleteParams.ListID; } +#pragma warning restore CS8618 public ListDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ListID"] = this.ListID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ListDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.ListID?.Equals(other.ListID) ?? other.ListID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Lists/ListListParams.cs b/src/Courier/Models/Lists/ListListParams.cs index 732d4927..40aaaeff 100644 --- a/src/Courier/Models/Lists/ListListParams.cs +++ b/src/Courier/Models/Lists/ListListParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Lists; /// /// Returns all of the lists, with the ability to filter based on a pattern. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ListListParams : ParamsBase +public record class ListListParams : ParamsBase { /// /// A unique identifier that allows for fetching the next page of lists. @@ -44,8 +48,11 @@ public string? Pattern public ListListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ListListParams(ListListParams listListParams) : base(listListParams) { } +#pragma warning restore CS8618 public ListListParams( IReadOnlyDictionary rawHeaderData, @@ -80,6 +87,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ListListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/lists") @@ -96,4 +123,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Lists/ListRestoreParams.cs b/src/Courier/Models/Lists/ListRestoreParams.cs index ac1d636c..866d7778 100644 --- a/src/Courier/Models/Lists/ListRestoreParams.cs +++ b/src/Courier/Models/Lists/ListRestoreParams.cs @@ -11,8 +11,12 @@ namespace Courier.Models.Lists; /// /// Restore a previously deleted list. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ListRestoreParams : ParamsBase +public record class ListRestoreParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -24,6 +28,8 @@ public IReadOnlyDictionary RawBodyData public ListRestoreParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ListRestoreParams(ListRestoreParams listRestoreParams) : base(listRestoreParams) { @@ -31,6 +37,7 @@ public ListRestoreParams(ListRestoreParams listRestoreParams) this._rawBodyData = new(listRestoreParams._rawBodyData); } +#pragma warning restore CS8618 public ListRestoreParams( IReadOnlyDictionary rawHeaderData, @@ -71,6 +78,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ListID"] = this.ListID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ListRestoreParams? other) + { + if (other == null) + { + return false; + } + return (this.ListID?.Equals(other.ListID) ?? other.ListID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -99,4 +130,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Lists/ListRetrieveParams.cs b/src/Courier/Models/Lists/ListRetrieveParams.cs index 5716ba0f..cf646d33 100644 --- a/src/Courier/Models/Lists/ListRetrieveParams.cs +++ b/src/Courier/Models/Lists/ListRetrieveParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Lists; /// /// Returns a list based on the list ID provided. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ListRetrieveParams : ParamsBase +public record class ListRetrieveParams : ParamsBase { public string? ListID { get; init; } public ListRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ListRetrieveParams(ListRetrieveParams listRetrieveParams) : base(listRetrieveParams) { this.ListID = listRetrieveParams.ListID; } +#pragma warning restore CS8618 public ListRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ListID"] = this.ListID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ListRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.ListID?.Equals(other.ListID) ?? other.ListID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Lists/ListUpdateParams.cs b/src/Courier/Models/Lists/ListUpdateParams.cs index 9ab1868c..0dbd6fd7 100644 --- a/src/Courier/Models/Lists/ListUpdateParams.cs +++ b/src/Courier/Models/Lists/ListUpdateParams.cs @@ -11,8 +11,12 @@ namespace Courier.Models.Lists; /// /// Create or replace an existing list with the supplied values. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ListUpdateParams : ParamsBase +public record class ListUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -44,6 +48,8 @@ public RecipientPreferences? Preferences public ListUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ListUpdateParams(ListUpdateParams listUpdateParams) : base(listUpdateParams) { @@ -51,6 +57,7 @@ public ListUpdateParams(ListUpdateParams listUpdateParams) this._rawBodyData = new(listUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public ListUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -91,6 +98,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ListID"] = this.ListID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ListUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.ListID?.Equals(other.ListID) ?? other.ListID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -118,4 +149,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Lists/Subscriptions/SubscriptionAddParams.cs b/src/Courier/Models/Lists/Subscriptions/SubscriptionAddParams.cs index 8b5b682c..a8e314e9 100644 --- a/src/Courier/Models/Lists/Subscriptions/SubscriptionAddParams.cs +++ b/src/Courier/Models/Lists/Subscriptions/SubscriptionAddParams.cs @@ -13,8 +13,12 @@ namespace Courier.Models.Lists.Subscriptions; /// /// Subscribes additional users to the list, without modifying existing subscriptions. /// If the list does not exist, it will be automatically created. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionAddParams : ParamsBase +public record class SubscriptionAddParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -44,6 +48,8 @@ public required IReadOnlyList Recipients public SubscriptionAddParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionAddParams(SubscriptionAddParams subscriptionAddParams) : base(subscriptionAddParams) { @@ -51,6 +57,7 @@ public SubscriptionAddParams(SubscriptionAddParams subscriptionAddParams) this._rawBodyData = new(subscriptionAddParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionAddParams( IReadOnlyDictionary rawHeaderData, @@ -91,6 +98,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ListID"] = this.ListID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionAddParams? other) + { + if (other == null) + { + return false; + } + return (this.ListID?.Equals(other.ListID) ?? other.ListID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -119,4 +150,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Lists/Subscriptions/SubscriptionListParams.cs b/src/Courier/Models/Lists/Subscriptions/SubscriptionListParams.cs index de7caacf..ce1ed4bd 100644 --- a/src/Courier/Models/Lists/Subscriptions/SubscriptionListParams.cs +++ b/src/Courier/Models/Lists/Subscriptions/SubscriptionListParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Lists.Subscriptions; /// /// Get the list's subscriptions. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionListParams : ParamsBase +public record class SubscriptionListParams : ParamsBase { public string? ListID { get; init; } @@ -30,11 +34,14 @@ public string? Cursor public SubscriptionListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionListParams(SubscriptionListParams subscriptionListParams) : base(subscriptionListParams) { this.ListID = subscriptionListParams.ListID; } +#pragma warning restore CS8618 public SubscriptionListParams( IReadOnlyDictionary rawHeaderData, @@ -69,6 +76,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ListID"] = this.ListID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionListParams? other) + { + if (other == null) + { + return false; + } + return (this.ListID?.Equals(other.ListID) ?? other.ListID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -88,4 +117,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Lists/Subscriptions/SubscriptionSubscribeParams.cs b/src/Courier/Models/Lists/Subscriptions/SubscriptionSubscribeParams.cs index de4b3867..b30792aa 100644 --- a/src/Courier/Models/Lists/Subscriptions/SubscriptionSubscribeParams.cs +++ b/src/Courier/Models/Lists/Subscriptions/SubscriptionSubscribeParams.cs @@ -13,8 +13,12 @@ namespace Courier.Models.Lists.Subscriptions; /// /// Subscribes the users to the list, overwriting existing subscriptions. If the list /// does not exist, it will be automatically created. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionSubscribeParams : ParamsBase +public record class SubscriptionSubscribeParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -44,6 +48,8 @@ public required IReadOnlyList Recipients public SubscriptionSubscribeParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSubscribeParams(SubscriptionSubscribeParams subscriptionSubscribeParams) : base(subscriptionSubscribeParams) { @@ -51,6 +57,7 @@ public SubscriptionSubscribeParams(SubscriptionSubscribeParams subscriptionSubsc this._rawBodyData = new(subscriptionSubscribeParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionSubscribeParams( IReadOnlyDictionary rawHeaderData, @@ -91,6 +98,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ListID"] = this.ListID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionSubscribeParams? other) + { + if (other == null) + { + return false; + } + return (this.ListID?.Equals(other.ListID) ?? other.ListID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -119,4 +150,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Lists/Subscriptions/SubscriptionSubscribeUserParams.cs b/src/Courier/Models/Lists/Subscriptions/SubscriptionSubscribeUserParams.cs index a06b743f..9e234adb 100644 --- a/src/Courier/Models/Lists/Subscriptions/SubscriptionSubscribeUserParams.cs +++ b/src/Courier/Models/Lists/Subscriptions/SubscriptionSubscribeUserParams.cs @@ -12,8 +12,12 @@ namespace Courier.Models.Lists.Subscriptions; /// /// Subscribe a user to an existing list (note: if the List does not exist, it will /// be automatically created). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionSubscribeUserParams : ParamsBase +public record class SubscriptionSubscribeUserParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -37,6 +41,8 @@ public RecipientPreferences? Preferences public SubscriptionSubscribeUserParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSubscribeUserParams( SubscriptionSubscribeUserParams subscriptionSubscribeUserParams ) @@ -47,6 +53,7 @@ SubscriptionSubscribeUserParams subscriptionSubscribeUserParams this._rawBodyData = new(subscriptionSubscribeUserParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionSubscribeUserParams( IReadOnlyDictionary rawHeaderData, @@ -87,6 +94,32 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ListID"] = this.ListID, + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionSubscribeUserParams? other) + { + if (other == null) + { + return false; + } + return this.ListID.Equals(other.ListID) + && (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -115,4 +148,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Lists/Subscriptions/SubscriptionUnsubscribeUserParams.cs b/src/Courier/Models/Lists/Subscriptions/SubscriptionUnsubscribeUserParams.cs index 5ff661ac..2f051761 100644 --- a/src/Courier/Models/Lists/Subscriptions/SubscriptionUnsubscribeUserParams.cs +++ b/src/Courier/Models/Lists/Subscriptions/SubscriptionUnsubscribeUserParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Lists.Subscriptions; /// /// Delete a subscription to a list by list ID and user ID. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionUnsubscribeUserParams : ParamsBase +public record class SubscriptionUnsubscribeUserParams : ParamsBase { public required string ListID { get; init; } @@ -19,6 +23,8 @@ public sealed record class SubscriptionUnsubscribeUserParams : ParamsBase public SubscriptionUnsubscribeUserParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionUnsubscribeUserParams( SubscriptionUnsubscribeUserParams subscriptionUnsubscribeUserParams ) @@ -27,6 +33,7 @@ SubscriptionUnsubscribeUserParams subscriptionUnsubscribeUserParams this.ListID = subscriptionUnsubscribeUserParams.ListID; this.UserID = subscriptionUnsubscribeUserParams.UserID; } +#pragma warning restore CS8618 public SubscriptionUnsubscribeUserParams( IReadOnlyDictionary rawHeaderData, @@ -61,6 +68,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ListID"] = this.ListID, + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionUnsubscribeUserParams? other) + { + if (other == null) + { + return false; + } + return this.ListID.Equals(other.ListID) + && (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -80,4 +111,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Messages/MessageCancelParams.cs b/src/Courier/Models/Messages/MessageCancelParams.cs index 976cd48a..1565c53f 100644 --- a/src/Courier/Models/Messages/MessageCancelParams.cs +++ b/src/Courier/Models/Messages/MessageCancelParams.cs @@ -13,18 +13,25 @@ namespace Courier.Models.Messages; /// API call to the cancel message API will return either `200` status code for a /// successful cancellation or `409` status code for an unsuccessful cancellation. /// Both cases will include the actual message record in the response body (see details below). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MessageCancelParams : ParamsBase +public record class MessageCancelParams : ParamsBase { public string? MessageID { get; init; } public MessageCancelParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MessageCancelParams(MessageCancelParams messageCancelParams) : base(messageCancelParams) { this.MessageID = messageCancelParams.MessageID; } +#pragma warning restore CS8618 public MessageCancelParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["MessageID"] = this.MessageID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MessageCancelParams? other) + { + if (other == null) + { + return false; + } + return (this.MessageID?.Equals(other.MessageID) ?? other.MessageID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -78,4 +107,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Messages/MessageContentParams.cs b/src/Courier/Models/Messages/MessageContentParams.cs index 5f2d0298..0fe1b562 100644 --- a/src/Courier/Models/Messages/MessageContentParams.cs +++ b/src/Courier/Models/Messages/MessageContentParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Messages; /// /// Get message content +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MessageContentParams : ParamsBase +public record class MessageContentParams : ParamsBase { public string? MessageID { get; init; } public MessageContentParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MessageContentParams(MessageContentParams messageContentParams) : base(messageContentParams) { this.MessageID = messageContentParams.MessageID; } +#pragma warning restore CS8618 public MessageContentParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["MessageID"] = this.MessageID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MessageContentParams? other) + { + if (other == null) + { + return false; + } + return (this.MessageID?.Equals(other.MessageID) ?? other.MessageID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Messages/MessageHistoryParams.cs b/src/Courier/Models/Messages/MessageHistoryParams.cs index ac6f253f..29d1e8a2 100644 --- a/src/Courier/Models/Messages/MessageHistoryParams.cs +++ b/src/Courier/Models/Messages/MessageHistoryParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Messages; /// /// Fetch the array of events of a message you've previously sent. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MessageHistoryParams : ParamsBase +public record class MessageHistoryParams : ParamsBase { public string? MessageID { get; init; } @@ -30,11 +34,14 @@ public string? Type public MessageHistoryParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MessageHistoryParams(MessageHistoryParams messageHistoryParams) : base(messageHistoryParams) { this.MessageID = messageHistoryParams.MessageID; } +#pragma warning restore CS8618 public MessageHistoryParams( IReadOnlyDictionary rawHeaderData, @@ -69,6 +76,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["MessageID"] = this.MessageID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MessageHistoryParams? other) + { + if (other == null) + { + return false; + } + return (this.MessageID?.Equals(other.MessageID) ?? other.MessageID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -88,4 +117,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Messages/MessageListParams.cs b/src/Courier/Models/Messages/MessageListParams.cs index 0be3d68d..910c1976 100644 --- a/src/Courier/Models/Messages/MessageListParams.cs +++ b/src/Courier/Models/Messages/MessageListParams.cs @@ -11,8 +11,12 @@ namespace Courier.Models.Messages; /// /// Fetch the statuses of messages you've previously sent. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MessageListParams : ParamsBase +public record class MessageListParams : ParamsBase { /// /// A boolean value that indicates whether archived messages should be included @@ -237,8 +241,11 @@ public string? TraceID public MessageListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MessageListParams(MessageListParams messageListParams) : base(messageListParams) { } +#pragma warning restore CS8618 public MessageListParams( IReadOnlyDictionary rawHeaderData, @@ -273,6 +280,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MessageListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/messages") @@ -289,4 +316,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Messages/MessageRetrieveParams.cs b/src/Courier/Models/Messages/MessageRetrieveParams.cs index 4ef808b8..bbb9807e 100644 --- a/src/Courier/Models/Messages/MessageRetrieveParams.cs +++ b/src/Courier/Models/Messages/MessageRetrieveParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Messages; /// /// Fetch the status of a message you've previously sent. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MessageRetrieveParams : ParamsBase +public record class MessageRetrieveParams : ParamsBase { public string? MessageID { get; init; } public MessageRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MessageRetrieveParams(MessageRetrieveParams messageRetrieveParams) : base(messageRetrieveParams) { this.MessageID = messageRetrieveParams.MessageID; } +#pragma warning restore CS8618 public MessageRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["MessageID"] = this.MessageID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MessageRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.MessageID?.Equals(other.MessageID) ?? other.MessageID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Messages/MessageRetrieveResponse.cs b/src/Courier/Models/Messages/MessageRetrieveResponse.cs index 1fdac328..ab6285ac 100644 --- a/src/Courier/Models/Messages/MessageRetrieveResponse.cs +++ b/src/Courier/Models/Messages/MessageRetrieveResponse.cs @@ -271,12 +271,7 @@ IReadOnlyDictionary rawData ) => MessageRetrieveResponse.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Courier.Models.Messages.IntersectionMember1, - global::Courier.Models.Messages.IntersectionMember1FromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class IntersectionMember1 : JsonModel { public IReadOnlyList>? Providers @@ -312,9 +307,7 @@ public override void Validate() public IntersectionMember1() { } - public IntersectionMember1( - global::Courier.Models.Messages.IntersectionMember1 intersectionMember1 - ) + public IntersectionMember1(IntersectionMember1 intersectionMember1) : base(intersectionMember1) { } public IntersectionMember1(IReadOnlyDictionary rawData) @@ -330,8 +323,8 @@ public IntersectionMember1(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Courier.Models.Messages.IntersectionMember1 FromRawUnchecked( + /// + public static IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -339,10 +332,9 @@ IReadOnlyDictionary rawData } } -class IntersectionMember1FromRaw : IFromRawJson +class IntersectionMember1FromRaw : IFromRawJson { /// - public global::Courier.Models.Messages.IntersectionMember1 FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Courier.Models.Messages.IntersectionMember1.FromRawUnchecked(rawData); + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/Courier/Models/Notifications/BaseCheck.cs b/src/Courier/Models/Notifications/BaseCheck.cs index d7b50638..403a5de2 100644 --- a/src/Courier/Models/Notifications/BaseCheck.cs +++ b/src/Courier/Models/Notifications/BaseCheck.cs @@ -127,7 +127,7 @@ public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOp } } -[JsonConverter(typeof(global::Courier.Models.Notifications.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { Custom, diff --git a/src/Courier/Models/Notifications/Check.cs b/src/Courier/Models/Notifications/Check.cs index 76b6bfa5..89804778 100644 --- a/src/Courier/Models/Notifications/Check.cs +++ b/src/Courier/Models/Notifications/Check.cs @@ -30,14 +30,12 @@ public required ApiEnum Status init { this._rawData.Set("status", value); } } - public required ApiEnum Type + public required ApiEnum Type { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("type"); + return this._rawData.GetNotNullClass>("type"); } init { this._rawData.Set("type", value); } } @@ -101,12 +99,7 @@ public Check FromRawUnchecked(IReadOnlyDictionary rawData) Check.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Courier.Models.Notifications.IntersectionMember1, - global::Courier.Models.Notifications.IntersectionMember1FromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class IntersectionMember1 : JsonModel { public required long Updated @@ -127,9 +120,7 @@ public override void Validate() public IntersectionMember1() { } - public IntersectionMember1( - global::Courier.Models.Notifications.IntersectionMember1 intersectionMember1 - ) + public IntersectionMember1(IntersectionMember1 intersectionMember1) : base(intersectionMember1) { } public IntersectionMember1(IReadOnlyDictionary rawData) @@ -145,8 +136,8 @@ public IntersectionMember1(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Courier.Models.Notifications.IntersectionMember1 FromRawUnchecked( + /// + public static IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -161,11 +152,9 @@ public IntersectionMember1(long updated) } } -class IntersectionMember1FromRaw - : IFromRawJson +class IntersectionMember1FromRaw : IFromRawJson { /// - public global::Courier.Models.Notifications.IntersectionMember1 FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Courier.Models.Notifications.IntersectionMember1.FromRawUnchecked(rawData); + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/Courier/Models/Notifications/Checks/CheckDeleteParams.cs b/src/Courier/Models/Notifications/Checks/CheckDeleteParams.cs index e6bba1ca..57931c1f 100644 --- a/src/Courier/Models/Notifications/Checks/CheckDeleteParams.cs +++ b/src/Courier/Models/Notifications/Checks/CheckDeleteParams.cs @@ -8,7 +8,12 @@ namespace Courier.Models.Notifications.Checks; -public sealed record class CheckDeleteParams : ParamsBase +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public record class CheckDeleteParams : ParamsBase { public required string ID { get; init; } @@ -16,12 +21,15 @@ public sealed record class CheckDeleteParams : ParamsBase public CheckDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CheckDeleteParams(CheckDeleteParams checkDeleteParams) : base(checkDeleteParams) { this.ID = checkDeleteParams.ID; this.SubmissionID = checkDeleteParams.SubmissionID; } +#pragma warning restore CS8618 public CheckDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +64,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["SubmissionID"] = this.SubmissionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CheckDeleteParams? other) + { + if (other == null) + { + return false; + } + return this.ID.Equals(other.ID) + && (this.SubmissionID?.Equals(other.SubmissionID) ?? other.SubmissionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +107,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Notifications/Checks/CheckListParams.cs b/src/Courier/Models/Notifications/Checks/CheckListParams.cs index d43c2568..f7b59651 100644 --- a/src/Courier/Models/Notifications/Checks/CheckListParams.cs +++ b/src/Courier/Models/Notifications/Checks/CheckListParams.cs @@ -8,7 +8,12 @@ namespace Courier.Models.Notifications.Checks; -public sealed record class CheckListParams : ParamsBase +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public record class CheckListParams : ParamsBase { public required string ID { get; init; } @@ -16,12 +21,15 @@ public sealed record class CheckListParams : ParamsBase public CheckListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CheckListParams(CheckListParams checkListParams) : base(checkListParams) { this.ID = checkListParams.ID; this.SubmissionID = checkListParams.SubmissionID; } +#pragma warning restore CS8618 public CheckListParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +64,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["SubmissionID"] = this.SubmissionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CheckListParams? other) + { + if (other == null) + { + return false; + } + return this.ID.Equals(other.ID) + && (this.SubmissionID?.Equals(other.SubmissionID) ?? other.SubmissionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +107,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Notifications/Checks/CheckUpdateParams.cs b/src/Courier/Models/Notifications/Checks/CheckUpdateParams.cs index 912629ab..2a4847e7 100644 --- a/src/Courier/Models/Notifications/Checks/CheckUpdateParams.cs +++ b/src/Courier/Models/Notifications/Checks/CheckUpdateParams.cs @@ -10,7 +10,12 @@ namespace Courier.Models.Notifications.Checks; -public sealed record class CheckUpdateParams : ParamsBase +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public record class CheckUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -40,6 +45,8 @@ public required IReadOnlyList Checks public CheckUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CheckUpdateParams(CheckUpdateParams checkUpdateParams) : base(checkUpdateParams) { @@ -48,6 +55,7 @@ public CheckUpdateParams(CheckUpdateParams checkUpdateParams) this._rawBodyData = new(checkUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public CheckUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -88,6 +96,32 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["SubmissionID"] = this.SubmissionID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CheckUpdateParams? other) + { + if (other == null) + { + return false; + } + return this.ID.Equals(other.ID) + && (this.SubmissionID?.Equals(other.SubmissionID) ?? other.SubmissionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -116,4 +150,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Notifications/Draft/DraftRetrieveContentParams.cs b/src/Courier/Models/Notifications/Draft/DraftRetrieveContentParams.cs index 4bf42a1d..a4f3051c 100644 --- a/src/Courier/Models/Notifications/Draft/DraftRetrieveContentParams.cs +++ b/src/Courier/Models/Notifications/Draft/DraftRetrieveContentParams.cs @@ -8,17 +8,25 @@ namespace Courier.Models.Notifications.Draft; -public sealed record class DraftRetrieveContentParams : ParamsBase +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public record class DraftRetrieveContentParams : ParamsBase { public string? ID { get; init; } public DraftRetrieveContentParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DraftRetrieveContentParams(DraftRetrieveContentParams draftRetrieveContentParams) : base(draftRetrieveContentParams) { this.ID = draftRetrieveContentParams.ID; } +#pragma warning restore CS8618 public DraftRetrieveContentParams( IReadOnlyDictionary rawHeaderData, @@ -53,6 +61,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(DraftRetrieveContentParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -72,4 +102,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Notifications/NotificationListParams.cs b/src/Courier/Models/Notifications/NotificationListParams.cs index 7e8e5e56..c09ae35a 100644 --- a/src/Courier/Models/Notifications/NotificationListParams.cs +++ b/src/Courier/Models/Notifications/NotificationListParams.cs @@ -8,7 +8,12 @@ namespace Courier.Models.Notifications; -public sealed record class NotificationListParams : ParamsBase +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public record class NotificationListParams : ParamsBase { public string? Cursor { @@ -35,8 +40,11 @@ public bool? Notes public NotificationListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NotificationListParams(NotificationListParams notificationListParams) : base(notificationListParams) { } +#pragma warning restore CS8618 public NotificationListParams( IReadOnlyDictionary rawHeaderData, @@ -71,6 +79,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(NotificationListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/notifications") @@ -87,4 +115,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Notifications/NotificationRetrieveContentParams.cs b/src/Courier/Models/Notifications/NotificationRetrieveContentParams.cs index ce0b1230..1451781f 100644 --- a/src/Courier/Models/Notifications/NotificationRetrieveContentParams.cs +++ b/src/Courier/Models/Notifications/NotificationRetrieveContentParams.cs @@ -8,12 +8,19 @@ namespace Courier.Models.Notifications; -public sealed record class NotificationRetrieveContentParams : ParamsBase +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking +/// changes in non-major versions. We may add new methods in the future that cause +/// existing derived classes to break. +/// +public record class NotificationRetrieveContentParams : ParamsBase { public string? ID { get; init; } public NotificationRetrieveContentParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NotificationRetrieveContentParams( NotificationRetrieveContentParams notificationRetrieveContentParams ) @@ -21,6 +28,7 @@ NotificationRetrieveContentParams notificationRetrieveContentParams { this.ID = notificationRetrieveContentParams.ID; } +#pragma warning restore CS8618 public NotificationRetrieveContentParams( IReadOnlyDictionary rawHeaderData, @@ -55,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["ID"] = this.ID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(NotificationRetrieveContentParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Profiles/Lists/ListDeleteParams.cs b/src/Courier/Models/Profiles/Lists/ListDeleteParams.cs index 86965205..dbaf619f 100644 --- a/src/Courier/Models/Profiles/Lists/ListDeleteParams.cs +++ b/src/Courier/Models/Profiles/Lists/ListDeleteParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Profiles.Lists; /// /// Removes all list subscriptions for given user. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ListDeleteParams : ParamsBase +public record class ListDeleteParams : ParamsBase { public string? UserID { get; init; } public ListDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ListDeleteParams(ListDeleteParams listDeleteParams) : base(listDeleteParams) { this.UserID = listDeleteParams.UserID; } +#pragma warning restore CS8618 public ListDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ListDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Profiles/Lists/ListDeleteResponse.cs b/src/Courier/Models/Profiles/Lists/ListDeleteResponse.cs index 2191a7ea..b1a8652f 100644 --- a/src/Courier/Models/Profiles/Lists/ListDeleteResponse.cs +++ b/src/Courier/Models/Profiles/Lists/ListDeleteResponse.cs @@ -12,14 +12,12 @@ namespace Courier.Models.Profiles.Lists; [JsonConverter(typeof(JsonModelConverter))] public sealed record class ListDeleteResponse : JsonModel { - public required ApiEnum Status + public required ApiEnum Status { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("status"); + return this._rawData.GetNotNullClass>("status"); } init { this._rawData.Set("status", value); } } @@ -57,7 +55,7 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public ListDeleteResponse(ApiEnum status) + public ListDeleteResponse(ApiEnum status) : this() { this.Status = status; @@ -71,15 +69,15 @@ public ListDeleteResponse FromRawUnchecked(IReadOnlyDictionary +sealed class StatusConverter : JsonConverter { - public override global::Courier.Models.Profiles.Lists.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -87,22 +85,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "SUCCESS" => global::Courier.Models.Profiles.Lists.Status.Success, - _ => (global::Courier.Models.Profiles.Lists.Status)(-1), + "SUCCESS" => Status.Success, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Courier.Models.Profiles.Lists.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Courier.Models.Profiles.Lists.Status.Success => "SUCCESS", + Status.Success => "SUCCESS", _ => throw new CourierInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Courier/Models/Profiles/Lists/ListRetrieveParams.cs b/src/Courier/Models/Profiles/Lists/ListRetrieveParams.cs index 1bb291e9..63f26a88 100644 --- a/src/Courier/Models/Profiles/Lists/ListRetrieveParams.cs +++ b/src/Courier/Models/Profiles/Lists/ListRetrieveParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Profiles.Lists; /// /// Returns the subscribed lists for a specified user. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ListRetrieveParams : ParamsBase +public record class ListRetrieveParams : ParamsBase { public string? UserID { get; init; } @@ -30,11 +34,14 @@ public string? Cursor public ListRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ListRetrieveParams(ListRetrieveParams listRetrieveParams) : base(listRetrieveParams) { this.UserID = listRetrieveParams.UserID; } +#pragma warning restore CS8618 public ListRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -69,6 +76,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ListRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -88,4 +117,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Profiles/Lists/ListSubscribeParams.cs b/src/Courier/Models/Profiles/Lists/ListSubscribeParams.cs index 481b9c8b..ef2a7a74 100644 --- a/src/Courier/Models/Profiles/Lists/ListSubscribeParams.cs +++ b/src/Courier/Models/Profiles/Lists/ListSubscribeParams.cs @@ -13,8 +13,12 @@ namespace Courier.Models.Profiles.Lists; /// /// Subscribes the given user to one or more lists. If the list does not exist, it /// will be created. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ListSubscribeParams : ParamsBase +public record class ListSubscribeParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -44,6 +48,8 @@ public required IReadOnlyList Lists public ListSubscribeParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ListSubscribeParams(ListSubscribeParams listSubscribeParams) : base(listSubscribeParams) { @@ -51,6 +57,7 @@ public ListSubscribeParams(ListSubscribeParams listSubscribeParams) this._rawBodyData = new(listSubscribeParams._rawBodyData); } +#pragma warning restore CS8618 public ListSubscribeParams( IReadOnlyDictionary rawHeaderData, @@ -91,6 +98,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ListSubscribeParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -119,4 +150,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Profiles/ProfileCreateParams.cs b/src/Courier/Models/Profiles/ProfileCreateParams.cs index aa0402ac..8d3d961c 100644 --- a/src/Courier/Models/Profiles/ProfileCreateParams.cs +++ b/src/Courier/Models/Profiles/ProfileCreateParams.cs @@ -12,8 +12,12 @@ namespace Courier.Models.Profiles; /// /// Merge the supplied values with an existing profile or create a new profile if /// one doesn't already exist. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ProfileCreateParams : ParamsBase +public record class ProfileCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -43,6 +47,8 @@ public required IReadOnlyDictionary Profile public ProfileCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ProfileCreateParams(ProfileCreateParams profileCreateParams) : base(profileCreateParams) { @@ -50,6 +56,7 @@ public ProfileCreateParams(ProfileCreateParams profileCreateParams) this._rawBodyData = new(profileCreateParams._rawBodyData); } +#pragma warning restore CS8618 public ProfileCreateParams( IReadOnlyDictionary rawHeaderData, @@ -90,6 +97,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ProfileCreateParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -117,4 +148,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Profiles/ProfileDeleteParams.cs b/src/Courier/Models/Profiles/ProfileDeleteParams.cs index 73292e4d..c9387ff4 100644 --- a/src/Courier/Models/Profiles/ProfileDeleteParams.cs +++ b/src/Courier/Models/Profiles/ProfileDeleteParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Profiles; /// /// Deletes the specified user profile. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ProfileDeleteParams : ParamsBase +public record class ProfileDeleteParams : ParamsBase { public string? UserID { get; init; } public ProfileDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ProfileDeleteParams(ProfileDeleteParams profileDeleteParams) : base(profileDeleteParams) { this.UserID = profileDeleteParams.UserID; } +#pragma warning restore CS8618 public ProfileDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ProfileDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Profiles/ProfileReplaceParams.cs b/src/Courier/Models/Profiles/ProfileReplaceParams.cs index 4aab1962..3db754b3 100644 --- a/src/Courier/Models/Profiles/ProfileReplaceParams.cs +++ b/src/Courier/Models/Profiles/ProfileReplaceParams.cs @@ -15,8 +15,12 @@ namespace Courier.Models.Profiles; /// to be included in the `PUT` request will be removed from the profile. Remember, /// a `PUT` update is a full replacement of the data. For partial updates, use the /// [Patch](https://www.courier.com/docs/reference/profiles/patch/) request. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ProfileReplaceParams : ParamsBase +public record class ProfileReplaceParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -46,6 +50,8 @@ public required IReadOnlyDictionary Profile public ProfileReplaceParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ProfileReplaceParams(ProfileReplaceParams profileReplaceParams) : base(profileReplaceParams) { @@ -53,6 +59,7 @@ public ProfileReplaceParams(ProfileReplaceParams profileReplaceParams) this._rawBodyData = new(profileReplaceParams._rawBodyData); } +#pragma warning restore CS8618 public ProfileReplaceParams( IReadOnlyDictionary rawHeaderData, @@ -93,6 +100,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ProfileReplaceParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -120,4 +151,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Profiles/ProfileRetrieveParams.cs b/src/Courier/Models/Profiles/ProfileRetrieveParams.cs index 5c428891..218666d2 100644 --- a/src/Courier/Models/Profiles/ProfileRetrieveParams.cs +++ b/src/Courier/Models/Profiles/ProfileRetrieveParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Profiles; /// /// Returns the specified user profile. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ProfileRetrieveParams : ParamsBase +public record class ProfileRetrieveParams : ParamsBase { public string? UserID { get; init; } public ProfileRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ProfileRetrieveParams(ProfileRetrieveParams profileRetrieveParams) : base(profileRetrieveParams) { this.UserID = profileRetrieveParams.UserID; } +#pragma warning restore CS8618 public ProfileRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ProfileRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Profiles/ProfileUpdateParams.cs b/src/Courier/Models/Profiles/ProfileUpdateParams.cs index 1b2906a8..7088a208 100644 --- a/src/Courier/Models/Profiles/ProfileUpdateParams.cs +++ b/src/Courier/Models/Profiles/ProfileUpdateParams.cs @@ -13,8 +13,12 @@ namespace Courier.Models.Profiles; /// /// Update a profile +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ProfileUpdateParams : ParamsBase +public record class ProfileUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -45,6 +49,8 @@ public required IReadOnlyList Patch public ProfileUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ProfileUpdateParams(ProfileUpdateParams profileUpdateParams) : base(profileUpdateParams) { @@ -52,6 +58,7 @@ public ProfileUpdateParams(ProfileUpdateParams profileUpdateParams) this._rawBodyData = new(profileUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public ProfileUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -92,6 +99,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ProfileUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -119,6 +150,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] diff --git a/src/Courier/Models/Requests/RequestArchiveParams.cs b/src/Courier/Models/Requests/RequestArchiveParams.cs index 3390b22d..5f2ae8a6 100644 --- a/src/Courier/Models/Requests/RequestArchiveParams.cs +++ b/src/Courier/Models/Requests/RequestArchiveParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Requests; /// /// Archive message +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class RequestArchiveParams : ParamsBase +public record class RequestArchiveParams : ParamsBase { public string? RequestID { get; init; } public RequestArchiveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public RequestArchiveParams(RequestArchiveParams requestArchiveParams) : base(requestArchiveParams) { this.RequestID = requestArchiveParams.RequestID; } +#pragma warning restore CS8618 public RequestArchiveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["RequestID"] = this.RequestID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(RequestArchiveParams? other) + { + if (other == null) + { + return false; + } + return (this.RequestID?.Equals(other.RequestID) ?? other.RequestID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Send/SendMessageParams.cs b/src/Courier/Models/Send/SendMessageParams.cs index 0af82bfc..c8511f8a 100644 --- a/src/Courier/Models/Send/SendMessageParams.cs +++ b/src/Courier/Models/Send/SendMessageParams.cs @@ -14,8 +14,12 @@ namespace Courier.Models.Send; /// /// Send a message to one or more recipients. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SendMessageParams : ParamsBase +public record class SendMessageParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -39,11 +43,14 @@ public required Message Message public SendMessageParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SendMessageParams(SendMessageParams sendMessageParams) : base(sendMessageParams) { this._rawBodyData = new(sendMessageParams._rawBodyData); } +#pragma warning restore CS8618 public SendMessageParams( IReadOnlyDictionary rawHeaderData, @@ -84,6 +91,28 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SendMessageParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/send") @@ -109,6 +138,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -227,14 +261,12 @@ public MessageMetadata? Metadata init { this._rawData.Set("metadata", value); } } - public global::Courier.Models.Send.Preferences? Preferences + public Preferences? Preferences { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "preferences" - ); + return this._rawData.GetNullableClass("preferences"); } init { this._rawData.Set("preferences", value); } } @@ -1388,12 +1420,7 @@ public MessageMetadata FromRawUnchecked(IReadOnlyDictionary MessageMetadata.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Courier.Models.Send.Preferences, - global::Courier.Models.Send.PreferencesFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Preferences : JsonModel { /// @@ -1417,7 +1444,7 @@ public override void Validate() public Preferences() { } - public Preferences(global::Courier.Models.Send.Preferences preferences) + public Preferences(Preferences preferences) : base(preferences) { } public Preferences(IReadOnlyDictionary rawData) @@ -1433,10 +1460,8 @@ public Preferences(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Courier.Models.Send.Preferences FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Preferences FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -1449,12 +1474,11 @@ public Preferences(string subscriptionTopicID) } } -class PreferencesFromRaw : IFromRawJson +class PreferencesFromRaw : IFromRawJson { /// - public global::Courier.Models.Send.Preferences FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Courier.Models.Send.Preferences.FromRawUnchecked(rawData); + public Preferences FromRawUnchecked(IReadOnlyDictionary rawData) => + Preferences.FromRawUnchecked(rawData); } [JsonConverter(typeof(JsonModelConverter))] @@ -1636,14 +1660,12 @@ public required IReadOnlyList Channels } } - public required ApiEnum Method + public required ApiEnum Method { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("method"); + return this._rawData.GetNotNullClass>("method"); } init { this._rawData.Set("method", value); } } @@ -1690,16 +1712,16 @@ public Routing FromRawUnchecked(IReadOnlyDictionary rawData Routing.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Courier.Models.Send.MethodConverter))] +[JsonConverter(typeof(MethodConverter))] public enum Method { All, Single, } -sealed class MethodConverter : JsonConverter +sealed class MethodConverter : JsonConverter { - public override global::Courier.Models.Send.Method Read( + public override Method Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1707,24 +1729,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "all" => global::Courier.Models.Send.Method.All, - "single" => global::Courier.Models.Send.Method.Single, - _ => (global::Courier.Models.Send.Method)(-1), + "all" => Method.All, + "single" => Method.Single, + _ => (Method)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Courier.Models.Send.Method value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Method value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Courier.Models.Send.Method.All => "all", - global::Courier.Models.Send.Method.Single => "single", + Method.All => "all", + Method.Single => "single", _ => throw new CourierInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Courier/Models/Tenants/DefaultPreferences.cs b/src/Courier/Models/Tenants/DefaultPreferences.cs index b38e40b4..bd29f838 100644 --- a/src/Courier/Models/Tenants/DefaultPreferences.cs +++ b/src/Courier/Models/Tenants/DefaultPreferences.cs @@ -183,12 +183,7 @@ public Item FromRawUnchecked(IReadOnlyDictionary rawData) = Item.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Courier.Models.Tenants.IntersectionMember1, - global::Courier.Models.Tenants.IntersectionMember1FromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class IntersectionMember1 : JsonModel { /// @@ -212,9 +207,7 @@ public override void Validate() public IntersectionMember1() { } - public IntersectionMember1( - global::Courier.Models.Tenants.IntersectionMember1 intersectionMember1 - ) + public IntersectionMember1(IntersectionMember1 intersectionMember1) : base(intersectionMember1) { } public IntersectionMember1(IReadOnlyDictionary rawData) @@ -230,8 +223,8 @@ public IntersectionMember1(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Courier.Models.Tenants.IntersectionMember1 FromRawUnchecked( + /// + public static IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -246,10 +239,9 @@ public IntersectionMember1(string id) } } -class IntersectionMember1FromRaw : IFromRawJson +class IntersectionMember1FromRaw : IFromRawJson { /// - public global::Courier.Models.Tenants.IntersectionMember1 FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Courier.Models.Tenants.IntersectionMember1.FromRawUnchecked(rawData); + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); } diff --git a/src/Courier/Models/Tenants/Preferences/Items/ItemDeleteParams.cs b/src/Courier/Models/Tenants/Preferences/Items/ItemDeleteParams.cs index aa0d3661..94c70af5 100644 --- a/src/Courier/Models/Tenants/Preferences/Items/ItemDeleteParams.cs +++ b/src/Courier/Models/Tenants/Preferences/Items/ItemDeleteParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Tenants.Preferences.Items; /// /// Remove Default Preferences For Topic +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemDeleteParams : ParamsBase +public record class ItemDeleteParams : ParamsBase { public required string TenantID { get; init; } @@ -19,12 +23,15 @@ public sealed record class ItemDeleteParams : ParamsBase public ItemDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemDeleteParams(ItemDeleteParams itemDeleteParams) : base(itemDeleteParams) { this.TenantID = itemDeleteParams.TenantID; this.TopicID = itemDeleteParams.TopicID; } +#pragma warning restore CS8618 public ItemDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["TenantID"] = this.TenantID, + ["TopicID"] = this.TopicID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ItemDeleteParams? other) + { + if (other == null) + { + return false; + } + return this.TenantID.Equals(other.TenantID) + && (this.TopicID?.Equals(other.TopicID) ?? other.TopicID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -82,4 +113,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Tenants/Preferences/Items/ItemUpdateParams.cs b/src/Courier/Models/Tenants/Preferences/Items/ItemUpdateParams.cs index 38ef5f7c..7bdaf8f6 100644 --- a/src/Courier/Models/Tenants/Preferences/Items/ItemUpdateParams.cs +++ b/src/Courier/Models/Tenants/Preferences/Items/ItemUpdateParams.cs @@ -14,8 +14,12 @@ namespace Courier.Models.Tenants.Preferences.Items; /// /// Create or Replace Default Preferences For Topic +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemUpdateParams : ParamsBase +public record class ItemUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -27,14 +31,12 @@ public IReadOnlyDictionary RawBodyData public string? TopicID { get; init; } - public required ApiEnum Status + public required ApiEnum Status { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass< - ApiEnum - >("status"); + return this._rawBodyData.GetNotNullClass>("status"); } init { this._rawBodyData.Set("status", value); } } @@ -76,6 +78,8 @@ public bool? HasCustomRouting public ItemUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemUpdateParams(ItemUpdateParams itemUpdateParams) : base(itemUpdateParams) { @@ -84,6 +88,7 @@ public ItemUpdateParams(ItemUpdateParams itemUpdateParams) this._rawBodyData = new(itemUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public ItemUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -124,6 +129,32 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["TenantID"] = this.TenantID, + ["TopicID"] = this.TopicID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ItemUpdateParams? other) + { + if (other == null) + { + return false; + } + return this.TenantID.Equals(other.TenantID) + && (this.TopicID?.Equals(other.TopicID) ?? other.TopicID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -156,9 +187,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(global::Courier.Models.Tenants.Preferences.Items.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { OptedOut, @@ -166,10 +202,9 @@ public enum Status Required, } -sealed class StatusConverter - : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Courier.Models.Tenants.Preferences.Items.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -177,26 +212,22 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "OPTED_OUT" => global::Courier.Models.Tenants.Preferences.Items.Status.OptedOut, - "OPTED_IN" => global::Courier.Models.Tenants.Preferences.Items.Status.OptedIn, - "REQUIRED" => global::Courier.Models.Tenants.Preferences.Items.Status.Required, - _ => (global::Courier.Models.Tenants.Preferences.Items.Status)(-1), + "OPTED_OUT" => Status.OptedOut, + "OPTED_IN" => Status.OptedIn, + "REQUIRED" => Status.Required, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Courier.Models.Tenants.Preferences.Items.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Courier.Models.Tenants.Preferences.Items.Status.OptedOut => "OPTED_OUT", - global::Courier.Models.Tenants.Preferences.Items.Status.OptedIn => "OPTED_IN", - global::Courier.Models.Tenants.Preferences.Items.Status.Required => "REQUIRED", + Status.OptedOut => "OPTED_OUT", + Status.OptedIn => "OPTED_IN", + Status.Required => "REQUIRED", _ => throw new CourierInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Courier/Models/Tenants/Templates/TemplateListParams.cs b/src/Courier/Models/Tenants/Templates/TemplateListParams.cs index ef764a8d..6a653538 100644 --- a/src/Courier/Models/Tenants/Templates/TemplateListParams.cs +++ b/src/Courier/Models/Tenants/Templates/TemplateListParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Tenants.Templates; /// /// List Templates in Tenant +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TemplateListParams : ParamsBase +public record class TemplateListParams : ParamsBase { public string? TenantID { get; init; } @@ -43,11 +47,14 @@ public long? Limit public TemplateListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TemplateListParams(TemplateListParams templateListParams) : base(templateListParams) { this.TenantID = templateListParams.TenantID; } +#pragma warning restore CS8618 public TemplateListParams( IReadOnlyDictionary rawHeaderData, @@ -82,6 +89,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["TenantID"] = this.TenantID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TemplateListParams? other) + { + if (other == null) + { + return false; + } + return (this.TenantID?.Equals(other.TenantID) ?? other.TenantID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -101,4 +130,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Tenants/Templates/TemplateListResponse.cs b/src/Courier/Models/Tenants/Templates/TemplateListResponse.cs index 32ee4779..44102d0f 100644 --- a/src/Courier/Models/Tenants/Templates/TemplateListResponse.cs +++ b/src/Courier/Models/Tenants/Templates/TemplateListResponse.cs @@ -68,18 +68,16 @@ public string? Cursor init { this._rawData.Set("cursor", value); } } - public IReadOnlyList? Items + public IReadOnlyList? Items { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct< - ImmutableArray - >("items"); + return this._rawData.GetNullableStruct>("items"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "items", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -152,7 +150,7 @@ IReadOnlyDictionary rawData /// /// Always set to `list`. Represents the type of this object. /// -[JsonConverter(typeof(global::Courier.Models.Tenants.Templates.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { List, @@ -193,12 +191,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Courier.Models.Tenants.Templates.Item, - global::Courier.Models.Tenants.Templates.ItemFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Item : JsonModel { /// @@ -279,9 +272,7 @@ public required Data Data init { this._rawData.Set("data", value); } } - public static implicit operator BaseTemplateTenantAssociation( - global::Courier.Models.Tenants.Templates.Item item - ) => + public static implicit operator BaseTemplateTenantAssociation(Item item) => new() { ID = item.ID, @@ -304,7 +295,7 @@ public override void Validate() public Item() { } - public Item(global::Courier.Models.Tenants.Templates.Item item) + public Item(Item item) : base(item) { } public Item(IReadOnlyDictionary rawData) @@ -320,29 +311,21 @@ public Item(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Courier.Models.Tenants.Templates.Item FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Item FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class ItemFromRaw : IFromRawJson +class ItemFromRaw : IFromRawJson { /// - public global::Courier.Models.Tenants.Templates.Item FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Courier.Models.Tenants.Templates.Item.FromRawUnchecked(rawData); + public Item FromRawUnchecked(IReadOnlyDictionary rawData) => + Item.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Courier.Models.Tenants.Templates.IntersectionMember1, - global::Courier.Models.Tenants.Templates.IntersectionMember1FromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class IntersectionMember1 : JsonModel { /// @@ -366,9 +349,7 @@ public override void Validate() public IntersectionMember1() { } - public IntersectionMember1( - global::Courier.Models.Tenants.Templates.IntersectionMember1 intersectionMember1 - ) + public IntersectionMember1(IntersectionMember1 intersectionMember1) : base(intersectionMember1) { } public IntersectionMember1(IReadOnlyDictionary rawData) @@ -384,8 +365,8 @@ public IntersectionMember1(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Courier.Models.Tenants.Templates.IntersectionMember1 FromRawUnchecked( + /// + public static IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -400,13 +381,11 @@ public IntersectionMember1(Data data) } } -class IntersectionMember1FromRaw - : IFromRawJson +class IntersectionMember1FromRaw : IFromRawJson { /// - public global::Courier.Models.Tenants.Templates.IntersectionMember1 FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Courier.Models.Tenants.Templates.IntersectionMember1.FromRawUnchecked(rawData); + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); } /// diff --git a/src/Courier/Models/Tenants/Templates/TemplateRetrieveParams.cs b/src/Courier/Models/Tenants/Templates/TemplateRetrieveParams.cs index 10c98d99..7d67119d 100644 --- a/src/Courier/Models/Tenants/Templates/TemplateRetrieveParams.cs +++ b/src/Courier/Models/Tenants/Templates/TemplateRetrieveParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Tenants.Templates; /// /// Get a Template in Tenant +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TemplateRetrieveParams : ParamsBase +public record class TemplateRetrieveParams : ParamsBase { public required string TenantID { get; init; } @@ -19,12 +23,15 @@ public sealed record class TemplateRetrieveParams : ParamsBase public TemplateRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TemplateRetrieveParams(TemplateRetrieveParams templateRetrieveParams) : base(templateRetrieveParams) { this.TenantID = templateRetrieveParams.TenantID; this.TemplateID = templateRetrieveParams.TemplateID; } +#pragma warning restore CS8618 public TemplateRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["TenantID"] = this.TenantID, + ["TemplateID"] = this.TemplateID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TemplateRetrieveParams? other) + { + if (other == null) + { + return false; + } + return this.TenantID.Equals(other.TenantID) + && (this.TemplateID?.Equals(other.TemplateID) ?? other.TemplateID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -78,4 +109,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Tenants/TenantAssociation.cs b/src/Courier/Models/Tenants/TenantAssociation.cs index 1bbe49b9..e97e2ec2 100644 --- a/src/Courier/Models/Tenants/TenantAssociation.cs +++ b/src/Courier/Models/Tenants/TenantAssociation.cs @@ -119,7 +119,7 @@ public TenantAssociation FromRawUnchecked(IReadOnlyDictionary /// Delete a Tenant +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TenantDeleteParams : ParamsBase +public record class TenantDeleteParams : ParamsBase { public string? TenantID { get; init; } public TenantDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TenantDeleteParams(TenantDeleteParams tenantDeleteParams) : base(tenantDeleteParams) { this.TenantID = tenantDeleteParams.TenantID; } +#pragma warning restore CS8618 public TenantDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["TenantID"] = this.TenantID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TenantDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.TenantID?.Equals(other.TenantID) ?? other.TenantID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Tenants/TenantListParams.cs b/src/Courier/Models/Tenants/TenantListParams.cs index 1f9a5fa4..0b319a50 100644 --- a/src/Courier/Models/Tenants/TenantListParams.cs +++ b/src/Courier/Models/Tenants/TenantListParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Tenants; /// /// Get a List of Tenants +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TenantListParams : ParamsBase +public record class TenantListParams : ParamsBase { /// /// Continue the pagination with the next cursor @@ -54,8 +58,11 @@ public string? ParentTenantID public TenantListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TenantListParams(TenantListParams tenantListParams) : base(tenantListParams) { } +#pragma warning restore CS8618 public TenantListParams( IReadOnlyDictionary rawHeaderData, @@ -90,6 +97,26 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TenantListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/tenants") @@ -106,4 +133,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Tenants/TenantListUsersParams.cs b/src/Courier/Models/Tenants/TenantListUsersParams.cs index 2c373399..0b628ae9 100644 --- a/src/Courier/Models/Tenants/TenantListUsersParams.cs +++ b/src/Courier/Models/Tenants/TenantListUsersParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Tenants; /// /// Get Users in Tenant +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TenantListUsersParams : ParamsBase +public record class TenantListUsersParams : ParamsBase { public string? TenantID { get; init; } @@ -43,11 +47,14 @@ public long? Limit public TenantListUsersParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TenantListUsersParams(TenantListUsersParams tenantListUsersParams) : base(tenantListUsersParams) { this.TenantID = tenantListUsersParams.TenantID; } +#pragma warning restore CS8618 public TenantListUsersParams( IReadOnlyDictionary rawHeaderData, @@ -82,6 +89,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["TenantID"] = this.TenantID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TenantListUsersParams? other) + { + if (other == null) + { + return false; + } + return (this.TenantID?.Equals(other.TenantID) ?? other.TenantID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -101,4 +130,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Tenants/TenantRetrieveParams.cs b/src/Courier/Models/Tenants/TenantRetrieveParams.cs index 3045e147..eadc6b70 100644 --- a/src/Courier/Models/Tenants/TenantRetrieveParams.cs +++ b/src/Courier/Models/Tenants/TenantRetrieveParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Tenants; /// /// Get a Tenant +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TenantRetrieveParams : ParamsBase +public record class TenantRetrieveParams : ParamsBase { public string? TenantID { get; init; } public TenantRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TenantRetrieveParams(TenantRetrieveParams tenantRetrieveParams) : base(tenantRetrieveParams) { this.TenantID = tenantRetrieveParams.TenantID; } +#pragma warning restore CS8618 public TenantRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["TenantID"] = this.TenantID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TenantRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.TenantID?.Equals(other.TenantID) ?? other.TenantID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -74,4 +103,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Tenants/TenantUpdateParams.cs b/src/Courier/Models/Tenants/TenantUpdateParams.cs index 6361f0fc..bf750dec 100644 --- a/src/Courier/Models/Tenants/TenantUpdateParams.cs +++ b/src/Courier/Models/Tenants/TenantUpdateParams.cs @@ -11,8 +11,12 @@ namespace Courier.Models.Tenants; /// /// Create or Replace a Tenant +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TenantUpdateParams : ParamsBase +public record class TenantUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -119,6 +123,8 @@ public IReadOnlyDictionary? UserProfile public TenantUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TenantUpdateParams(TenantUpdateParams tenantUpdateParams) : base(tenantUpdateParams) { @@ -126,6 +132,7 @@ public TenantUpdateParams(TenantUpdateParams tenantUpdateParams) this._rawBodyData = new(tenantUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public TenantUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -166,6 +173,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["TenantID"] = this.TenantID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TenantUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.TenantID?.Equals(other.TenantID) ?? other.TenantID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -193,4 +224,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Translations/TranslationRetrieveParams.cs b/src/Courier/Models/Translations/TranslationRetrieveParams.cs index 8a635b38..46d45cea 100644 --- a/src/Courier/Models/Translations/TranslationRetrieveParams.cs +++ b/src/Courier/Models/Translations/TranslationRetrieveParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Translations; /// /// Get translations by locale +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TranslationRetrieveParams : ParamsBase +public record class TranslationRetrieveParams : ParamsBase { public required string Domain { get; init; } @@ -19,12 +23,15 @@ public sealed record class TranslationRetrieveParams : ParamsBase public TranslationRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TranslationRetrieveParams(TranslationRetrieveParams translationRetrieveParams) : base(translationRetrieveParams) { this.Domain = translationRetrieveParams.Domain; this.Locale = translationRetrieveParams.Locale; } +#pragma warning restore CS8618 public TranslationRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["Domain"] = this.Domain, + ["Locale"] = this.Locale, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TranslationRetrieveParams? other) + { + if (other == null) + { + return false; + } + return this.Domain.Equals(other.Domain) + && (this.Locale?.Equals(other.Locale) ?? other.Locale == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -78,4 +109,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Translations/TranslationUpdateParams.cs b/src/Courier/Models/Translations/TranslationUpdateParams.cs index a6eddd40..a0d6076b 100644 --- a/src/Courier/Models/Translations/TranslationUpdateParams.cs +++ b/src/Courier/Models/Translations/TranslationUpdateParams.cs @@ -11,8 +11,12 @@ namespace Courier.Models.Translations; /// /// Update a translation +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TranslationUpdateParams : ParamsBase +public record class TranslationUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -36,6 +40,8 @@ public required string Body public TranslationUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TranslationUpdateParams(TranslationUpdateParams translationUpdateParams) : base(translationUpdateParams) { @@ -44,6 +50,7 @@ public TranslationUpdateParams(TranslationUpdateParams translationUpdateParams) this._rawBodyData = new(translationUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public TranslationUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -84,6 +91,32 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["Domain"] = this.Domain, + ["Locale"] = this.Locale, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TranslationUpdateParams? other) + { + if (other == null) + { + return false; + } + return this.Domain.Equals(other.Domain) + && (this.Locale?.Equals(other.Locale) ?? other.Locale == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -112,4 +145,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Preferences/PreferenceRetrieveParams.cs b/src/Courier/Models/Users/Preferences/PreferenceRetrieveParams.cs index 87ce00c1..fdd5aeee 100644 --- a/src/Courier/Models/Users/Preferences/PreferenceRetrieveParams.cs +++ b/src/Courier/Models/Users/Preferences/PreferenceRetrieveParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Users.Preferences; /// /// Fetch all user preferences. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PreferenceRetrieveParams : ParamsBase +public record class PreferenceRetrieveParams : ParamsBase { public string? UserID { get; init; } @@ -30,11 +34,14 @@ public string? TenantID public PreferenceRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PreferenceRetrieveParams(PreferenceRetrieveParams preferenceRetrieveParams) : base(preferenceRetrieveParams) { this.UserID = preferenceRetrieveParams.UserID; } +#pragma warning restore CS8618 public PreferenceRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -69,6 +76,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PreferenceRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -88,4 +117,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Preferences/PreferenceRetrieveTopicParams.cs b/src/Courier/Models/Users/Preferences/PreferenceRetrieveTopicParams.cs index d4b82919..d0dd9990 100644 --- a/src/Courier/Models/Users/Preferences/PreferenceRetrieveTopicParams.cs +++ b/src/Courier/Models/Users/Preferences/PreferenceRetrieveTopicParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Users.Preferences; /// /// Fetch user preferences for a specific subscription topic. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PreferenceRetrieveTopicParams : ParamsBase +public record class PreferenceRetrieveTopicParams : ParamsBase { public required string UserID { get; init; } @@ -32,6 +36,8 @@ public string? TenantID public PreferenceRetrieveTopicParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PreferenceRetrieveTopicParams( PreferenceRetrieveTopicParams preferenceRetrieveTopicParams ) @@ -40,6 +46,7 @@ PreferenceRetrieveTopicParams preferenceRetrieveTopicParams this.UserID = preferenceRetrieveTopicParams.UserID; this.TopicID = preferenceRetrieveTopicParams.TopicID; } +#pragma warning restore CS8618 public PreferenceRetrieveTopicParams( IReadOnlyDictionary rawHeaderData, @@ -74,6 +81,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["TopicID"] = this.TopicID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PreferenceRetrieveTopicParams? other) + { + if (other == null) + { + return false; + } + return this.UserID.Equals(other.UserID) + && (this.TopicID?.Equals(other.TopicID) ?? other.TopicID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -93,4 +124,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Preferences/PreferenceUpdateOrCreateTopicParams.cs b/src/Courier/Models/Users/Preferences/PreferenceUpdateOrCreateTopicParams.cs index 542060eb..9a98d711 100644 --- a/src/Courier/Models/Users/Preferences/PreferenceUpdateOrCreateTopicParams.cs +++ b/src/Courier/Models/Users/Preferences/PreferenceUpdateOrCreateTopicParams.cs @@ -13,8 +13,12 @@ namespace Courier.Models.Users.Preferences; /// /// Update or Create user preferences for a specific subscription topic. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PreferenceUpdateOrCreateTopicParams : ParamsBase +public record class PreferenceUpdateOrCreateTopicParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -51,6 +55,8 @@ public string? TenantID public PreferenceUpdateOrCreateTopicParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PreferenceUpdateOrCreateTopicParams( PreferenceUpdateOrCreateTopicParams preferenceUpdateOrCreateTopicParams ) @@ -61,6 +67,7 @@ PreferenceUpdateOrCreateTopicParams preferenceUpdateOrCreateTopicParams this._rawBodyData = new(preferenceUpdateOrCreateTopicParams._rawBodyData); } +#pragma warning restore CS8618 public PreferenceUpdateOrCreateTopicParams( IReadOnlyDictionary rawHeaderData, @@ -101,6 +108,32 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["TopicID"] = this.TopicID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PreferenceUpdateOrCreateTopicParams? other) + { + if (other == null) + { + return false; + } + return this.UserID.Equals(other.UserID) + && (this.TopicID?.Equals(other.TopicID) ?? other.TopicID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -129,6 +162,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] diff --git a/src/Courier/Models/Users/Tenants/TenantAddMultipleParams.cs b/src/Courier/Models/Users/Tenants/TenantAddMultipleParams.cs index 89979726..a98188d5 100644 --- a/src/Courier/Models/Users/Tenants/TenantAddMultipleParams.cs +++ b/src/Courier/Models/Users/Tenants/TenantAddMultipleParams.cs @@ -15,8 +15,12 @@ namespace Courier.Models.Users.Tenants; /// This endpoint is used to add a user to multiple tenants in one call. A custom /// profile can also be supplied for each tenant. This profile will be merged with /// the user's main profile when sending to the user with that tenant. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TenantAddMultipleParams : ParamsBase +public record class TenantAddMultipleParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -44,6 +48,8 @@ public required IReadOnlyList Tenants public TenantAddMultipleParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TenantAddMultipleParams(TenantAddMultipleParams tenantAddMultipleParams) : base(tenantAddMultipleParams) { @@ -51,6 +57,7 @@ public TenantAddMultipleParams(TenantAddMultipleParams tenantAddMultipleParams) this._rawBodyData = new(tenantAddMultipleParams._rawBodyData); } +#pragma warning restore CS8618 public TenantAddMultipleParams( IReadOnlyDictionary rawHeaderData, @@ -91,6 +98,30 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TenantAddMultipleParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -119,4 +150,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Tenants/TenantAddSingleParams.cs b/src/Courier/Models/Users/Tenants/TenantAddSingleParams.cs index 908f4170..b39423d7 100644 --- a/src/Courier/Models/Users/Tenants/TenantAddSingleParams.cs +++ b/src/Courier/Models/Users/Tenants/TenantAddSingleParams.cs @@ -14,8 +14,12 @@ namespace Courier.Models.Users.Tenants; /// /// A custom profile can also be supplied with the tenant. This profile will /// be merged with the user's main profile when sending to the user with that tenant. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TenantAddSingleParams : ParamsBase +public record class TenantAddSingleParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -47,6 +51,8 @@ public IReadOnlyDictionary? Profile public TenantAddSingleParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TenantAddSingleParams(TenantAddSingleParams tenantAddSingleParams) : base(tenantAddSingleParams) { @@ -55,6 +61,7 @@ public TenantAddSingleParams(TenantAddSingleParams tenantAddSingleParams) this._rawBodyData = new(tenantAddSingleParams._rawBodyData); } +#pragma warning restore CS8618 public TenantAddSingleParams( IReadOnlyDictionary rawHeaderData, @@ -95,6 +102,32 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["TenantID"] = this.TenantID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TenantAddSingleParams? other) + { + if (other == null) + { + return false; + } + return this.UserID.Equals(other.UserID) + && (this.TenantID?.Equals(other.TenantID) ?? other.TenantID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -123,4 +156,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Tenants/TenantListParams.cs b/src/Courier/Models/Users/Tenants/TenantListParams.cs index d17f6e6c..21b25fa8 100644 --- a/src/Courier/Models/Users/Tenants/TenantListParams.cs +++ b/src/Courier/Models/Users/Tenants/TenantListParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Users.Tenants; /// /// Returns a paginated list of user tenant associations. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TenantListParams : ParamsBase +public record class TenantListParams : ParamsBase { public string? UserID { get; init; } @@ -43,11 +47,14 @@ public long? Limit public TenantListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TenantListParams(TenantListParams tenantListParams) : base(tenantListParams) { this.UserID = tenantListParams.UserID; } +#pragma warning restore CS8618 public TenantListParams( IReadOnlyDictionary rawHeaderData, @@ -82,6 +89,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TenantListParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -101,4 +130,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Tenants/TenantListResponse.cs b/src/Courier/Models/Users/Tenants/TenantListResponse.cs index 109e081e..7703827b 100644 --- a/src/Courier/Models/Users/Tenants/TenantListResponse.cs +++ b/src/Courier/Models/Users/Tenants/TenantListResponse.cs @@ -152,7 +152,7 @@ public TenantListResponse FromRawUnchecked(IReadOnlyDictionary /// Always set to `list`. Represents the type of this object. /// -[JsonConverter(typeof(global::Courier.Models.Users.Tenants.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { List, diff --git a/src/Courier/Models/Users/Tenants/TenantRemoveAllParams.cs b/src/Courier/Models/Users/Tenants/TenantRemoveAllParams.cs index d3dd80d2..7869be58 100644 --- a/src/Courier/Models/Users/Tenants/TenantRemoveAllParams.cs +++ b/src/Courier/Models/Users/Tenants/TenantRemoveAllParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Users.Tenants; /// /// Removes a user from any tenants they may have been associated with. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TenantRemoveAllParams : ParamsBase +public record class TenantRemoveAllParams : ParamsBase { public string? UserID { get; init; } public TenantRemoveAllParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TenantRemoveAllParams(TenantRemoveAllParams tenantRemoveAllParams) : base(tenantRemoveAllParams) { this.UserID = tenantRemoveAllParams.UserID; } +#pragma warning restore CS8618 public TenantRemoveAllParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TenantRemoveAllParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Tenants/TenantRemoveSingleParams.cs b/src/Courier/Models/Users/Tenants/TenantRemoveSingleParams.cs index 3f485c54..d38c6f34 100644 --- a/src/Courier/Models/Users/Tenants/TenantRemoveSingleParams.cs +++ b/src/Courier/Models/Users/Tenants/TenantRemoveSingleParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Users.Tenants; /// /// Removes a user from the supplied tenant. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TenantRemoveSingleParams : ParamsBase +public record class TenantRemoveSingleParams : ParamsBase { public required string UserID { get; init; } @@ -19,12 +23,15 @@ public sealed record class TenantRemoveSingleParams : ParamsBase public TenantRemoveSingleParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TenantRemoveSingleParams(TenantRemoveSingleParams tenantRemoveSingleParams) : base(tenantRemoveSingleParams) { this.UserID = tenantRemoveSingleParams.UserID; this.TenantID = tenantRemoveSingleParams.TenantID; } +#pragma warning restore CS8618 public TenantRemoveSingleParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["TenantID"] = this.TenantID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TenantRemoveSingleParams? other) + { + if (other == null) + { + return false; + } + return this.UserID.Equals(other.UserID) + && (this.TenantID?.Equals(other.TenantID) ?? other.TenantID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -78,4 +109,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Tokens/TokenAddMultipleParams.cs b/src/Courier/Models/Users/Tokens/TokenAddMultipleParams.cs index 7a4834ca..46e89e90 100644 --- a/src/Courier/Models/Users/Tokens/TokenAddMultipleParams.cs +++ b/src/Courier/Models/Users/Tokens/TokenAddMultipleParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Users.Tokens; /// /// Adds multiple tokens to a user and overwrites matching existing tokens. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TokenAddMultipleParams : ParamsBase +public record class TokenAddMultipleParams : ParamsBase { public string? UserID { get; init; } public TokenAddMultipleParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TokenAddMultipleParams(TokenAddMultipleParams tokenAddMultipleParams) : base(tokenAddMultipleParams) { this.UserID = tokenAddMultipleParams.UserID; } +#pragma warning restore CS8618 public TokenAddMultipleParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TokenAddMultipleParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Tokens/TokenAddSingleParams.cs b/src/Courier/Models/Users/Tokens/TokenAddSingleParams.cs index a55fde97..5e43d272 100644 --- a/src/Courier/Models/Users/Tokens/TokenAddSingleParams.cs +++ b/src/Courier/Models/Users/Tokens/TokenAddSingleParams.cs @@ -13,8 +13,12 @@ namespace Courier.Models.Users.Tokens; /// /// Adds a single token to a user and overwrites a matching existing token. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TokenAddSingleParams : ParamsBase +public record class TokenAddSingleParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -112,6 +116,8 @@ public Tracking? Tracking public TokenAddSingleParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TokenAddSingleParams(TokenAddSingleParams tokenAddSingleParams) : base(tokenAddSingleParams) { @@ -120,6 +126,7 @@ public TokenAddSingleParams(TokenAddSingleParams tokenAddSingleParams) this._rawBodyData = new(tokenAddSingleParams._rawBodyData); } +#pragma warning restore CS8618 public TokenAddSingleParams( IReadOnlyDictionary rawHeaderData, @@ -160,6 +167,32 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["Token"] = this.Token, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TokenAddSingleParams? other) + { + if (other == null) + { + return false; + } + return this.UserID.Equals(other.UserID) + && (this.Token?.Equals(other.Token) ?? other.Token == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -188,6 +221,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(ProviderKeyConverter))] diff --git a/src/Courier/Models/Users/Tokens/TokenDeleteParams.cs b/src/Courier/Models/Users/Tokens/TokenDeleteParams.cs index d9a2bbbb..52939afd 100644 --- a/src/Courier/Models/Users/Tokens/TokenDeleteParams.cs +++ b/src/Courier/Models/Users/Tokens/TokenDeleteParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Users.Tokens; /// /// Delete User Token +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TokenDeleteParams : ParamsBase +public record class TokenDeleteParams : ParamsBase { public required string UserID { get; init; } @@ -19,12 +23,15 @@ public sealed record class TokenDeleteParams : ParamsBase public TokenDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TokenDeleteParams(TokenDeleteParams tokenDeleteParams) : base(tokenDeleteParams) { this.UserID = tokenDeleteParams.UserID; this.Token = tokenDeleteParams.Token; } +#pragma warning restore CS8618 public TokenDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["Token"] = this.Token, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TokenDeleteParams? other) + { + if (other == null) + { + return false; + } + return this.UserID.Equals(other.UserID) + && (this.Token?.Equals(other.Token) ?? other.Token == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -78,4 +109,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Tokens/TokenListParams.cs b/src/Courier/Models/Users/Tokens/TokenListParams.cs index fdd11776..93068ff8 100644 --- a/src/Courier/Models/Users/Tokens/TokenListParams.cs +++ b/src/Courier/Models/Users/Tokens/TokenListParams.cs @@ -10,18 +10,25 @@ namespace Courier.Models.Users.Tokens; /// /// Gets all tokens available for a :user_id +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TokenListParams : ParamsBase +public record class TokenListParams : ParamsBase { public string? UserID { get; init; } public TokenListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TokenListParams(TokenListParams tokenListParams) : base(tokenListParams) { this.UserID = tokenListParams.UserID; } +#pragma warning restore CS8618 public TokenListParams( IReadOnlyDictionary rawHeaderData, @@ -56,6 +63,28 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TokenListParams? other) + { + if (other == null) + { + return false; + } + return (this.UserID?.Equals(other.UserID) ?? other.UserID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -75,4 +104,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Tokens/TokenRetrieveParams.cs b/src/Courier/Models/Users/Tokens/TokenRetrieveParams.cs index 96435f25..cd5d7ae7 100644 --- a/src/Courier/Models/Users/Tokens/TokenRetrieveParams.cs +++ b/src/Courier/Models/Users/Tokens/TokenRetrieveParams.cs @@ -10,8 +10,12 @@ namespace Courier.Models.Users.Tokens; /// /// Get single token available for a `:token` +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TokenRetrieveParams : ParamsBase +public record class TokenRetrieveParams : ParamsBase { public required string UserID { get; init; } @@ -19,12 +23,15 @@ public sealed record class TokenRetrieveParams : ParamsBase public TokenRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TokenRetrieveParams(TokenRetrieveParams tokenRetrieveParams) : base(tokenRetrieveParams) { this.UserID = tokenRetrieveParams.UserID; this.Token = tokenRetrieveParams.Token; } +#pragma warning restore CS8618 public TokenRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -59,6 +66,30 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["Token"] = this.Token, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TokenRetrieveParams? other) + { + if (other == null) + { + return false; + } + return this.UserID.Equals(other.UserID) + && (this.Token?.Equals(other.Token) ?? other.Token == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -78,4 +109,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Courier/Models/Users/Tokens/TokenRetrieveResponse.cs b/src/Courier/Models/Users/Tokens/TokenRetrieveResponse.cs index 01c74c7d..819efbf4 100644 --- a/src/Courier/Models/Users/Tokens/TokenRetrieveResponse.cs +++ b/src/Courier/Models/Users/Tokens/TokenRetrieveResponse.cs @@ -180,12 +180,7 @@ IReadOnlyDictionary rawData ) => TokenRetrieveResponse.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Courier.Models.Users.Tokens.IntersectionMember1, - global::Courier.Models.Users.Tokens.IntersectionMember1FromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class IntersectionMember1 : JsonModel { public ApiEnum? Status @@ -220,9 +215,7 @@ public override void Validate() public IntersectionMember1() { } - public IntersectionMember1( - global::Courier.Models.Users.Tokens.IntersectionMember1 intersectionMember1 - ) + public IntersectionMember1(IntersectionMember1 intersectionMember1) : base(intersectionMember1) { } public IntersectionMember1(IReadOnlyDictionary rawData) @@ -238,8 +231,8 @@ public IntersectionMember1(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Courier.Models.Users.Tokens.IntersectionMember1 FromRawUnchecked( + /// + public static IntersectionMember1 FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -247,13 +240,11 @@ IReadOnlyDictionary rawData } } -class IntersectionMember1FromRaw - : IFromRawJson +class IntersectionMember1FromRaw : IFromRawJson { /// - public global::Courier.Models.Users.Tokens.IntersectionMember1 FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Courier.Models.Users.Tokens.IntersectionMember1.FromRawUnchecked(rawData); + public IntersectionMember1 FromRawUnchecked(IReadOnlyDictionary rawData) => + IntersectionMember1.FromRawUnchecked(rawData); } [JsonConverter(typeof(StatusConverter))] diff --git a/src/Courier/Models/Users/Tokens/TokenUpdateParams.cs b/src/Courier/Models/Users/Tokens/TokenUpdateParams.cs index 7506700e..6b8cfe0b 100644 --- a/src/Courier/Models/Users/Tokens/TokenUpdateParams.cs +++ b/src/Courier/Models/Users/Tokens/TokenUpdateParams.cs @@ -13,8 +13,12 @@ namespace Courier.Models.Users.Tokens; /// /// Apply a JSON Patch (RFC 6902) to the specified token. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TokenUpdateParams : ParamsBase +public record class TokenUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -44,6 +48,8 @@ public required IReadOnlyList Patch public TokenUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TokenUpdateParams(TokenUpdateParams tokenUpdateParams) : base(tokenUpdateParams) { @@ -52,6 +58,7 @@ public TokenUpdateParams(TokenUpdateParams tokenUpdateParams) this._rawBodyData = new(tokenUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public TokenUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -92,6 +99,32 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + new Dictionary() + { + ["UserID"] = this.UserID, + ["Token"] = this.Token, + ["HeaderData"] = this._rawHeaderData.Freeze(), + ["QueryData"] = this._rawQueryData.Freeze(), + ["BodyData"] = this._rawBodyData.Freeze(), + }, + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TokenUpdateParams? other) + { + if (other == null) + { + return false; + } + return this.UserID.Equals(other.UserID) + && (this.Token?.Equals(other.Token) ?? other.Token == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -120,6 +153,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] diff --git a/src/Courier/Services/Profiles/IListService.cs b/src/Courier/Services/Profiles/IListService.cs index 384c4345..1cf7b13e 100644 --- a/src/Courier/Services/Profiles/IListService.cs +++ b/src/Courier/Services/Profiles/IListService.cs @@ -17,16 +17,14 @@ public interface IListService /// Returns a view of this service that provides access to raw HTTP responses /// for each method. /// - global::Courier.Services.Profiles.IListServiceWithRawResponse WithRawResponse { get; } + IListServiceWithRawResponse WithRawResponse { get; } /// /// Returns a view of this service with the given option modifications applied. /// /// The original service is not modified. /// - global::Courier.Services.Profiles.IListService WithOptions( - Func modifier - ); + IListService WithOptions(Func modifier); /// /// Returns the subscribed lists for a specified user. @@ -76,7 +74,7 @@ Task Subscribe( } /// -/// A view of that provides access to raw +/// A view of that provides access to raw /// HTTP responses for each method. /// public interface IListServiceWithRawResponse @@ -86,13 +84,11 @@ public interface IListServiceWithRawResponse /// /// The original service is not modified. /// - global::Courier.Services.Profiles.IListServiceWithRawResponse WithOptions( - Func modifier - ); + IListServiceWithRawResponse WithOptions(Func modifier); /// /// Returns a raw HTTP response for `get /profiles/{user_id}/lists`, but is otherwise the - /// same as . + /// same as . /// Task> Retrieve( ListRetrieveParams parameters, @@ -108,7 +104,7 @@ Task> Retrieve( /// /// Returns a raw HTTP response for `delete /profiles/{user_id}/lists`, but is otherwise the - /// same as . + /// same as . /// Task> Delete( ListDeleteParams parameters, @@ -124,7 +120,7 @@ Task> Delete( /// /// Returns a raw HTTP response for `post /profiles/{user_id}/lists`, but is otherwise the - /// same as . + /// same as . /// Task> Subscribe( ListSubscribeParams parameters, diff --git a/src/Courier/Services/Profiles/ListService.cs b/src/Courier/Services/Profiles/ListService.cs index 92aa64f4..a2c68587 100644 --- a/src/Courier/Services/Profiles/ListService.cs +++ b/src/Courier/Services/Profiles/ListService.cs @@ -9,12 +9,12 @@ namespace Courier.Services.Profiles; /// -public sealed class ListService : global::Courier.Services.Profiles.IListService +public sealed class ListService : IListService { - readonly Lazy _withRawResponse; + readonly Lazy _withRawResponse; /// - public global::Courier.Services.Profiles.IListServiceWithRawResponse WithRawResponse + public IListServiceWithRawResponse WithRawResponse { get { return _withRawResponse.Value; } } @@ -22,22 +22,16 @@ public sealed class ListService : global::Courier.Services.Profiles.IListService readonly ICourierClient _client; /// - public global::Courier.Services.Profiles.IListService WithOptions( - Func modifier - ) + public IListService WithOptions(Func modifier) { - return new global::Courier.Services.Profiles.ListService( - this._client.WithOptions(modifier) - ); + return new ListService(this._client.WithOptions(modifier)); } public ListService(ICourierClient client) { _client = client; - _withRawResponse = new(() => - new global::Courier.Services.Profiles.ListServiceWithRawResponse(client.WithRawResponse) - ); + _withRawResponse = new(() => new ListServiceWithRawResponse(client.WithRawResponse)); } /// @@ -112,19 +106,14 @@ public Task Subscribe( } /// -public sealed class ListServiceWithRawResponse - : global::Courier.Services.Profiles.IListServiceWithRawResponse +public sealed class ListServiceWithRawResponse : IListServiceWithRawResponse { readonly ICourierClientWithRawResponse _client; /// - public global::Courier.Services.Profiles.IListServiceWithRawResponse WithOptions( - Func modifier - ) + public IListServiceWithRawResponse WithOptions(Func modifier) { - return new global::Courier.Services.Profiles.ListServiceWithRawResponse( - this._client.WithOptions(modifier) - ); + return new ListServiceWithRawResponse(this._client.WithOptions(modifier)); } public ListServiceWithRawResponse(ICourierClientWithRawResponse client) diff --git a/src/Courier/Services/Users/ITenantService.cs b/src/Courier/Services/Users/ITenantService.cs index d2f654a2..fa216e39 100644 --- a/src/Courier/Services/Users/ITenantService.cs +++ b/src/Courier/Services/Users/ITenantService.cs @@ -17,16 +17,14 @@ public interface ITenantService /// Returns a view of this service that provides access to raw HTTP responses /// for each method. /// - global::Courier.Services.Users.ITenantServiceWithRawResponse WithRawResponse { get; } + ITenantServiceWithRawResponse WithRawResponse { get; } /// /// Returns a view of this service with the given option modifications applied. /// /// The original service is not modified. /// - global::Courier.Services.Users.ITenantService WithOptions( - Func modifier - ); + ITenantService WithOptions(Func modifier); /// /// Returns a paginated list of user tenant associations. @@ -105,7 +103,7 @@ Task RemoveSingle( } /// -/// A view of that provides access to raw +/// A view of that provides access to raw /// HTTP responses for each method. /// public interface ITenantServiceWithRawResponse @@ -115,13 +113,11 @@ public interface ITenantServiceWithRawResponse /// /// The original service is not modified. /// - global::Courier.Services.Users.ITenantServiceWithRawResponse WithOptions( - Func modifier - ); + ITenantServiceWithRawResponse WithOptions(Func modifier); /// /// Returns a raw HTTP response for `get /users/{user_id}/tenants`, but is otherwise the - /// same as . + /// same as . /// Task> List( TenantListParams parameters, @@ -137,7 +133,7 @@ Task> List( /// /// Returns a raw HTTP response for `put /users/{user_id}/tenants`, but is otherwise the - /// same as . + /// same as . /// Task AddMultiple( TenantAddMultipleParams parameters, @@ -153,7 +149,7 @@ Task AddMultiple( /// /// Returns a raw HTTP response for `put /users/{user_id}/tenants/{tenant_id}`, but is otherwise the - /// same as . + /// same as . /// Task AddSingle( TenantAddSingleParams parameters, @@ -169,7 +165,7 @@ Task AddSingle( /// /// Returns a raw HTTP response for `delete /users/{user_id}/tenants`, but is otherwise the - /// same as . + /// same as . /// Task RemoveAll( TenantRemoveAllParams parameters, @@ -185,7 +181,7 @@ Task RemoveAll( /// /// Returns a raw HTTP response for `delete /users/{user_id}/tenants/{tenant_id}`, but is otherwise the - /// same as . + /// same as . /// Task RemoveSingle( TenantRemoveSingleParams parameters, diff --git a/src/Courier/Services/Users/TenantService.cs b/src/Courier/Services/Users/TenantService.cs index de4bdc42..69615852 100644 --- a/src/Courier/Services/Users/TenantService.cs +++ b/src/Courier/Services/Users/TenantService.cs @@ -9,12 +9,12 @@ namespace Courier.Services.Users; /// -public sealed class TenantService : global::Courier.Services.Users.ITenantService +public sealed class TenantService : ITenantService { - readonly Lazy _withRawResponse; + readonly Lazy _withRawResponse; /// - public global::Courier.Services.Users.ITenantServiceWithRawResponse WithRawResponse + public ITenantServiceWithRawResponse WithRawResponse { get { return _withRawResponse.Value; } } @@ -22,20 +22,16 @@ public sealed class TenantService : global::Courier.Services.Users.ITenantServic readonly ICourierClient _client; /// - public global::Courier.Services.Users.ITenantService WithOptions( - Func modifier - ) + public ITenantService WithOptions(Func modifier) { - return new global::Courier.Services.Users.TenantService(this._client.WithOptions(modifier)); + return new TenantService(this._client.WithOptions(modifier)); } public TenantService(ICourierClient client) { _client = client; - _withRawResponse = new(() => - new global::Courier.Services.Users.TenantServiceWithRawResponse(client.WithRawResponse) - ); + _withRawResponse = new(() => new TenantServiceWithRawResponse(client.WithRawResponse)); } /// @@ -146,19 +142,14 @@ await this.RemoveSingle(parameters with { TenantID = tenantID }, cancellationTok } /// -public sealed class TenantServiceWithRawResponse - : global::Courier.Services.Users.ITenantServiceWithRawResponse +public sealed class TenantServiceWithRawResponse : ITenantServiceWithRawResponse { readonly ICourierClientWithRawResponse _client; /// - public global::Courier.Services.Users.ITenantServiceWithRawResponse WithOptions( - Func modifier - ) + public ITenantServiceWithRawResponse WithOptions(Func modifier) { - return new global::Courier.Services.Users.TenantServiceWithRawResponse( - this._client.WithOptions(modifier) - ); + return new TenantServiceWithRawResponse(this._client.WithOptions(modifier)); } public TenantServiceWithRawResponse(ICourierClientWithRawResponse client)