diff --git a/.fern/metadata.json b/.fern/metadata.json index 6c4a80ce..eb502820 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,7 +1,7 @@ { - "cliVersion": "4.76.1", + "cliVersion": "5.6.0", "generatorName": "fernapi/fern-csharp-sdk", - "generatorVersion": "2.62.0", + "generatorVersion": "2.66.1", "generatorConfig": { "namespace": "SchematicHQ.Client", "client-class-name": "SchematicApi", @@ -12,6 +12,10 @@ }, "generate-mock-server-tests": false }, - "originGitCommit": "65ef3b80b68cd7596daad7fa53232ea510ad01f2", + "originGitCommit": "4fd82021eff164a6f2484d4504850c46fe8f4a95", + "originGitCommitIsDirty": false, + "invokedBy": "ci", + "requestedVersion": "1.4.5", + "ciProvider": "github", "sdkVersion": "1.4.5" } \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..1de04769 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,119 @@ +# Contributing + +Thanks for your interest in contributing to this SDK! This document provides guidelines for contributing to the project. + +## Getting Started + +### Prerequisites + +- .NET SDK (version compatible with the target frameworks: net462, net8.0, netstandard2.0) + +### Installation + +Install the project dependencies: + +```bash +dotnet restore +``` + +### Building + +Build the project: + +```bash +dotnet build +``` + +### Testing + +Run the test suite: + +```bash +dotnet test +``` + +### Formatting + +Check code style: + +```bash +dotnet format --verify-no-changes +``` + +Fix code style issues: + +```bash +dotnet format +``` + +## About Generated Code + +**Important**: Most files in this SDK are automatically generated by [Fern](https://buildwithfern.com) from the API definition. Direct modifications to generated files will be overwritten the next time the SDK is generated. + +### Generated Files + +The following directories contain generated code: +- `src/` - API client classes and types +- Most C# files in the project + +### How to Customize + +If you need to customize the SDK, you have two options: + +#### Option 1: Use `.fernignore` + +For custom code that should persist across SDK regenerations: + +1. Create a `.fernignore` file in the project root +2. Add file patterns for files you want to preserve (similar to `.gitignore` syntax) +3. Add your custom code to those files + +Files listed in `.fernignore` will not be overwritten when the SDK is regenerated. + +For more information, see the [Fern documentation on custom code](https://buildwithfern.com/learn/sdks/overview/custom-code). + +#### Option 2: Contribute to the Generator + +If you want to change how code is generated for all users of this SDK: + +1. The C# SDK generator lives in the [Fern repository](https://github.com/fern-api/fern) +2. Generator code is located at `generators/csharp/` +3. Follow the [Fern contributing guidelines](https://github.com/fern-api/fern/blob/main/CONTRIBUTING.md) +4. Submit a pull request with your changes to the generator + +This approach is best for: +- Bug fixes in generated code +- New features that would benefit all users +- Improvements to code generation patterns + +## Making Changes + +### Workflow + +1. Create a new branch for your changes +2. Make your modifications +3. Run tests to ensure nothing breaks: `dotnet test` +4. Run formatting: `dotnet format` +5. Build the project: `dotnet build` +6. Commit your changes with a clear commit message +7. Push your branch and create a pull request + +### Commit Messages + +Write clear, descriptive commit messages that explain what changed and why. + +### Code Style + +This project uses automated code formatting. Run `dotnet format` before committing to ensure your code meets the project's style guidelines. + +## Questions or Issues? + +If you have questions or run into issues: + +1. Check the [Fern documentation](https://buildwithfern.com) +2. Search existing [GitHub issues](https://github.com/fern-api/fern/issues) +3. Open a new issue if your question hasn't been addressed + +## License + +By contributing to this project, you agree that your contributions will be licensed under the same license as the project. diff --git a/reference.md b/reference.md index 243cbe04..2953406a 100644 --- a/reference.md +++ b/reference.md @@ -16,7 +16,7 @@ await client.Accounts.ListAccountMembersAsync( new ListAccountMembersRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Q = "q", Limit = 1000000, Offset = 1000000, @@ -510,7 +510,7 @@ await client.Accounts.CountAuditLogsAsync( await client.Accounts.ListEnvironmentsAsync( new ListEnvironmentsRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Limit = 1000000, Offset = 1000000, } @@ -930,7 +930,7 @@ await client.Billing.UpsertBillingCustomerAsync( await client.Billing.ListCustomersWithSubscriptionsAsync( new ListCustomersWithSubscriptionsRequest { - CompanyIds = [new List() { "company_ids" }], + CompanyIds = new List() { "company_ids" }, Name = "name", ProviderType = BillingProviderType.Orb, Q = "q", @@ -980,7 +980,7 @@ await client.Billing.ListCustomersWithSubscriptionsAsync( await client.Billing.CountCustomersAsync( new CountCustomersRequest { - CompanyIds = [new List() { "company_ids" }], + CompanyIds = new List() { "company_ids" }, Name = "name", ProviderType = BillingProviderType.Orb, Q = "q", @@ -1323,12 +1323,12 @@ await client.Billing.ListBillingPricesAsync( Currency = "currency", ForInitialPlan = true, ForTrialExpiryPlan = true, - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Interval = "interval", IsActive = true, Price = 1000000, ProductId = "product_id", - ProductIds = [new List() { "product_ids" }], + ProductIds = new List() { "product_ids" }, ProviderType = BillingProviderType.Orb, Q = "q", TiersMode = BillingTiersMode.Graduated, @@ -1480,12 +1480,12 @@ await client.Billing.ListBillingProductPricesAsync( Currency = "currency", ForInitialPlan = true, ForTrialExpiryPlan = true, - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Interval = "interval", IsActive = true, Price = 1000000, ProductId = "product_id", - ProductIds = [new List() { "product_ids" }], + ProductIds = new List() { "product_ids" }, ProviderType = BillingProviderType.Orb, Q = "q", TiersMode = BillingTiersMode.Graduated, @@ -1619,12 +1619,13 @@ await client.Billing.UpsertBillingProductAsync( await client.Billing.ListBillingProductsAsync( new ListBillingProductsRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, IsActive = true, Name = "name", PriceUsageType = BillingPriceUsageType.Licensed, ProviderType = BillingProviderType.Orb, Q = "q", + RecurringChargesOnly = true, WithOneTimeCharges = true, WithPricesOnly = true, WithZeroPrice = true, @@ -1675,12 +1676,13 @@ await client.Billing.ListBillingProductsAsync( await client.Billing.CountBillingProductsAsync( new CountBillingProductsRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, IsActive = true, Name = "name", PriceUsageType = BillingPriceUsageType.Licensed, ProviderType = BillingProviderType.Orb, Q = "q", + RecurringChargesOnly = true, WithOneTimeCharges = true, WithPricesOnly = true, WithZeroPrice = true, @@ -1805,7 +1807,7 @@ await client.Billing.UpsertBillingSubscriptionAsync( await client.Credits.ListBillingCreditsAsync( new ListBillingCreditsRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Name = "name", Limit = 1000000, Offset = 1000000, @@ -2073,7 +2075,7 @@ await client.Credits.ListCompanyCreditBalancesAsync( await client.Credits.ListCreditBundlesAsync( new ListCreditBundlesRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, CreditId = "credit_id", Status = BillingCreditBundleStatus.Active, BundleType = "fixed", @@ -2302,7 +2304,7 @@ await client.Credits.DeleteCreditBundleAsync("bundle_id"); await client.Credits.CountCreditBundlesAsync( new CountCreditBundlesRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, CreditId = "credit_id", Status = BillingCreditBundleStatus.Active, BundleType = "fixed", @@ -2352,7 +2354,7 @@ await client.Credits.CountCreditBundlesAsync( await client.Credits.CountBillingCreditsAsync( new CountBillingCreditsRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Name = "name", Limit = 1000000, Offset = 1000000, @@ -2595,7 +2597,7 @@ await client.Credits.CountBillingCreditsGrantsAsync( new CountBillingCreditsGrantsRequest { CreditId = "credit_id", - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Limit = 1000000, Offset = 1000000, } @@ -2643,7 +2645,7 @@ await client.Credits.ListGrantsForCreditAsync( new ListGrantsForCreditRequest { CreditId = "credit_id", - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Limit = 1000000, Offset = 1000000, } @@ -2795,10 +2797,11 @@ await client.Credits.ListBillingPlanCreditGrantsAsync( new ListBillingPlanCreditGrantsRequest { CreditId = "credit_id", - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, PlanId = "plan_id", - PlanIds = [new List() { "plan_ids" }], + PlanIds = new List() { "plan_ids" }, PlanVersionId = "plan_version_id", + PlanVersionIds = new List() { "plan_version_ids" }, Limit = 1000000, Offset = 1000000, } @@ -3041,10 +3044,11 @@ await client.Credits.CountBillingPlanCreditGrantsAsync( new CountBillingPlanCreditGrantsRequest { CreditId = "credit_id", - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, PlanId = "plan_id", - PlanIds = [new List() { "plan_ids" }], + PlanIds = new List() { "plan_ids" }, PlanVersionId = "plan_version_id", + PlanVersionIds = new List() { "plan_version_ids" }, Limit = 1000000, Offset = 1000000, } @@ -3200,6 +3204,10 @@ await client.Checkout.InternalAsync( { new UpdateAddOnRequestBody { AddOnId = "add_on_id", PriceId = "price_id" }, }, + AutoTopupOverrides = new List() + { + new UpdateAutoTopupOverrideRequestBody { PlanCreditGrantId = "plan_credit_grant_id" }, + }, CompanyId = "company_id", CreditBundles = new List() { @@ -3302,6 +3310,10 @@ await client.Checkout.PreviewCheckoutInternalAsync( { new UpdateAddOnRequestBody { AddOnId = "add_on_id", PriceId = "price_id" }, }, + AutoTopupOverrides = new List() + { + new UpdateAutoTopupOverrideRequestBody { PlanCreditGrantId = "plan_credit_grant_id" }, + }, CompanyId = "company_id", CreditBundles = new List() { @@ -3560,18 +3572,18 @@ await client.Checkout.UpdateCustomerSubscriptionTrialEndAsync( await client.Companies.ListCompaniesAsync( new ListCompaniesRequest { - CreditTypeIds = [new List() { "credit_type_ids" }], + CreditTypeIds = new List() { "credit_type_ids" }, HasScheduledDowngrade = true, - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, MonetizedSubscriptions = true, PlanId = "plan_id", - PlanIds = [new List() { "plan_ids" }], + PlanIds = new List() { "plan_ids" }, PlanVersionId = "plan_version_id", Q = "q", SortOrderColumn = "sort_order_column", SortOrderDirection = SortDirection.Asc, - SubscriptionStatuses = [new List() { SubscriptionStatus.Active }], - SubscriptionTypes = [new List() { SubscriptionType.Free }], + SubscriptionStatuses = new List() { SubscriptionStatus.Active }, + SubscriptionTypes = new List() { SubscriptionType.Free }, WithEntitlementFor = "with_entitlement_for", WithoutFeatureOverrideFor = "without_feature_override_for", WithoutPlan = true, @@ -3756,18 +3768,18 @@ await client.Companies.DeleteCompanyAsync( await client.Companies.CountCompaniesAsync( new CountCompaniesRequest { - CreditTypeIds = [new List() { "credit_type_ids" }], + CreditTypeIds = new List() { "credit_type_ids" }, HasScheduledDowngrade = true, - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, MonetizedSubscriptions = true, PlanId = "plan_id", - PlanIds = [new List() { "plan_ids" }], + PlanIds = new List() { "plan_ids" }, PlanVersionId = "plan_version_id", Q = "q", SortOrderColumn = "sort_order_column", SortOrderDirection = SortDirection.Asc, - SubscriptionStatuses = [new List() { SubscriptionStatus.Active }], - SubscriptionTypes = [new List() { SubscriptionType.Free }], + SubscriptionStatuses = new List() { SubscriptionStatus.Active }, + SubscriptionTypes = new List() { SubscriptionType.Free }, WithEntitlementFor = "with_entitlement_for", WithoutFeatureOverrideFor = "without_feature_override_for", WithoutPlan = true, @@ -4094,7 +4106,7 @@ await client.Companies.GetActiveCompanySubscriptionAsync( new GetActiveCompanySubscriptionRequest { CompanyId = "company_id", - CompanyIds = [new List() { "company_ids" }], + CompanyIds = new List() { "company_ids" }, Limit = 1000000, Offset = 1000000, } @@ -4188,7 +4200,7 @@ await client.Companies.ListEntityKeyDefinitionsAsync( new ListEntityKeyDefinitionsRequest { EntityType = EntityType.Company, - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Q = "q", Limit = 1000000, Offset = 1000000, @@ -4237,7 +4249,7 @@ await client.Companies.CountEntityKeyDefinitionsAsync( new CountEntityKeyDefinitionsRequest { EntityType = EntityType.Company, - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Q = "q", Limit = 1000000, Offset = 1000000, @@ -4286,10 +4298,10 @@ await client.Companies.ListEntityTraitDefinitionsAsync( new ListEntityTraitDefinitionsRequest { EntityType = EntityType.Company, - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Q = "q", TraitType = TraitType.Boolean, - TraitTypes = [new List() { TraitType.Boolean }], + TraitTypes = new List() { TraitType.Boolean }, Limit = 1000000, Offset = 1000000, } @@ -4475,10 +4487,10 @@ await client.Companies.CountEntityTraitDefinitionsAsync( new CountEntityTraitDefinitionsRequest { EntityType = EntityType.Company, - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Q = "q", TraitType = TraitType.Boolean, - TraitTypes = [new List() { TraitType.Boolean }], + TraitTypes = new List() { TraitType.Boolean }, Limit = 1000000, Offset = 1000000, } @@ -4576,8 +4588,8 @@ await client.Companies.ListPlanChangesAsync( Action = PlanChangeAction.Checkout, BasePlanAction = PlanChangeBasePlanAction.Fallback, CompanyId = "company_id", - CompanyIds = [new List() { "company_ids" }], - PlanIds = [new List() { "plan_ids" }], + CompanyIds = new List() { "company_ids" }, + PlanIds = new List() { "plan_ids" }, Limit = 1000000, Offset = 1000000, } @@ -4664,10 +4676,10 @@ await client.Companies.GetPlanChangeAsync("plan_change_id"); await client.Companies.ListPlanTraitsAsync( new ListPlanTraitsRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, PlanId = "plan_id", TraitId = "trait_id", - TraitIds = [new List() { "trait_ids" }], + TraitIds = new List() { "trait_ids" }, Limit = 1000000, Offset = 1000000, } @@ -4808,10 +4820,10 @@ await client.Companies.UpdatePlanTraitsBulkAsync( await client.Companies.CountPlanTraitsAsync( new CountPlanTraitsRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, PlanId = "plan_id", TraitId = "trait_id", - TraitIds = [new List() { "trait_ids" }], + TraitIds = new List() { "trait_ids" }, Limit = 1000000, Offset = 1000000, } @@ -4905,7 +4917,7 @@ await client.Companies.ListUsersAsync( new ListUsersRequest { CompanyId = "company_id", - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, PlanId = "plan_id", Q = "q", Limit = 1000000, @@ -5077,7 +5089,7 @@ await client.Companies.CountUsersAsync( new CountUsersRequest { CompanyId = "company_id", - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, PlanId = "plan_id", Q = "q", Limit = 1000000, @@ -5254,10 +5266,10 @@ await client.Entitlements.ListCompanyOverridesAsync( new ListCompanyOverridesRequest { CompanyId = "company_id", - CompanyIds = [new List() { "company_ids" }], + CompanyIds = new List() { "company_ids" }, FeatureId = "feature_id", - FeatureIds = [new List() { "feature_ids" }], - Ids = [new List() { "ids" }], + FeatureIds = new List() { "feature_ids" }, + Ids = new List() { "ids" }, WithoutExpired = true, Q = "q", Limit = 1000000, @@ -5485,10 +5497,10 @@ await client.Entitlements.CountCompanyOverridesAsync( new CountCompanyOverridesRequest { CompanyId = "company_id", - CompanyIds = [new List() { "company_ids" }], + CompanyIds = new List() { "company_ids" }, FeatureId = "feature_id", - FeatureIds = [new List() { "feature_ids" }], - Ids = [new List() { "ids" }], + FeatureIds = new List() { "feature_ids" }, + Ids = new List() { "ids" }, WithoutExpired = true, Q = "q", Limit = 1000000, @@ -5634,7 +5646,7 @@ await client.Entitlements.ListFeatureUsageAsync( new ListFeatureUsageRequest { CompanyId = "company_id", - FeatureIds = [new List() { "feature_ids" }], + FeatureIds = new List() { "feature_ids" }, IncludeUsageAggregation = true, Q = "q", WithoutNegativeEntitlements = true, @@ -5734,7 +5746,7 @@ await client.Entitlements.CountFeatureUsageAsync( new CountFeatureUsageRequest { CompanyId = "company_id", - FeatureIds = [new List() { "feature_ids" }], + FeatureIds = new List() { "feature_ids" }, IncludeUsageAggregation = true, Q = "q", WithoutNegativeEntitlements = true, @@ -5881,12 +5893,12 @@ await client.Entitlements.ListPlanEntitlementsAsync( new ListPlanEntitlementsRequest { FeatureId = "feature_id", - FeatureIds = [new List() { "feature_ids" }], - Ids = [new List() { "ids" }], + FeatureIds = new List() { "feature_ids" }, + Ids = new List() { "ids" }, PlanId = "plan_id", - PlanIds = [new List() { "plan_ids" }], + PlanIds = new List() { "plan_ids" }, PlanVersionId = "plan_version_id", - PlanVersionIds = [new List() { "plan_version_ids" }], + PlanVersionIds = new List() { "plan_version_ids" }, Q = "q", WithMeteredProducts = true, Limit = 1000000, @@ -6163,12 +6175,12 @@ await client.Entitlements.CountPlanEntitlementsAsync( new CountPlanEntitlementsRequest { FeatureId = "feature_id", - FeatureIds = [new List() { "feature_ids" }], - Ids = [new List() { "ids" }], + FeatureIds = new List() { "feature_ids" }, + Ids = new List() { "ids" }, PlanId = "plan_id", - PlanIds = [new List() { "plan_ids" }], + PlanIds = new List() { "plan_ids" }, PlanVersionId = "plan_version_id", - PlanVersionIds = [new List() { "plan_version_ids" }], + PlanVersionIds = new List() { "plan_version_ids" }, Q = "q", WithMeteredProducts = true, Limit = 1000000, @@ -6363,7 +6375,7 @@ await client.Plans.ListCustomPlanBillingsAsync( CompanyId = "company_id", PlanId = "plan_id", Status = CustomPlanBillingStatus.Active, - Statuses = [new List() { CustomPlanBillingStatus.Active }], + Statuses = new List() { CustomPlanBillingStatus.Active }, Limit = 1000000, Offset = 1000000, } @@ -6516,12 +6528,13 @@ await client.Plans.ListPlansAsync( new ListPlansRequest { CompanyId = "company_id", + CompanyScopedOnly = true, ExcludeCompanyScoped = true, ForFallbackPlan = true, ForInitialPlan = true, ForTrialExpiryPlan = true, HasProductId = true, - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, IncludeDraftVersions = true, PlanType = PlanType.Plan, Q = "q", @@ -6957,12 +6970,13 @@ await client.Plans.CountPlansAsync( new CountPlansRequest { CompanyId = "company_id", + CompanyScopedOnly = true, ExcludeCompanyScoped = true, ForFallbackPlan = true, ForInitialPlan = true, ForTrialExpiryPlan = true, HasProductId = true, - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, IncludeDraftVersions = true, PlanType = PlanType.Plan, Q = "q", @@ -7612,7 +7626,7 @@ await client.Events.GetEventSummariesAsync( new GetEventSummariesRequest { Q = "q", - EventSubtypes = [new List() { "event_subtypes" }], + EventSubtypes = new List() { "event_subtypes" }, Limit = 1000000, Offset = 1000000, } @@ -7661,8 +7675,9 @@ await client.Events.ListEventsAsync( { CompanyId = "company_id", EventSubtype = "event_subtype", - EventTypes = [new List() { EventType.FlagCheck }], + EventTypes = new List() { EventType.FlagCheck }, FlagId = "flag_id", + IdempotencyKey = "idempotency_key", UserId = "user_id", Limit = 1000000, Offset = 1000000, @@ -7819,8 +7834,9 @@ await client.Features.ListFeaturesAsync( new ListFeaturesRequest { BooleanRequireEvent = true, - FeatureType = [new List() { FeatureType.Boolean }], - Ids = [new List() { "ids" }], + FeatureType = new List() { FeatureType.Boolean }, + Ids = new List() { "ids" }, + ManagedBy = BillingProviderType.Orb, PlanVersionId = "plan_version_id", Q = "q", WithoutCompanyOverrideFor = "without_company_override_for", @@ -8096,8 +8112,9 @@ await client.Features.CountFeaturesAsync( new CountFeaturesRequest { BooleanRequireEvent = true, - FeatureType = [new List() { FeatureType.Boolean }], - Ids = [new List() { "ids" }], + FeatureType = new List() { FeatureType.Boolean }, + Ids = new List() { "ids" }, + ManagedBy = BillingProviderType.Orb, PlanVersionId = "plan_version_id", Q = "q", WithoutCompanyOverrideFor = "without_company_override_for", @@ -8149,7 +8166,7 @@ await client.Features.ListFlagsAsync( new ListFlagsRequest { FeatureId = "feature_id", - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Q = "q", Limit = 1000000, Offset = 1000000, @@ -8604,7 +8621,7 @@ await client.Features.CountFlagsAsync( new CountFlagsRequest { FeatureId = "feature_id", - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Q = "q", Limit = 1000000, Offset = 1000000, @@ -8886,6 +8903,97 @@ await client.Insights.GetEnvironmentTraitUsageTimeSeriesAsync( ## integrationsapi +
client.Integrationsapi.RunIntegrationAsync(integrationId) -> WithRawResponseTask<RunIntegrationResponse> +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Integrationsapi.RunIntegrationAsync("integration_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**integrationId:** `string` — integration_id + +
+
+
+
+ + +
+
+
+ +
client.Integrationsapi.ListIntegrationsAsync(ListIntegrationsRequest { ... }) -> WithRawResponseTask<ListIntegrationsResponse> +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Integrationsapi.ListIntegrationsAsync( + new ListIntegrationsRequest + { + BillingOnly = true, + ExcludeIds = new List() { "exclude_ids" }, + Id = "id", + State = IntegrationState.Active, + Type = IntegrationType.Clerk, + Limit = 1000000, + Offset = 1000000, + } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `ListIntegrationsRequest` + +
+
+
+
+ + +
+
+
+
client.Integrationsapi.GetIntegrationWebhookUrlAsync(type) -> WithRawResponseTask<GetIntegrationWebhookUrlResponse>
@@ -8922,6 +9030,113 @@ await client.Integrationsapi.GetIntegrationWebhookUrlAsync("type");
+ + +
+ +
client.Integrationsapi.StartDataImportAsync(StartDataImportRequestBody { ... }) -> WithRawResponseTask<StartDataImportResponse> +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Integrationsapi.StartDataImportAsync( + new StartDataImportRequestBody { IntegrationId = "integration_id" } +); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `StartDataImportRequestBody` + +
+
+
+
+ + +
+
+
+ +
client.Integrationsapi.LoadSampleDataSetV2Async() -> WithRawResponseTask<LoadSampleDataSetV2Response> +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Integrationsapi.LoadSampleDataSetV2Async(); +``` +
+
+
+
+ + +
+
+
+ +
client.Integrationsapi.UninstallIntegrationAsync(integrationId) -> WithRawResponseTask<UninstallIntegrationResponse> +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```csharp +await client.Integrationsapi.UninstallIntegrationAsync("integration_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**integrationId:** `string` — integration_id + +
+
+
+
+ +
@@ -9737,7 +9952,7 @@ await client.Accesstokens.IssueTemporaryAccessTokenAsync( await client.Webhooks.ListWebhookEventsAsync( new ListWebhookEventsRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Q = "q", WebhookId = "webhook_id", Limit = 1000000, @@ -9826,7 +10041,7 @@ await client.Webhooks.GetWebhookEventAsync("webhook_event_id"); await client.Webhooks.CountWebhookEventsAsync( new CountWebhookEventsRequest { - Ids = [new List() { "ids" }], + Ids = new List() { "ids" }, Q = "q", WebhookId = "webhook_id", Limit = 1000000, diff --git a/src/SchematicHQ.Client.Test/Utils/JsonAssert.cs b/src/SchematicHQ.Client.Test/Utils/JsonAssert.cs index 8827584b..fe29f091 100644 --- a/src/SchematicHQ.Client.Test/Utils/JsonAssert.cs +++ b/src/SchematicHQ.Client.Test/Utils/JsonAssert.cs @@ -18,12 +18,16 @@ internal static void AreEqual(object actual, string expectedJson) } /// - /// Asserts that the given JSON string survives a deserialization/serialization round-trip - /// intact: deserializes to T then re-serializes and compares to the original JSON. + /// Asserts that the given JSON string survives a deserialization/serialization round-trip. + /// Deserializes to T, re-serializes to get the canonical form, then verifies a second + /// round-trip produces the same canonical form (idempotency). This accounts for serializer + /// options like WhenWritingNull that may normalize the output. /// internal static void Roundtrips(string json) { var deserialized = JsonUtils.Deserialize(json); - AreEqual(deserialized!, json); + var serialized = JsonUtils.Serialize(deserialized!); + var deserialized2 = JsonUtils.Deserialize(serialized); + AreEqual(deserialized2!, serialized); } } diff --git a/src/SchematicHQ.Client/Accounts/AccountsClient.cs b/src/SchematicHQ.Client/Accounts/AccountsClient.cs index 2e06417a..f93c2595 100644 --- a/src/SchematicHQ.Client/Accounts/AccountsClient.cs +++ b/src/SchematicHQ.Client/Accounts/AccountsClient.cs @@ -1657,7 +1657,7 @@ private async Task> GetWhoAmIAsyncCore( /// await client.Accounts.ListAccountMembersAsync( /// new ListAccountMembersRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Q = "q", /// Limit = 1000000, /// Offset = 1000000, @@ -1858,7 +1858,7 @@ public WithRawResponseTask CountAuditLogsAsync( /// await client.Accounts.ListEnvironmentsAsync( /// new ListEnvironmentsRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Limit = 1000000, /// Offset = 1000000, /// } diff --git a/src/SchematicHQ.Client/Billing/BillingClient.cs b/src/SchematicHQ.Client/Billing/BillingClient.cs index 4c3080b9..5619c562 100644 --- a/src/SchematicHQ.Client/Billing/BillingClient.cs +++ b/src/SchematicHQ.Client/Billing/BillingClient.cs @@ -1629,13 +1629,14 @@ private async Task> ListBillingProd CancellationToken cancellationToken = default ) { - var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 12) + var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 13) .Add("ids", request.Ids) .Add("is_active", request.IsActive) .Add("name", request.Name) .Add("price_usage_type", request.PriceUsageType) .Add("provider_type", request.ProviderType) .Add("q", request.Q) + .Add("recurring_charges_only", request.RecurringChargesOnly) .Add("with_one_time_charges", request.WithOneTimeCharges) .Add("with_prices_only", request.WithPricesOnly) .Add("with_zero_price", request.WithZeroPrice) @@ -1734,13 +1735,14 @@ private async Task> CountBillingPr CancellationToken cancellationToken = default ) { - var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 12) + var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 13) .Add("ids", request.Ids) .Add("is_active", request.IsActive) .Add("name", request.Name) .Add("price_usage_type", request.PriceUsageType) .Add("provider_type", request.ProviderType) .Add("q", request.Q) + .Add("recurring_charges_only", request.RecurringChargesOnly) .Add("with_one_time_charges", request.WithOneTimeCharges) .Add("with_prices_only", request.WithPricesOnly) .Add("with_zero_price", request.WithZeroPrice) @@ -2000,7 +2002,7 @@ public WithRawResponseTask UpsertBillingCustomerA /// await client.Billing.ListCustomersWithSubscriptionsAsync( /// new ListCustomersWithSubscriptionsRequest /// { - /// CompanyIds = [new List<string>() { "company_ids" }], + /// CompanyIds = new List<string>() { "company_ids" }, /// Name = "name", /// ProviderType = BillingProviderType.Orb, /// Q = "q", @@ -2024,7 +2026,7 @@ public WithRawResponseTask ListCustomers /// await client.Billing.CountCustomersAsync( /// new CountCustomersRequest /// { - /// CompanyIds = [new List<string>() { "company_ids" }], + /// CompanyIds = new List<string>() { "company_ids" }, /// Name = "name", /// ProviderType = BillingProviderType.Orb, /// Q = "q", @@ -2185,12 +2187,12 @@ public WithRawResponseTask UpsertPaymentMethodAsync /// Currency = "currency", /// ForInitialPlan = true, /// ForTrialExpiryPlan = true, - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Interval = "interval", /// IsActive = true, /// Price = 1000000, /// ProductId = "product_id", - /// ProductIds = [new List<string>() { "product_ids" }], + /// ProductIds = new List<string>() { "product_ids" }, /// ProviderType = BillingProviderType.Orb, /// Q = "q", /// TiersMode = BillingTiersMode.Graduated, @@ -2264,12 +2266,12 @@ public WithRawResponseTask DeleteBillingProductAsy /// Currency = "currency", /// ForInitialPlan = true, /// ForTrialExpiryPlan = true, - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Interval = "interval", /// IsActive = true, /// Price = 1000000, /// ProductId = "product_id", - /// ProductIds = [new List<string>() { "product_ids" }], + /// ProductIds = new List<string>() { "product_ids" }, /// ProviderType = BillingProviderType.Orb, /// Q = "q", /// TiersMode = BillingTiersMode.Graduated, @@ -2325,12 +2327,13 @@ public WithRawResponseTask UpsertBillingProductAsy /// await client.Billing.ListBillingProductsAsync( /// new ListBillingProductsRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// IsActive = true, /// Name = "name", /// PriceUsageType = BillingPriceUsageType.Licensed, /// ProviderType = BillingProviderType.Orb, /// Q = "q", + /// RecurringChargesOnly = true, /// WithOneTimeCharges = true, /// WithPricesOnly = true, /// WithZeroPrice = true, @@ -2355,12 +2358,13 @@ public WithRawResponseTask ListBillingProductsAsync /// await client.Billing.CountBillingProductsAsync( /// new CountBillingProductsRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// IsActive = true, /// Name = "name", /// PriceUsageType = BillingPriceUsageType.Licensed, /// ProviderType = BillingProviderType.Orb, /// Q = "q", + /// RecurringChargesOnly = true, /// WithOneTimeCharges = true, /// WithPricesOnly = true, /// WithZeroPrice = true, diff --git a/src/SchematicHQ.Client/Billing/Requests/CountBillingProductsRequest.cs b/src/SchematicHQ.Client/Billing/Requests/CountBillingProductsRequest.cs index 4ba54a8e..aefee731 100644 --- a/src/SchematicHQ.Client/Billing/Requests/CountBillingProductsRequest.cs +++ b/src/SchematicHQ.Client/Billing/Requests/CountBillingProductsRequest.cs @@ -27,6 +27,12 @@ public record CountBillingProductsRequest [JsonIgnore] public string? Q { get; set; } + /// + /// Filter to products that have at least one recurring price + /// + [JsonIgnore] + public bool? RecurringChargesOnly { get; set; } + /// /// Filter products that are one time charges /// diff --git a/src/SchematicHQ.Client/Billing/Requests/ListBillingProductsRequest.cs b/src/SchematicHQ.Client/Billing/Requests/ListBillingProductsRequest.cs index 81eefc00..fc5f5dde 100644 --- a/src/SchematicHQ.Client/Billing/Requests/ListBillingProductsRequest.cs +++ b/src/SchematicHQ.Client/Billing/Requests/ListBillingProductsRequest.cs @@ -27,6 +27,12 @@ public record ListBillingProductsRequest [JsonIgnore] public string? Q { get; set; } + /// + /// Filter to products that have at least one recurring price + /// + [JsonIgnore] + public bool? RecurringChargesOnly { get; set; } + /// /// Filter products that are one time charges /// diff --git a/src/SchematicHQ.Client/Billing/Types/CountBillingProductsParams.cs b/src/SchematicHQ.Client/Billing/Types/CountBillingProductsParams.cs index c0ad20c4..da60146f 100644 --- a/src/SchematicHQ.Client/Billing/Types/CountBillingProductsParams.cs +++ b/src/SchematicHQ.Client/Billing/Types/CountBillingProductsParams.cs @@ -47,6 +47,12 @@ public record CountBillingProductsParams : IJsonOnDeserialized [JsonPropertyName("q")] public string? Q { get; set; } + /// + /// Filter to products that have at least one recurring price + /// + [JsonPropertyName("recurring_charges_only")] + public bool? RecurringChargesOnly { get; set; } + /// /// Filter products that are one time charges /// diff --git a/src/SchematicHQ.Client/Billing/Types/ListBillingProductsParams.cs b/src/SchematicHQ.Client/Billing/Types/ListBillingProductsParams.cs index 7895154f..596288e7 100644 --- a/src/SchematicHQ.Client/Billing/Types/ListBillingProductsParams.cs +++ b/src/SchematicHQ.Client/Billing/Types/ListBillingProductsParams.cs @@ -47,6 +47,12 @@ public record ListBillingProductsParams : IJsonOnDeserialized [JsonPropertyName("q")] public string? Q { get; set; } + /// + /// Filter to products that have at least one recurring price + /// + [JsonPropertyName("recurring_charges_only")] + public bool? RecurringChargesOnly { get; set; } + /// /// Filter products that are one time charges /// diff --git a/src/SchematicHQ.Client/Checkout/CheckoutClient.cs b/src/SchematicHQ.Client/Checkout/CheckoutClient.cs index 97878d30..7c16499c 100644 --- a/src/SchematicHQ.Client/Checkout/CheckoutClient.cs +++ b/src/SchematicHQ.Client/Checkout/CheckoutClient.cs @@ -656,6 +656,10 @@ private async Task< /// { /// new UpdateAddOnRequestBody { AddOnId = "add_on_id", PriceId = "price_id" }, /// }, + /// AutoTopupOverrides = new List<UpdateAutoTopupOverrideRequestBody>() + /// { + /// new UpdateAutoTopupOverrideRequestBody { PlanCreditGrantId = "plan_credit_grant_id" }, + /// }, /// CompanyId = "company_id", /// CreditBundles = new List<UpdateCreditBundleRequestBody>() /// { @@ -706,6 +710,10 @@ public WithRawResponseTask GetCheckoutDataAsync( /// { /// new UpdateAddOnRequestBody { AddOnId = "add_on_id", PriceId = "price_id" }, /// }, + /// AutoTopupOverrides = new List<UpdateAutoTopupOverrideRequestBody>() + /// { + /// new UpdateAutoTopupOverrideRequestBody { PlanCreditGrantId = "plan_credit_grant_id" }, + /// }, /// CompanyId = "company_id", /// CreditBundles = new List<UpdateCreditBundleRequestBody>() /// { diff --git a/src/SchematicHQ.Client/Companies/CompaniesClient.cs b/src/SchematicHQ.Client/Companies/CompaniesClient.cs index c0a82073..fd75d9f5 100644 --- a/src/SchematicHQ.Client/Companies/CompaniesClient.cs +++ b/src/SchematicHQ.Client/Companies/CompaniesClient.cs @@ -3408,18 +3408,18 @@ private async Task> LookupUserAsyncCore( /// await client.Companies.ListCompaniesAsync( /// new ListCompaniesRequest /// { - /// CreditTypeIds = [new List<string>() { "credit_type_ids" }], + /// CreditTypeIds = new List<string>() { "credit_type_ids" }, /// HasScheduledDowngrade = true, - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// MonetizedSubscriptions = true, /// PlanId = "plan_id", - /// PlanIds = [new List<string>() { "plan_ids" }], + /// PlanIds = new List<string>() { "plan_ids" }, /// PlanVersionId = "plan_version_id", /// Q = "q", /// SortOrderColumn = "sort_order_column", /// SortOrderDirection = SortDirection.Asc, - /// SubscriptionStatuses = [new List<SubscriptionStatus>() { SubscriptionStatus.Active }], - /// SubscriptionTypes = [new List<SubscriptionType>() { SubscriptionType.Free }], + /// SubscriptionStatuses = new List<SubscriptionStatus>() { SubscriptionStatus.Active }, + /// SubscriptionTypes = new List<SubscriptionType>() { SubscriptionType.Free }, /// WithEntitlementFor = "with_entitlement_for", /// WithoutFeatureOverrideFor = "without_feature_override_for", /// WithoutPlan = true, @@ -3493,18 +3493,18 @@ public WithRawResponseTask DeleteCompanyAsync( /// await client.Companies.CountCompaniesAsync( /// new CountCompaniesRequest /// { - /// CreditTypeIds = [new List<string>() { "credit_type_ids" }], + /// CreditTypeIds = new List<string>() { "credit_type_ids" }, /// HasScheduledDowngrade = true, - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// MonetizedSubscriptions = true, /// PlanId = "plan_id", - /// PlanIds = [new List<string>() { "plan_ids" }], + /// PlanIds = new List<string>() { "plan_ids" }, /// PlanVersionId = "plan_version_id", /// Q = "q", /// SortOrderColumn = "sort_order_column", /// SortOrderDirection = SortDirection.Asc, - /// SubscriptionStatuses = [new List<SubscriptionStatus>() { SubscriptionStatus.Active }], - /// SubscriptionTypes = [new List<SubscriptionType>() { SubscriptionType.Free }], + /// SubscriptionStatuses = new List<SubscriptionStatus>() { SubscriptionStatus.Active }, + /// SubscriptionTypes = new List<SubscriptionType>() { SubscriptionType.Free }, /// WithEntitlementFor = "with_entitlement_for", /// WithoutFeatureOverrideFor = "without_feature_override_for", /// WithoutPlan = true, @@ -3638,7 +3638,7 @@ public WithRawResponseTask DeleteCompanyMembers /// new GetActiveCompanySubscriptionRequest /// { /// CompanyId = "company_id", - /// CompanyIds = [new List<string>() { "company_ids" }], + /// CompanyIds = new List<string>() { "company_ids" }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -3680,7 +3680,7 @@ public WithRawResponseTask UpsertCompanyTraitAsync( /// new ListEntityKeyDefinitionsRequest /// { /// EntityType = EntityType.Company, - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Q = "q", /// Limit = 1000000, /// Offset = 1000000, @@ -3703,7 +3703,7 @@ public WithRawResponseTask ListEntityKeyDefini /// new CountEntityKeyDefinitionsRequest /// { /// EntityType = EntityType.Company, - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Q = "q", /// Limit = 1000000, /// Offset = 1000000, @@ -3726,10 +3726,10 @@ public WithRawResponseTask CountEntityKeyDefi /// new ListEntityTraitDefinitionsRequest /// { /// EntityType = EntityType.Company, - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Q = "q", /// TraitType = TraitType.Boolean, - /// TraitTypes = [new List<TraitType>() { TraitType.Boolean }], + /// TraitTypes = new List<TraitType>() { TraitType.Boolean }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -3809,10 +3809,10 @@ public WithRawResponseTask UpdateEntityTrai /// new CountEntityTraitDefinitionsRequest /// { /// EntityType = EntityType.Company, - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Q = "q", /// TraitType = TraitType.Boolean, - /// TraitTypes = [new List<TraitType>() { TraitType.Boolean }], + /// TraitTypes = new List<TraitType>() { TraitType.Boolean }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -3858,8 +3858,8 @@ public WithRawResponseTask GetEntityTraitValuesAsy /// Action = PlanChangeAction.Checkout, /// BasePlanAction = PlanChangeBasePlanAction.Fallback, /// CompanyId = "company_id", - /// CompanyIds = [new List<string>() { "company_ids" }], - /// PlanIds = [new List<string>() { "plan_ids" }], + /// CompanyIds = new List<string>() { "company_ids" }, + /// PlanIds = new List<string>() { "plan_ids" }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -3894,10 +3894,10 @@ public WithRawResponseTask GetPlanChangeAsync( /// await client.Companies.ListPlanTraitsAsync( /// new ListPlanTraitsRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// PlanId = "plan_id", /// TraitId = "trait_id", - /// TraitIds = [new List<string>() { "trait_ids" }], + /// TraitIds = new List<string>() { "trait_ids" }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -3960,10 +3960,10 @@ public WithRawResponseTask UpdatePlanTraitsBulkAsy /// await client.Companies.CountPlanTraitsAsync( /// new CountPlanTraitsRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// PlanId = "plan_id", /// TraitId = "trait_id", - /// TraitIds = [new List<string>() { "trait_ids" }], + /// TraitIds = new List<string>() { "trait_ids" }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -4005,7 +4005,7 @@ public WithRawResponseTask UpsertUserTraitAsync( /// new ListUsersRequest /// { /// CompanyId = "company_id", - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// PlanId = "plan_id", /// Q = "q", /// Limit = 1000000, @@ -4073,7 +4073,7 @@ public WithRawResponseTask DeleteUserAsync( /// new CountUsersRequest /// { /// CompanyId = "company_id", - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// PlanId = "plan_id", /// Q = "q", /// Limit = 1000000, diff --git a/src/SchematicHQ.Client/Core/OneOfSerializer.cs b/src/SchematicHQ.Client/Core/OneOfSerializer.cs index 0b3403ab..79655d92 100644 --- a/src/SchematicHQ.Client/Core/OneOfSerializer.cs +++ b/src/SchematicHQ.Client/Core/OneOfSerializer.cs @@ -16,21 +16,66 @@ JsonSerializerOptions options if (reader.TokenType is JsonTokenType.Null) return default; + var json = JsonElement.ParseValue(ref reader); + + IOneOf? firstMatch = null; + IOneOf? bestMatch = null; + foreach (var (type, cast) in GetOneOfTypes(typeToConvert)) { try { - var readerCopy = reader; - var result = JsonSerializer.Deserialize(ref readerCopy, type, options); - reader.Skip(); - return (IOneOf)cast.Invoke(null, [result])!; + var result = JsonSerializer.Deserialize(json, type, options); + var oneOf = (IOneOf)cast.Invoke(null, [result])!; + firstMatch ??= oneOf; + + if (!ContainsJsonElement(result)) + { + bestMatch = oneOf; + break; + } } catch (JsonException) { } } - throw new JsonException( - $"Cannot deserialize into one of the supported types for {typeToConvert}" - ); + return bestMatch + ?? firstMatch + ?? throw new JsonException( + $"Cannot deserialize into one of the supported types for {typeToConvert}" + ); + } + + /// + /// Checks if the deserialized object is or contains a raw JsonElement value, + /// indicating the deserializer used a catch-all strategy rather than + /// strongly-typed deserialization. + /// + private static bool ContainsJsonElement(object? result) + { + if (result == null || result is JsonElement) + return true; + + foreach ( + var prop in result.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance) + ) + { + if (prop.GetCustomAttribute() != null) + continue; + if (prop.GetCustomAttribute() != null) + continue; + + try + { + if (prop.GetValue(result) is JsonElement) + return true; + } + catch + { + // Ignore inaccessible properties + } + } + + return false; } public override void Write(Utf8JsonWriter writer, IOneOf value, JsonSerializerOptions options) diff --git a/src/SchematicHQ.Client/Core/RawClient.cs b/src/SchematicHQ.Client/Core/RawClient.cs index 93c59956..83c17714 100644 --- a/src/SchematicHQ.Client/Core/RawClient.cs +++ b/src/SchematicHQ.Client/Core/RawClient.cs @@ -174,7 +174,8 @@ CancellationToken cancellationToken private static bool ShouldRetry(HttpResponseMessage response) { var statusCode = (int)response.StatusCode; - return statusCode is 408 or 429 or >= 500; + + return statusCode is 408 or 429 or (>= 500); } private static int AddPositiveJitter(int delayMs) diff --git a/src/SchematicHQ.Client/Credits/CreditsClient.cs b/src/SchematicHQ.Client/Credits/CreditsClient.cs index 25ef4bc9..98e821e8 100644 --- a/src/SchematicHQ.Client/Credits/CreditsClient.cs +++ b/src/SchematicHQ.Client/Credits/CreditsClient.cs @@ -2014,12 +2014,13 @@ private async Task< CancellationToken cancellationToken = default ) { - var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 7) + var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 8) .Add("credit_id", request.CreditId) .Add("ids", request.Ids) .Add("plan_id", request.PlanId) .Add("plan_ids", request.PlanIds) .Add("plan_version_id", request.PlanVersionId) + .Add("plan_version_ids", request.PlanVersionIds) .Add("limit", request.Limit) .Add("offset", request.Offset) .MergeAdditional(options?.AdditionalQueryParameters) @@ -2498,12 +2499,13 @@ private async Task< CancellationToken cancellationToken = default ) { - var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 7) + var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 8) .Add("credit_id", request.CreditId) .Add("ids", request.Ids) .Add("plan_id", request.PlanId) .Add("plan_ids", request.PlanIds) .Add("plan_version_id", request.PlanVersionId) + .Add("plan_version_ids", request.PlanVersionIds) .Add("limit", request.Limit) .Add("offset", request.Offset) .MergeAdditional(options?.AdditionalQueryParameters) @@ -2802,7 +2804,7 @@ private async Task< /// await client.Credits.ListBillingCreditsAsync( /// new ListBillingCreditsRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Name = "name", /// Limit = 1000000, /// Offset = 1000000, @@ -2907,7 +2909,7 @@ public WithRawResponseTask ListCompanyCreditB /// await client.Credits.ListCreditBundlesAsync( /// new ListCreditBundlesRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// CreditId = "credit_id", /// Status = BillingCreditBundleStatus.Active, /// BundleType = "fixed", @@ -2999,7 +3001,7 @@ public WithRawResponseTask DeleteCreditBundleAsync( /// await client.Credits.CountCreditBundlesAsync( /// new CountCreditBundlesRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// CreditId = "credit_id", /// Status = BillingCreditBundleStatus.Active, /// BundleType = "fixed", @@ -3023,7 +3025,7 @@ public WithRawResponseTask CountCreditBundlesAsync( /// await client.Credits.CountBillingCreditsAsync( /// new CountBillingCreditsRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Name = "name", /// Limit = 1000000, /// Offset = 1000000, @@ -3129,7 +3131,7 @@ public WithRawResponseTask ListCompanyGrantsAsync( /// new CountBillingCreditsGrantsRequest /// { /// CreditId = "credit_id", - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -3151,7 +3153,7 @@ public WithRawResponseTask CountBillingCredit /// new ListGrantsForCreditRequest /// { /// CreditId = "credit_id", - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -3225,10 +3227,11 @@ public WithRawResponseTask CountCreditLedgerAsync( /// new ListBillingPlanCreditGrantsRequest /// { /// CreditId = "credit_id", - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// PlanId = "plan_id", - /// PlanIds = [new List<string>() { "plan_ids" }], + /// PlanIds = new List<string>() { "plan_ids" }, /// PlanVersionId = "plan_version_id", + /// PlanVersionIds = new List<string>() { "plan_version_ids" }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -3327,10 +3330,11 @@ public WithRawResponseTask DeleteBillingPl /// new CountBillingPlanCreditGrantsRequest /// { /// CreditId = "credit_id", - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// PlanId = "plan_id", - /// PlanIds = [new List<string>() { "plan_ids" }], + /// PlanIds = new List<string>() { "plan_ids" }, /// PlanVersionId = "plan_version_id", + /// PlanVersionIds = new List<string>() { "plan_version_ids" }, /// Limit = 1000000, /// Offset = 1000000, /// } diff --git a/src/SchematicHQ.Client/Credits/Requests/CountBillingPlanCreditGrantsRequest.cs b/src/SchematicHQ.Client/Credits/Requests/CountBillingPlanCreditGrantsRequest.cs index c624f6dd..f194855f 100644 --- a/src/SchematicHQ.Client/Credits/Requests/CountBillingPlanCreditGrantsRequest.cs +++ b/src/SchematicHQ.Client/Credits/Requests/CountBillingPlanCreditGrantsRequest.cs @@ -21,6 +21,9 @@ public record CountBillingPlanCreditGrantsRequest [JsonIgnore] public string? PlanVersionId { get; set; } + [JsonIgnore] + public IEnumerable PlanVersionIds { get; set; } = new List(); + /// /// Page limit (default 100) /// diff --git a/src/SchematicHQ.Client/Credits/Requests/ListBillingPlanCreditGrantsRequest.cs b/src/SchematicHQ.Client/Credits/Requests/ListBillingPlanCreditGrantsRequest.cs index 56b5c666..f92196a3 100644 --- a/src/SchematicHQ.Client/Credits/Requests/ListBillingPlanCreditGrantsRequest.cs +++ b/src/SchematicHQ.Client/Credits/Requests/ListBillingPlanCreditGrantsRequest.cs @@ -21,6 +21,9 @@ public record ListBillingPlanCreditGrantsRequest [JsonIgnore] public string? PlanVersionId { get; set; } + [JsonIgnore] + public IEnumerable PlanVersionIds { get; set; } = new List(); + /// /// Page limit (default 100) /// diff --git a/src/SchematicHQ.Client/Credits/Types/CountBillingPlanCreditGrantsParams.cs b/src/SchematicHQ.Client/Credits/Types/CountBillingPlanCreditGrantsParams.cs index e32d4c77..5d7700e6 100644 --- a/src/SchematicHQ.Client/Credits/Types/CountBillingPlanCreditGrantsParams.cs +++ b/src/SchematicHQ.Client/Credits/Types/CountBillingPlanCreditGrantsParams.cs @@ -41,6 +41,9 @@ public record CountBillingPlanCreditGrantsParams : IJsonOnDeserialized [JsonPropertyName("plan_version_id")] public string? PlanVersionId { get; set; } + [JsonPropertyName("plan_version_ids")] + public IEnumerable? PlanVersionIds { get; set; } + [JsonIgnore] public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); diff --git a/src/SchematicHQ.Client/Credits/Types/ListBillingPlanCreditGrantsParams.cs b/src/SchematicHQ.Client/Credits/Types/ListBillingPlanCreditGrantsParams.cs index 30d37e9d..8dbeefb1 100644 --- a/src/SchematicHQ.Client/Credits/Types/ListBillingPlanCreditGrantsParams.cs +++ b/src/SchematicHQ.Client/Credits/Types/ListBillingPlanCreditGrantsParams.cs @@ -41,6 +41,9 @@ public record ListBillingPlanCreditGrantsParams : IJsonOnDeserialized [JsonPropertyName("plan_version_id")] public string? PlanVersionId { get; set; } + [JsonPropertyName("plan_version_ids")] + public IEnumerable? PlanVersionIds { get; set; } + [JsonIgnore] public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); diff --git a/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs b/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs index 4e66d6e3..3ae1ee25 100644 --- a/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs +++ b/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs @@ -2140,10 +2140,10 @@ private async Task< /// new ListCompanyOverridesRequest /// { /// CompanyId = "company_id", - /// CompanyIds = [new List<string>() { "company_ids" }], + /// CompanyIds = new List<string>() { "company_ids" }, /// FeatureId = "feature_id", - /// FeatureIds = [new List<string>() { "feature_ids" }], - /// Ids = [new List<string>() { "ids" }], + /// FeatureIds = new List<string>() { "feature_ids" }, + /// Ids = new List<string>() { "ids" }, /// WithoutExpired = true, /// Q = "q", /// Limit = 1000000, @@ -2234,10 +2234,10 @@ public WithRawResponseTask DeleteCompanyOverrideA /// new CountCompanyOverridesRequest /// { /// CompanyId = "company_id", - /// CompanyIds = [new List<string>() { "company_ids" }], + /// CompanyIds = new List<string>() { "company_ids" }, /// FeatureId = "feature_id", - /// FeatureIds = [new List<string>() { "feature_ids" }], - /// Ids = [new List<string>() { "ids" }], + /// FeatureIds = new List<string>() { "feature_ids" }, + /// Ids = new List<string>() { "ids" }, /// WithoutExpired = true, /// Q = "q", /// Limit = 1000000, @@ -2305,7 +2305,7 @@ public WithRawResponseTask CountFeatureCompaniesA /// new ListFeatureUsageRequest /// { /// CompanyId = "company_id", - /// FeatureIds = [new List<string>() { "feature_ids" }], + /// FeatureIds = new List<string>() { "feature_ids" }, /// IncludeUsageAggregation = true, /// Q = "q", /// WithoutNegativeEntitlements = true, @@ -2353,7 +2353,7 @@ public WithRawResponseTask GetFeatureUsageTim /// new CountFeatureUsageRequest /// { /// CompanyId = "company_id", - /// FeatureIds = [new List<string>() { "feature_ids" }], + /// FeatureIds = new List<string>() { "feature_ids" }, /// IncludeUsageAggregation = true, /// Q = "q", /// WithoutNegativeEntitlements = true, @@ -2422,12 +2422,12 @@ public WithRawResponseTask CountFeatureUsersAsync( /// new ListPlanEntitlementsRequest /// { /// FeatureId = "feature_id", - /// FeatureIds = [new List<string>() { "feature_ids" }], - /// Ids = [new List<string>() { "ids" }], + /// FeatureIds = new List<string>() { "feature_ids" }, + /// Ids = new List<string>() { "ids" }, /// PlanId = "plan_id", - /// PlanIds = [new List<string>() { "plan_ids" }], + /// PlanIds = new List<string>() { "plan_ids" }, /// PlanVersionId = "plan_version_id", - /// PlanVersionIds = [new List<string>() { "plan_version_ids" }], + /// PlanVersionIds = new List<string>() { "plan_version_ids" }, /// Q = "q", /// WithMeteredProducts = true, /// Limit = 1000000, @@ -2541,12 +2541,12 @@ public WithRawResponseTask Upser /// new CountPlanEntitlementsRequest /// { /// FeatureId = "feature_id", - /// FeatureIds = [new List<string>() { "feature_ids" }], - /// Ids = [new List<string>() { "ids" }], + /// FeatureIds = new List<string>() { "feature_ids" }, + /// Ids = new List<string>() { "ids" }, /// PlanId = "plan_id", - /// PlanIds = [new List<string>() { "plan_ids" }], + /// PlanIds = new List<string>() { "plan_ids" }, /// PlanVersionId = "plan_version_id", - /// PlanVersionIds = [new List<string>() { "plan_version_ids" }], + /// PlanVersionIds = new List<string>() { "plan_version_ids" }, /// Q = "q", /// WithMeteredProducts = true, /// Limit = 1000000, diff --git a/src/SchematicHQ.Client/Events/EventsClient.cs b/src/SchematicHQ.Client/Events/EventsClient.cs index 474236c9..5582242d 100644 --- a/src/SchematicHQ.Client/Events/EventsClient.cs +++ b/src/SchematicHQ.Client/Events/EventsClient.cs @@ -202,11 +202,12 @@ private async Task> ListEventsAsyncCore( CancellationToken cancellationToken = default ) { - var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 7) + var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 8) .Add("company_id", request.CompanyId) .Add("event_subtype", request.EventSubtype) .Add("event_types", request.EventTypes) .Add("flag_id", request.FlagId) + .Add("idempotency_key", request.IdempotencyKey) .Add("user_id", request.UserId) .Add("limit", request.Limit) .Add("offset", request.Offset) @@ -583,7 +584,7 @@ public WithRawResponseTask CreateEventBatchAsync( /// new GetEventSummariesRequest /// { /// Q = "q", - /// EventSubtypes = [new List<string>() { "event_subtypes" }], + /// EventSubtypes = new List<string>() { "event_subtypes" }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -606,8 +607,9 @@ public WithRawResponseTask GetEventSummariesAsync( /// { /// CompanyId = "company_id", /// EventSubtype = "event_subtype", - /// EventTypes = [new List<EventType>() { EventType.FlagCheck }], + /// EventTypes = new List<EventType>() { EventType.FlagCheck }, /// FlagId = "flag_id", + /// IdempotencyKey = "idempotency_key", /// UserId = "user_id", /// Limit = 1000000, /// Offset = 1000000, diff --git a/src/SchematicHQ.Client/Events/Requests/ListEventsRequest.cs b/src/SchematicHQ.Client/Events/Requests/ListEventsRequest.cs index aea2023d..133755c3 100644 --- a/src/SchematicHQ.Client/Events/Requests/ListEventsRequest.cs +++ b/src/SchematicHQ.Client/Events/Requests/ListEventsRequest.cs @@ -18,6 +18,9 @@ public record ListEventsRequest [JsonIgnore] public string? FlagId { get; set; } + [JsonIgnore] + public string? IdempotencyKey { get; set; } + [JsonIgnore] public string? UserId { get; set; } diff --git a/src/SchematicHQ.Client/Events/Types/ListEventsParams.cs b/src/SchematicHQ.Client/Events/Types/ListEventsParams.cs index c22852d0..8ec8668f 100644 --- a/src/SchematicHQ.Client/Events/Types/ListEventsParams.cs +++ b/src/SchematicHQ.Client/Events/Types/ListEventsParams.cs @@ -26,6 +26,9 @@ public record ListEventsParams : IJsonOnDeserialized [JsonPropertyName("flag_id")] public string? FlagId { get; set; } + [JsonPropertyName("idempotency_key")] + public string? IdempotencyKey { get; set; } + /// /// Page limit (default 100) /// diff --git a/src/SchematicHQ.Client/Features/FeaturesClient.cs b/src/SchematicHQ.Client/Features/FeaturesClient.cs index c4bfdcaf..e2aa9d7b 100644 --- a/src/SchematicHQ.Client/Features/FeaturesClient.cs +++ b/src/SchematicHQ.Client/Features/FeaturesClient.cs @@ -18,10 +18,11 @@ private async Task> ListFeaturesAsyncCore( CancellationToken cancellationToken = default ) { - var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 9) + var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 10) .Add("boolean_require_event", request.BooleanRequireEvent) .Add("feature_type", request.FeatureType) .Add("ids", request.Ids) + .Add("managed_by", request.ManagedBy) .Add("plan_version_id", request.PlanVersionId) .Add("q", request.Q) .Add("without_company_override_for", request.WithoutCompanyOverrideFor) @@ -571,10 +572,11 @@ private async Task> CountFeaturesAsyncCor CancellationToken cancellationToken = default ) { - var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 9) + var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 10) .Add("boolean_require_event", request.BooleanRequireEvent) .Add("feature_type", request.FeatureType) .Add("ids", request.Ids) + .Add("managed_by", request.ManagedBy) .Add("plan_version_id", request.PlanVersionId) .Add("q", request.Q) .Add("without_company_override_for", request.WithoutCompanyOverrideFor) @@ -1577,8 +1579,9 @@ private async Task> CountFlagsAsyncCore( /// new ListFeaturesRequest /// { /// BooleanRequireEvent = true, - /// FeatureType = [new List<FeatureType>() { FeatureType.Boolean }], - /// Ids = [new List<string>() { "ids" }], + /// FeatureType = new List<FeatureType>() { FeatureType.Boolean }, + /// Ids = new List<string>() { "ids" }, + /// ManagedBy = BillingProviderType.Orb, /// PlanVersionId = "plan_version_id", /// Q = "q", /// WithoutCompanyOverrideFor = "without_company_override_for", @@ -1691,8 +1694,9 @@ public WithRawResponseTask UpsertFeature /// new CountFeaturesRequest /// { /// BooleanRequireEvent = true, - /// FeatureType = [new List<FeatureType>() { FeatureType.Boolean }], - /// Ids = [new List<string>() { "ids" }], + /// FeatureType = new List<FeatureType>() { FeatureType.Boolean }, + /// Ids = new List<string>() { "ids" }, + /// ManagedBy = BillingProviderType.Orb, /// PlanVersionId = "plan_version_id", /// Q = "q", /// WithoutCompanyOverrideFor = "without_company_override_for", @@ -1718,7 +1722,7 @@ public WithRawResponseTask CountFeaturesAsync( /// new ListFlagsRequest /// { /// FeatureId = "feature_id", - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Q = "q", /// Limit = 1000000, /// Offset = 1000000, @@ -1918,7 +1922,7 @@ public WithRawResponseTask CheckFlagsBulkAsync( /// new CountFlagsRequest /// { /// FeatureId = "feature_id", - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Q = "q", /// Limit = 1000000, /// Offset = 1000000, diff --git a/src/SchematicHQ.Client/Features/Requests/CountFeaturesRequest.cs b/src/SchematicHQ.Client/Features/Requests/CountFeaturesRequest.cs index aecc4215..d5a4d802 100644 --- a/src/SchematicHQ.Client/Features/Requests/CountFeaturesRequest.cs +++ b/src/SchematicHQ.Client/Features/Requests/CountFeaturesRequest.cs @@ -21,6 +21,12 @@ public record CountFeaturesRequest [JsonIgnore] public IEnumerable Ids { get; set; } = new List(); + /// + /// Filter for features managed by a billing provider, or by Schematic (no billing provider) + /// + [JsonIgnore] + public BillingProviderType? ManagedBy { get; set; } + /// /// Filter by plan version ID when used with without_plan_entitlement_for; if not provided, the latest published version is used /// diff --git a/src/SchematicHQ.Client/Features/Requests/ListFeaturesRequest.cs b/src/SchematicHQ.Client/Features/Requests/ListFeaturesRequest.cs index 1290dd35..6e4bf54e 100644 --- a/src/SchematicHQ.Client/Features/Requests/ListFeaturesRequest.cs +++ b/src/SchematicHQ.Client/Features/Requests/ListFeaturesRequest.cs @@ -21,6 +21,12 @@ public record ListFeaturesRequest [JsonIgnore] public IEnumerable Ids { get; set; } = new List(); + /// + /// Filter for features managed by a billing provider, or by Schematic (no billing provider) + /// + [JsonIgnore] + public BillingProviderType? ManagedBy { get; set; } + /// /// Filter by plan version ID when used with without_plan_entitlement_for; if not provided, the latest published version is used /// diff --git a/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs b/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs index 6bc9dc5a..1684fa52 100644 --- a/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs +++ b/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs @@ -35,6 +35,12 @@ public record CountFeaturesParams : IJsonOnDeserialized [JsonPropertyName("limit")] public long? Limit { get; set; } + /// + /// Filter for features managed by a billing provider, or by Schematic (no billing provider) + /// + [JsonPropertyName("managed_by")] + public BillingProviderType? ManagedBy { get; set; } + /// /// Page offset (default 0) /// diff --git a/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs b/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs index 4456a8da..e84b54ff 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs @@ -35,6 +35,12 @@ public record ListFeaturesParams : IJsonOnDeserialized [JsonPropertyName("limit")] public long? Limit { get; set; } + /// + /// Filter for features managed by a billing provider, or by Schematic (no billing provider) + /// + [JsonPropertyName("managed_by")] + public BillingProviderType? ManagedBy { get; set; } + /// /// Page offset (default 0) /// diff --git a/src/SchematicHQ.Client/Integrationsapi/IIntegrationsapiClient.cs b/src/SchematicHQ.Client/Integrationsapi/IIntegrationsapiClient.cs index d366c785..9bb7383a 100644 --- a/src/SchematicHQ.Client/Integrationsapi/IIntegrationsapiClient.cs +++ b/src/SchematicHQ.Client/Integrationsapi/IIntegrationsapiClient.cs @@ -2,9 +2,38 @@ namespace SchematicHQ.Client; public partial interface IIntegrationsapiClient { + WithRawResponseTask RunIntegrationAsync( + string integrationId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + + WithRawResponseTask ListIntegrationsAsync( + ListIntegrationsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + WithRawResponseTask GetIntegrationWebhookUrlAsync( string type, RequestOptions? options = null, CancellationToken cancellationToken = default ); + + WithRawResponseTask StartDataImportAsync( + StartDataImportRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + + WithRawResponseTask LoadSampleDataSetV2Async( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); + + WithRawResponseTask UninstallIntegrationAsync( + string integrationId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ); } diff --git a/src/SchematicHQ.Client/Integrationsapi/IntegrationsapiClient.cs b/src/SchematicHQ.Client/Integrationsapi/IntegrationsapiClient.cs index 4a27a665..5d6043c1 100644 --- a/src/SchematicHQ.Client/Integrationsapi/IntegrationsapiClient.cs +++ b/src/SchematicHQ.Client/Integrationsapi/IntegrationsapiClient.cs @@ -12,6 +12,192 @@ internal IntegrationsapiClient(RawClient client) _client = client; } + private async Task> RunIntegrationAsyncCore( + string integrationId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new SchematicHQ.Client.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Get, + Path = string.Format( + "integration/start/{0}", + ValueConvert.ToPathParameterString(integrationId) + ), + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize(responseBody)!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new SchematicApiException( + "Failed to deserialize response", + response.StatusCode, + responseBody, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError( + JsonUtils.Deserialize(responseBody) + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + private async Task> ListIntegrationsAsyncCore( + ListIntegrationsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 7) + .Add("billing_only", request.BillingOnly) + .Add("exclude_ids", request.ExcludeIds) + .Add("id", request.Id) + .Add("state", request.State) + .Add("type", request.Type) + .Add("limit", request.Limit) + .Add("offset", request.Offset) + .MergeAdditional(options?.AdditionalQueryParameters) + .Build(); + var _headers = await new SchematicHQ.Client.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Get, + Path = "integrations", + QueryString = _queryString, + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize(responseBody)!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new SchematicApiException( + "Failed to deserialize response", + response.StatusCode, + responseBody, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError( + JsonUtils.Deserialize(responseBody) + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + private async Task< WithRawResponse > GetIntegrationWebhookUrlAsyncCore( @@ -104,6 +290,312 @@ private async Task< } } + private async Task> StartDataImportAsyncCore( + StartDataImportRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new SchematicHQ.Client.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Post, + Path = "integrations/start-data-import", + Body = request, + Headers = _headers, + ContentType = "application/json", + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize(responseBody)!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new SchematicApiException( + "Failed to deserialize response", + response.StatusCode, + responseBody, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError( + JsonUtils.Deserialize(responseBody) + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + private async Task> LoadSampleDataSetV2AsyncCore( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new SchematicHQ.Client.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Get, + Path = "integrations/stripe/dataset-sample-v2", + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new SchematicApiException( + "Failed to deserialize response", + response.StatusCode, + responseBody, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError( + JsonUtils.Deserialize(responseBody) + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + private async Task> UninstallIntegrationAsyncCore( + string integrationId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + var _headers = await new SchematicHQ.Client.Core.HeadersBuilder.Builder() + .Add(_client.Options.Headers) + .Add(_client.Options.AdditionalHeaders) + .Add(options?.AdditionalHeaders) + .BuildAsync() + .ConfigureAwait(false); + var response = await _client + .SendRequestAsync( + new JsonRequest + { + Method = HttpMethod.Delete, + Path = string.Format( + "integrations/uninstall/{0}", + ValueConvert.ToPathParameterString(integrationId) + ), + Headers = _headers, + Options = options, + }, + cancellationToken + ) + .ConfigureAwait(false); + if (response.StatusCode is >= 200 and < 400) + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + var responseData = JsonUtils.Deserialize( + responseBody + )!; + return new WithRawResponse() + { + Data = responseData, + RawResponse = new RawResponse() + { + StatusCode = response.Raw.StatusCode, + Url = response.Raw.RequestMessage?.RequestUri ?? new Uri("about:blank"), + Headers = ResponseHeaders.FromHttpResponseMessage(response.Raw), + }, + }; + } + catch (JsonException e) + { + throw new SchematicApiException( + "Failed to deserialize response", + response.StatusCode, + responseBody, + e + ); + } + } + { + var responseBody = await response + .Raw.Content.ReadAsStringAsync(cancellationToken) + .ConfigureAwait(false); + try + { + switch (response.StatusCode) + { + case 400: + throw new BadRequestError(JsonUtils.Deserialize(responseBody)); + case 401: + throw new UnauthorizedError(JsonUtils.Deserialize(responseBody)); + case 403: + throw new ForbiddenError(JsonUtils.Deserialize(responseBody)); + case 404: + throw new NotFoundError(JsonUtils.Deserialize(responseBody)); + case 500: + throw new InternalServerError( + JsonUtils.Deserialize(responseBody) + ); + } + } + catch (JsonException) + { + // unable to map error response, throwing generic error + } + throw new SchematicApiException( + $"Error with status code {response.StatusCode}", + response.StatusCode, + responseBody + ); + } + } + + /// + /// await client.Integrationsapi.RunIntegrationAsync("integration_id"); + /// + public WithRawResponseTask RunIntegrationAsync( + string integrationId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + RunIntegrationAsyncCore(integrationId, options, cancellationToken) + ); + } + + /// + /// await client.Integrationsapi.ListIntegrationsAsync( + /// new ListIntegrationsRequest + /// { + /// BillingOnly = true, + /// ExcludeIds = new List<string>() { "exclude_ids" }, + /// Id = "id", + /// State = IntegrationState.Active, + /// Type = IntegrationType.Clerk, + /// Limit = 1000000, + /// Offset = 1000000, + /// } + /// ); + /// + public WithRawResponseTask ListIntegrationsAsync( + ListIntegrationsRequest request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + ListIntegrationsAsyncCore(request, options, cancellationToken) + ); + } + /// /// await client.Integrationsapi.GetIntegrationWebhookUrlAsync("type"); /// @@ -117,4 +609,47 @@ public WithRawResponseTask GetIntegrationWebho GetIntegrationWebhookUrlAsyncCore(type, options, cancellationToken) ); } + + /// + /// await client.Integrationsapi.StartDataImportAsync( + /// new StartDataImportRequestBody { IntegrationId = "integration_id" } + /// ); + /// + public WithRawResponseTask StartDataImportAsync( + StartDataImportRequestBody request, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + StartDataImportAsyncCore(request, options, cancellationToken) + ); + } + + /// + /// await client.Integrationsapi.LoadSampleDataSetV2Async(); + /// + public WithRawResponseTask LoadSampleDataSetV2Async( + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + LoadSampleDataSetV2AsyncCore(options, cancellationToken) + ); + } + + /// + /// await client.Integrationsapi.UninstallIntegrationAsync("integration_id"); + /// + public WithRawResponseTask UninstallIntegrationAsync( + string integrationId, + RequestOptions? options = null, + CancellationToken cancellationToken = default + ) + { + return new WithRawResponseTask( + UninstallIntegrationAsyncCore(integrationId, options, cancellationToken) + ); + } } diff --git a/src/SchematicHQ.Client/Integrationsapi/Requests/ListIntegrationsRequest.cs b/src/SchematicHQ.Client/Integrationsapi/Requests/ListIntegrationsRequest.cs new file mode 100644 index 00000000..8f130ad4 --- /dev/null +++ b/src/SchematicHQ.Client/Integrationsapi/Requests/ListIntegrationsRequest.cs @@ -0,0 +1,41 @@ +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record ListIntegrationsRequest +{ + [JsonIgnore] + public bool? BillingOnly { get; set; } + + [JsonIgnore] + public IEnumerable ExcludeIds { get; set; } = new List(); + + [JsonIgnore] + public string? Id { get; set; } + + [JsonIgnore] + public IntegrationState? State { get; set; } + + [JsonIgnore] + public IntegrationType? Type { get; set; } + + /// + /// Page limit (default 100) + /// + [JsonIgnore] + public long? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + [JsonIgnore] + public long? Offset { get; set; } + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Integrationsapi/Requests/StartDataImportRequestBody.cs b/src/SchematicHQ.Client/Integrationsapi/Requests/StartDataImportRequestBody.cs new file mode 100644 index 00000000..67485436 --- /dev/null +++ b/src/SchematicHQ.Client/Integrationsapi/Requests/StartDataImportRequestBody.cs @@ -0,0 +1,23 @@ +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record StartDataImportRequestBody +{ + [JsonPropertyName("company_matching_criteria")] + public CompanyMatchingCriteria? CompanyMatchingCriteria { get; set; } + + [JsonPropertyName("company_matching_field")] + public string? CompanyMatchingField { get; set; } + + [JsonPropertyName("integration_id")] + public required string IntegrationId { get; set; } + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Integrationsapi/Types/ListIntegrationsParams.cs b/src/SchematicHQ.Client/Integrationsapi/Types/ListIntegrationsParams.cs new file mode 100644 index 00000000..b47c5d86 --- /dev/null +++ b/src/SchematicHQ.Client/Integrationsapi/Types/ListIntegrationsParams.cs @@ -0,0 +1,55 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +/// +/// Input parameters +/// +[Serializable] +public record ListIntegrationsParams : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("billing_only")] + public bool? BillingOnly { get; set; } + + [JsonPropertyName("exclude_ids")] + public IEnumerable? ExcludeIds { get; set; } + + [JsonPropertyName("id")] + public string? Id { get; set; } + + /// + /// Page limit (default 100) + /// + [JsonPropertyName("limit")] + public long? Limit { get; set; } + + /// + /// Page offset (default 0) + /// + [JsonPropertyName("offset")] + public long? Offset { get; set; } + + [JsonPropertyName("state")] + public IntegrationState? State { get; set; } + + [JsonPropertyName("type")] + public IntegrationType? Type { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Integrationsapi/Types/ListIntegrationsResponse.cs b/src/SchematicHQ.Client/Integrationsapi/Types/ListIntegrationsResponse.cs new file mode 100644 index 00000000..c1c7735d --- /dev/null +++ b/src/SchematicHQ.Client/Integrationsapi/Types/ListIntegrationsResponse.cs @@ -0,0 +1,35 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record ListIntegrationsResponse : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("data")] + public IEnumerable Data { get; set; } = + new List(); + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public required ListIntegrationsParams Params { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Integrationsapi/Types/LoadSampleDataSetV2Response.cs b/src/SchematicHQ.Client/Integrationsapi/Types/LoadSampleDataSetV2Response.cs new file mode 100644 index 00000000..649191d3 --- /dev/null +++ b/src/SchematicHQ.Client/Integrationsapi/Types/LoadSampleDataSetV2Response.cs @@ -0,0 +1,34 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record LoadSampleDataSetV2Response : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("data")] + public required IntegrationsDataSetResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Integrationsapi/Types/RunIntegrationResponse.cs b/src/SchematicHQ.Client/Integrationsapi/Types/RunIntegrationResponse.cs new file mode 100644 index 00000000..3b3c7416 --- /dev/null +++ b/src/SchematicHQ.Client/Integrationsapi/Types/RunIntegrationResponse.cs @@ -0,0 +1,34 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record RunIntegrationResponse : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("data")] + public required IntegrationsResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Integrationsapi/Types/StartDataImportResponse.cs b/src/SchematicHQ.Client/Integrationsapi/Types/StartDataImportResponse.cs new file mode 100644 index 00000000..a5f6a261 --- /dev/null +++ b/src/SchematicHQ.Client/Integrationsapi/Types/StartDataImportResponse.cs @@ -0,0 +1,34 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record StartDataImportResponse : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("data")] + public required IntegrationsResponseData Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Integrationsapi/Types/UninstallIntegrationResponse.cs b/src/SchematicHQ.Client/Integrationsapi/Types/UninstallIntegrationResponse.cs new file mode 100644 index 00000000..431046fa --- /dev/null +++ b/src/SchematicHQ.Client/Integrationsapi/Types/UninstallIntegrationResponse.cs @@ -0,0 +1,34 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record UninstallIntegrationResponse : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("data")] + public required DeleteResponse Data { get; set; } + + /// + /// Input parameters + /// + [JsonPropertyName("params")] + public Dictionary Params { get; set; } = new Dictionary(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Plans/PlansClient.cs b/src/SchematicHQ.Client/Plans/PlansClient.cs index 8b647e88..9a8c479d 100644 --- a/src/SchematicHQ.Client/Plans/PlansClient.cs +++ b/src/SchematicHQ.Client/Plans/PlansClient.cs @@ -398,8 +398,9 @@ private async Task> ListPlansAsyncCore( CancellationToken cancellationToken = default ) { - var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 15) + var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 16) .Add("company_id", request.CompanyId) + .Add("company_scoped_only", request.CompanyScopedOnly) .Add("exclude_company_scoped", request.ExcludeCompanyScoped) .Add("for_fallback_plan", request.ForFallbackPlan) .Add("for_initial_plan", request.ForInitialPlan) @@ -1249,8 +1250,9 @@ private async Task> CountPlansAsyncCore( CancellationToken cancellationToken = default ) { - var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 15) + var _queryString = new SchematicHQ.Client.Core.QueryStringBuilder.Builder(capacity: 16) .Add("company_id", request.CompanyId) + .Add("company_scoped_only", request.CompanyScopedOnly) .Add("exclude_company_scoped", request.ExcludeCompanyScoped) .Add("for_fallback_plan", request.ForFallbackPlan) .Add("for_initial_plan", request.ForInitialPlan) @@ -1656,7 +1658,7 @@ public WithRawResponseTask UpdateCompanyPlansAsync( /// CompanyId = "company_id", /// PlanId = "plan_id", /// Status = CustomPlanBillingStatus.Active, - /// Statuses = [new List<CustomPlanBillingStatus>() { CustomPlanBillingStatus.Active }], + /// Statuses = new List<CustomPlanBillingStatus>() { CustomPlanBillingStatus.Active }, /// Limit = 1000000, /// Offset = 1000000, /// } @@ -1729,12 +1731,13 @@ public WithRawResponseTask CreateCustomPlanAsync( /// new ListPlansRequest /// { /// CompanyId = "company_id", + /// CompanyScopedOnly = true, /// ExcludeCompanyScoped = true, /// ForFallbackPlan = true, /// ForInitialPlan = true, /// ForTrialExpiryPlan = true, /// HasProductId = true, - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// IncludeDraftVersions = true, /// PlanType = PlanType.Plan, /// Q = "q", @@ -1915,12 +1918,13 @@ public WithRawResponseTask CountBilli /// new CountPlansRequest /// { /// CompanyId = "company_id", + /// CompanyScopedOnly = true, /// ExcludeCompanyScoped = true, /// ForFallbackPlan = true, /// ForInitialPlan = true, /// ForTrialExpiryPlan = true, /// HasProductId = true, - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// IncludeDraftVersions = true, /// PlanType = PlanType.Plan, /// Q = "q", diff --git a/src/SchematicHQ.Client/Plans/Requests/CountPlansRequest.cs b/src/SchematicHQ.Client/Plans/Requests/CountPlansRequest.cs index f33f4693..7b04472e 100644 --- a/src/SchematicHQ.Client/Plans/Requests/CountPlansRequest.cs +++ b/src/SchematicHQ.Client/Plans/Requests/CountPlansRequest.cs @@ -9,6 +9,12 @@ public record CountPlansRequest [JsonIgnore] public string? CompanyId { get; set; } + /// + /// Only return plans that are scoped to a company (custom plans assigned to a company) + /// + [JsonIgnore] + public bool? CompanyScopedOnly { get; set; } + /// /// Exclude plans that are scoped to a company (custom plans assigned to a company) /// diff --git a/src/SchematicHQ.Client/Plans/Requests/CreateBillingLinkedPlanRequestBody.cs b/src/SchematicHQ.Client/Plans/Requests/CreateBillingLinkedPlanRequestBody.cs index 281a0403..4573e1dd 100644 --- a/src/SchematicHQ.Client/Plans/Requests/CreateBillingLinkedPlanRequestBody.cs +++ b/src/SchematicHQ.Client/Plans/Requests/CreateBillingLinkedPlanRequestBody.cs @@ -15,6 +15,9 @@ public record CreateBillingLinkedPlanRequestBody [JsonPropertyName("external_resource_id")] public required string ExternalResourceId { get; set; } + [JsonPropertyName("external_resource_version")] + public string? ExternalResourceVersion { get; set; } + [JsonPropertyName("icon")] public PlanIcon? Icon { get; set; } diff --git a/src/SchematicHQ.Client/Plans/Requests/ListPlansRequest.cs b/src/SchematicHQ.Client/Plans/Requests/ListPlansRequest.cs index 7e77fb10..945f50a3 100644 --- a/src/SchematicHQ.Client/Plans/Requests/ListPlansRequest.cs +++ b/src/SchematicHQ.Client/Plans/Requests/ListPlansRequest.cs @@ -9,6 +9,12 @@ public record ListPlansRequest [JsonIgnore] public string? CompanyId { get; set; } + /// + /// Only return plans that are scoped to a company (custom plans assigned to a company) + /// + [JsonIgnore] + public bool? CompanyScopedOnly { get; set; } + /// /// Exclude plans that are scoped to a company (custom plans assigned to a company) /// diff --git a/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs b/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs index 40900e7c..dce10d1a 100644 --- a/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs +++ b/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs @@ -17,6 +17,12 @@ public record CountPlansParams : IJsonOnDeserialized [JsonPropertyName("company_id")] public string? CompanyId { get; set; } + /// + /// Only return plans that are scoped to a company (custom plans assigned to a company) + /// + [JsonPropertyName("company_scoped_only")] + public bool? CompanyScopedOnly { get; set; } + /// /// Exclude plans that are scoped to a company (custom plans assigned to a company) /// diff --git a/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs b/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs index b2123611..41735ab6 100644 --- a/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs +++ b/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs @@ -17,6 +17,12 @@ public record ListPlansParams : IJsonOnDeserialized [JsonPropertyName("company_id")] public string? CompanyId { get; set; } + /// + /// Only return plans that are scoped to a company (custom plans assigned to a company) + /// + [JsonPropertyName("company_scoped_only")] + public bool? CompanyScopedOnly { get; set; } + /// /// Exclude plans that are scoped to a company (custom plans assigned to a company) /// diff --git a/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs b/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs index 74813ed9..aecfcd6f 100644 --- a/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs +++ b/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs @@ -26,6 +26,9 @@ public record ApiKeyCreateResponseData : IJsonOnDeserialized [JsonPropertyName("id")] public required string Id { get; set; } + [JsonPropertyName("integration")] + public ApiKeyIntegrationResponseData? Integration { get; set; } + [JsonPropertyName("last_used_at")] public DateTime? LastUsedAt { get; set; } diff --git a/src/SchematicHQ.Client/Types/ApiKeyIntegrationResponseData.cs b/src/SchematicHQ.Client/Types/ApiKeyIntegrationResponseData.cs new file mode 100644 index 00000000..a0c1a984 --- /dev/null +++ b/src/SchematicHQ.Client/Types/ApiKeyIntegrationResponseData.cs @@ -0,0 +1,34 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record ApiKeyIntegrationResponseData : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("state")] + public required IntegrationState State { get; set; } + + [JsonPropertyName("type")] + public required IntegrationType Type { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs b/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs index cfc64cb6..fb8acb62 100644 --- a/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs +++ b/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs @@ -26,6 +26,9 @@ public record ApiKeyResponseData : IJsonOnDeserialized [JsonPropertyName("id")] public required string Id { get; set; } + [JsonPropertyName("integration")] + public ApiKeyIntegrationResponseData? Integration { get; set; } + [JsonPropertyName("last_used_at")] public DateTime? LastUsedAt { get; set; } diff --git a/src/SchematicHQ.Client/Types/AuditLogListResponseData.cs b/src/SchematicHQ.Client/Types/AuditLogListResponseData.cs index c7ef1b56..4d27cbea 100644 --- a/src/SchematicHQ.Client/Types/AuditLogListResponseData.cs +++ b/src/SchematicHQ.Client/Types/AuditLogListResponseData.cs @@ -14,6 +14,9 @@ public record AuditLogListResponseData : IJsonOnDeserialized [JsonPropertyName("actor_type")] public required ActorType ActorType { get; set; } + [JsonPropertyName("api_key")] + public ApiKeyResponseData? ApiKey { get; set; } + [JsonPropertyName("api_key_id")] public string? ApiKeyId { get; set; } diff --git a/src/SchematicHQ.Client/Types/AuditLogResponseData.cs b/src/SchematicHQ.Client/Types/AuditLogResponseData.cs index 88f2646b..03008f8c 100644 --- a/src/SchematicHQ.Client/Types/AuditLogResponseData.cs +++ b/src/SchematicHQ.Client/Types/AuditLogResponseData.cs @@ -14,6 +14,9 @@ public record AuditLogResponseData : IJsonOnDeserialized [JsonPropertyName("actor_type")] public required ActorType ActorType { get; set; } + [JsonPropertyName("api_key")] + public ApiKeyResponseData? ApiKey { get; set; } + [JsonPropertyName("api_key_id")] public string? ApiKeyId { get; set; } diff --git a/src/SchematicHQ.Client/Types/BillingCreditBundleView.cs b/src/SchematicHQ.Client/Types/BillingCreditBundleView.cs index 6c277949..70e7d802 100644 --- a/src/SchematicHQ.Client/Types/BillingCreditBundleView.cs +++ b/src/SchematicHQ.Client/Types/BillingCreditBundleView.cs @@ -30,7 +30,8 @@ public record BillingCreditBundleView : IJsonOnDeserialized public required string CreditName { get; set; } [JsonPropertyName("currency_prices")] - public IEnumerable? CurrencyPrices { get; set; } + public IEnumerable CurrencyPrices { get; set; } = + new List(); [JsonPropertyName("expiry_type")] public required BillingCreditExpiryType ExpiryType { get; set; } diff --git a/src/SchematicHQ.Client/Types/BillingCreditView.cs b/src/SchematicHQ.Client/Types/BillingCreditView.cs index 40c9c268..5583fed0 100644 --- a/src/SchematicHQ.Client/Types/BillingCreditView.cs +++ b/src/SchematicHQ.Client/Types/BillingCreditView.cs @@ -23,6 +23,10 @@ public record BillingCreditView : IJsonOnDeserialized [JsonPropertyName("created_at")] public required DateTime CreatedAt { get; set; } + [JsonPropertyName("currency_prices")] + public IEnumerable CurrencyPrices { get; set; } = + new List(); + [JsonPropertyName("default_expiry_unit")] public required BillingCreditExpiryUnit DefaultExpiryUnit { get; set; } diff --git a/src/SchematicHQ.Client/Types/BillingPlanCreditGrantResponseData.cs b/src/SchematicHQ.Client/Types/BillingPlanCreditGrantResponseData.cs index af33c474..3945c0d5 100644 --- a/src/SchematicHQ.Client/Types/BillingPlanCreditGrantResponseData.cs +++ b/src/SchematicHQ.Client/Types/BillingPlanCreditGrantResponseData.cs @@ -29,6 +29,9 @@ public record BillingPlanCreditGrantResponseData : IJsonOnDeserialized [JsonPropertyName("auto_topup_expiry_unit_count")] public long? AutoTopupExpiryUnitCount { get; set; } + [JsonPropertyName("auto_topup_self_service")] + public required bool AutoTopupSelfService { get; set; } + [JsonPropertyName("auto_topup_threshold_credits")] public long? AutoTopupThresholdCredits { get; set; } diff --git a/src/SchematicHQ.Client/Types/ChangeSubscriptionInternalRequestBody.cs b/src/SchematicHQ.Client/Types/ChangeSubscriptionInternalRequestBody.cs index 2dc530f5..ef9cc69b 100644 --- a/src/SchematicHQ.Client/Types/ChangeSubscriptionInternalRequestBody.cs +++ b/src/SchematicHQ.Client/Types/ChangeSubscriptionInternalRequestBody.cs @@ -15,6 +15,10 @@ public record ChangeSubscriptionInternalRequestBody : IJsonOnDeserialized public IEnumerable AddOnIds { get; set; } = new List(); + [JsonPropertyName("auto_topup_overrides")] + public IEnumerable AutoTopupOverrides { get; set; } = + new List(); + [JsonPropertyName("company_id")] public required string CompanyId { get; set; } diff --git a/src/SchematicHQ.Client/Types/ChangeSubscriptionRequestBody.cs b/src/SchematicHQ.Client/Types/ChangeSubscriptionRequestBody.cs index f9a40a98..c74086cf 100644 --- a/src/SchematicHQ.Client/Types/ChangeSubscriptionRequestBody.cs +++ b/src/SchematicHQ.Client/Types/ChangeSubscriptionRequestBody.cs @@ -15,6 +15,10 @@ public record ChangeSubscriptionRequestBody : IJsonOnDeserialized public IEnumerable AddOnIds { get; set; } = new List(); + [JsonPropertyName("auto_topup_overrides")] + public IEnumerable AutoTopupOverrides { get; set; } = + new List(); + [JsonPropertyName("coupon_external_id")] public string? CouponExternalId { get; set; } diff --git a/src/SchematicHQ.Client/Types/ClerkIntegrationConfig.cs b/src/SchematicHQ.Client/Types/ClerkIntegrationConfig.cs new file mode 100644 index 00000000..e222eb6a --- /dev/null +++ b/src/SchematicHQ.Client/Types/ClerkIntegrationConfig.cs @@ -0,0 +1,37 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record ClerkIntegrationConfig : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Whether Schematic has received the first webhook event from Clerk after install + /// + [JsonPropertyName("first_events_received")] + public bool? FirstEventsReceived { get; set; } + + /// + /// URL configured on the Clerk webhook endpoint that delivers events to Schematic + /// + [JsonPropertyName("webhook_url")] + public string? WebhookUrl { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/CompanyMatchingCriteria.cs b/src/SchematicHQ.Client/Types/CompanyMatchingCriteria.cs new file mode 100644 index 00000000..40b7ea84 --- /dev/null +++ b/src/SchematicHQ.Client/Types/CompanyMatchingCriteria.cs @@ -0,0 +1,117 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(CompanyMatchingCriteria.CompanyMatchingCriteriaSerializer))] +[Serializable] +public readonly record struct CompanyMatchingCriteria : IStringEnum +{ + public static readonly CompanyMatchingCriteria BillingMetaObject = new( + Values.BillingMetaObject + ); + + public static readonly CompanyMatchingCriteria ManualUpsert = new(Values.ManualUpsert); + + public CompanyMatchingCriteria(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static CompanyMatchingCriteria FromCustom(string value) + { + return new CompanyMatchingCriteria(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(CompanyMatchingCriteria value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(CompanyMatchingCriteria value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(CompanyMatchingCriteria value) => value.Value; + + public static explicit operator CompanyMatchingCriteria(string value) => new(value); + + internal class CompanyMatchingCriteriaSerializer : JsonConverter + { + public override CompanyMatchingCriteria Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new CompanyMatchingCriteria(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + CompanyMatchingCriteria value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override CompanyMatchingCriteria ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new CompanyMatchingCriteria(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + CompanyMatchingCriteria value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string BillingMetaObject = "billing_meta_object"; + + public const string ManualUpsert = "manual_upsert"; + } +} diff --git a/src/SchematicHQ.Client/Types/CompanyPlanCreditGrantView.cs b/src/SchematicHQ.Client/Types/CompanyPlanCreditGrantView.cs new file mode 100644 index 00000000..44c929aa --- /dev/null +++ b/src/SchematicHQ.Client/Types/CompanyPlanCreditGrantView.cs @@ -0,0 +1,136 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record CompanyPlanCreditGrantView : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("billing_credit_auto_topup_amount")] + public long? BillingCreditAutoTopupAmount { get; set; } + + [JsonPropertyName("billing_credit_auto_topup_amount_type")] + public string? BillingCreditAutoTopupAmountType { get; set; } + + [JsonPropertyName("billing_credit_auto_topup_enabled")] + public required bool BillingCreditAutoTopupEnabled { get; set; } + + [JsonPropertyName("billing_credit_auto_topup_expiry_type")] + public BillingCreditExpiryType? BillingCreditAutoTopupExpiryType { get; set; } + + [JsonPropertyName("billing_credit_auto_topup_expiry_unit")] + public BillingCreditExpiryUnit? BillingCreditAutoTopupExpiryUnit { get; set; } + + [JsonPropertyName("billing_credit_auto_topup_expiry_unit_count")] + public long? BillingCreditAutoTopupExpiryUnitCount { get; set; } + + [JsonPropertyName("billing_credit_auto_topup_self_service")] + public required bool BillingCreditAutoTopupSelfService { get; set; } + + [JsonPropertyName("billing_credit_auto_topup_threshold_credits")] + public long? BillingCreditAutoTopupThresholdCredits { get; set; } + + [JsonPropertyName("billing_credit_auto_topup_threshold_percent")] + public long? BillingCreditAutoTopupThresholdPercent { get; set; } + + [JsonPropertyName("company_auto_topup_amount")] + public long? CompanyAutoTopupAmount { get; set; } + + [JsonPropertyName("company_auto_topup_enabled")] + public bool? CompanyAutoTopupEnabled { get; set; } + + [JsonPropertyName("company_auto_topup_threshold_credits")] + public long? CompanyAutoTopupThresholdCredits { get; set; } + + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("credit")] + public BillingCreditView? Credit { get; set; } + + [JsonPropertyName("credit_amount")] + public required long CreditAmount { get; set; } + + /// + /// Deprecated field, will be removed in the future. Use Credit.Description instead. + /// + [JsonPropertyName("credit_description")] + public required string CreditDescription { get; set; } + + /// + /// Deprecated field, will be removed in the future. Use Credit.Icon instead. + /// + [JsonPropertyName("credit_icon")] + public string? CreditIcon { get; set; } + + [JsonPropertyName("credit_id")] + public required string CreditId { get; set; } + + /// + /// Deprecated field, will be removed in the future. Use Credit.Name instead. + /// + [JsonPropertyName("credit_name")] + public required string CreditName { get; set; } + + [JsonPropertyName("expiry_type")] + public BillingCreditExpiryType? ExpiryType { get; set; } + + [JsonPropertyName("expiry_unit")] + public BillingCreditExpiryUnit? ExpiryUnit { get; set; } + + [JsonPropertyName("expiry_unit_count")] + public long? ExpiryUnitCount { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("plan")] + public GenericPreviewObject? Plan { get; set; } + + [JsonPropertyName("plan_id")] + public required string PlanId { get; set; } + + [JsonPropertyName("plan_version_id")] + public string? PlanVersionId { get; set; } + + /// + /// Deprecated field, will be removed in the future. Use Credit.PluralName instead. + /// + [JsonPropertyName("plural_name")] + public string? PluralName { get; set; } + + [JsonPropertyName("reset_cadence")] + public BillingPlanCreditGrantResetCadence? ResetCadence { get; set; } + + [JsonPropertyName("reset_start")] + public BillingPlanCreditGrantResetStart? ResetStart { get; set; } + + [JsonPropertyName("reset_type")] + public required BillingPlanCreditGrantResetType ResetType { get; set; } + + /// + /// Deprecated field, will be removed in the future. Use Credit.SingularName instead. + /// + [JsonPropertyName("singular_name")] + public string? SingularName { get; set; } + + [JsonPropertyName("updated_at")] + public required DateTime UpdatedAt { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/CompanyPlanWithBillingSubView.cs b/src/SchematicHQ.Client/Types/CompanyPlanWithBillingSubView.cs index 0bb6a019..f90c94a0 100644 --- a/src/SchematicHQ.Client/Types/CompanyPlanWithBillingSubView.cs +++ b/src/SchematicHQ.Client/Types/CompanyPlanWithBillingSubView.cs @@ -30,8 +30,8 @@ public record CompanyPlanWithBillingSubView : IJsonOnDeserialized public string? ImageUrl { get; set; } [JsonPropertyName("included_credit_grants")] - public IEnumerable IncludedCreditGrants { get; set; } = - new List(); + public IEnumerable IncludedCreditGrants { get; set; } = + new List(); [JsonPropertyName("name")] public required string Name { get; set; } diff --git a/src/SchematicHQ.Client/Types/CreateBillingPlanCreditGrantRequestBody.cs b/src/SchematicHQ.Client/Types/CreateBillingPlanCreditGrantRequestBody.cs index d0bf6376..96bd8b8a 100644 --- a/src/SchematicHQ.Client/Types/CreateBillingPlanCreditGrantRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateBillingPlanCreditGrantRequestBody.cs @@ -32,6 +32,9 @@ public record CreateBillingPlanCreditGrantRequestBody : IJsonOnDeserialized [JsonPropertyName("auto_topup_expiry_unit_count")] public long? AutoTopupExpiryUnitCount { get; set; } + [JsonPropertyName("auto_topup_self_service")] + public bool? AutoTopupSelfService { get; set; } + [JsonPropertyName("auto_topup_threshold_credits")] public long? AutoTopupThresholdCredits { get; set; } diff --git a/src/SchematicHQ.Client/Types/CreateEventRequestBody.cs b/src/SchematicHQ.Client/Types/CreateEventRequestBody.cs index ec744106..d186dad7 100644 --- a/src/SchematicHQ.Client/Types/CreateEventRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateEventRequestBody.cs @@ -21,6 +21,12 @@ public record CreateEventRequestBody : IJsonOnDeserialized [JsonPropertyName("event_type")] public required EventType EventType { get; set; } + /// + /// Optional client-supplied key. Duplicate events with the same key (scoped to the environment) are dropped for 24h. + /// + [JsonPropertyName("idempotency_key")] + public string? IdempotencyKey { get; set; } + /// /// Optionally provide a timestamp at which the event was sent to Schematic /// diff --git a/src/SchematicHQ.Client/Types/CreditCurrencyPrice.cs b/src/SchematicHQ.Client/Types/CreditCurrencyPrice.cs new file mode 100644 index 00000000..2250e122 --- /dev/null +++ b/src/SchematicHQ.Client/Types/CreditCurrencyPrice.cs @@ -0,0 +1,31 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record CreditCurrencyPrice : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("currency")] + public required string Currency { get; set; } + + [JsonPropertyName("price")] + public BillingPriceView? Price { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/DataEventPayload.cs b/src/SchematicHQ.Client/Types/DataEventPayload.cs index 8bb54649..11a8ffdf 100644 --- a/src/SchematicHQ.Client/Types/DataEventPayload.cs +++ b/src/SchematicHQ.Client/Types/DataEventPayload.cs @@ -17,6 +17,9 @@ public record DataEventPayload : IJsonOnDeserialized [JsonPropertyName("body")] public Dictionary? Body { get; set; } + [JsonPropertyName("idempotency_key")] + public string? IdempotencyKey { get; set; } + [JsonPropertyName("sent_at")] public DateTime? SentAt { get; set; } diff --git a/src/SchematicHQ.Client/Types/DuplicatePlanEntitlementsResponseResponseData.cs b/src/SchematicHQ.Client/Types/DuplicatePlanEntitlementsResponseResponseData.cs index 2e79ca91..0a017152 100644 --- a/src/SchematicHQ.Client/Types/DuplicatePlanEntitlementsResponseResponseData.cs +++ b/src/SchematicHQ.Client/Types/DuplicatePlanEntitlementsResponseResponseData.cs @@ -15,6 +15,10 @@ public record DuplicatePlanEntitlementsResponseResponseData : IJsonOnDeserialize public IEnumerable Data { get; set; } = new List(); + [JsonPropertyName("issues")] + public IEnumerable Issues { get; set; } = + new List(); + [JsonPropertyName("skipped")] public IEnumerable Skipped { get; set; } = new List(); diff --git a/src/SchematicHQ.Client/Types/EventDetailResponseData.cs b/src/SchematicHQ.Client/Types/EventDetailResponseData.cs index c9b22c61..7f17d910 100644 --- a/src/SchematicHQ.Client/Types/EventDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/EventDetailResponseData.cs @@ -14,6 +14,9 @@ public record EventDetailResponseData : IJsonOnDeserialized [JsonPropertyName("api_key")] public string? ApiKey { get; set; } + [JsonPropertyName("api_key_view")] + public ApiKeyResponseData? ApiKeyView { get; set; } + [JsonPropertyName("body")] public Dictionary Body { get; set; } = new Dictionary(); @@ -47,6 +50,9 @@ public record EventDetailResponseData : IJsonOnDeserialized [JsonPropertyName("id")] public required string Id { get; set; } + [JsonPropertyName("idempotency_key")] + public string? IdempotencyKey { get; set; } + [JsonPropertyName("loaded_at")] public DateTime? LoadedAt { get; set; } diff --git a/src/SchematicHQ.Client/Types/EventResponseData.cs b/src/SchematicHQ.Client/Types/EventResponseData.cs index 3f74eb34..10cc8004 100644 --- a/src/SchematicHQ.Client/Types/EventResponseData.cs +++ b/src/SchematicHQ.Client/Types/EventResponseData.cs @@ -41,6 +41,9 @@ public record EventResponseData : IJsonOnDeserialized [JsonPropertyName("id")] public required string Id { get; set; } + [JsonPropertyName("idempotency_key")] + public string? IdempotencyKey { get; set; } + [JsonPropertyName("loaded_at")] public DateTime? LoadedAt { get; set; } diff --git a/src/SchematicHQ.Client/Types/IntegrationCapabilities.cs b/src/SchematicHQ.Client/Types/IntegrationCapabilities.cs new file mode 100644 index 00000000..4f1553b3 --- /dev/null +++ b/src/SchematicHQ.Client/Types/IntegrationCapabilities.cs @@ -0,0 +1,34 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record IntegrationCapabilities : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("author_plans")] + public required bool AuthorPlans { get; set; } + + [JsonPropertyName("checkout")] + public required bool Checkout { get; set; } + + [JsonPropertyName("edit_billing")] + public required bool EditBilling { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/IntegrationConfig.cs b/src/SchematicHQ.Client/Types/IntegrationConfig.cs new file mode 100644 index 00000000..91a2d86b --- /dev/null +++ b/src/SchematicHQ.Client/Types/IntegrationConfig.cs @@ -0,0 +1,357 @@ +// ReSharper disable NullableWarningSuppressionIsUsed +// ReSharper disable InconsistentNaming + +using global::System.Text.Json; +using global::System.Text.Json.Nodes; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(IntegrationConfig.JsonConverter))] +[Serializable] +public record IntegrationConfig +{ + internal IntegrationConfig(string type, object? value) + { + Type = type; + Value = value; + } + + /// + /// Create an instance of IntegrationConfig with . + /// + public IntegrationConfig(IntegrationConfig.Clerk value) + { + Type = "clerk"; + Value = value.Value; + } + + /// + /// Create an instance of IntegrationConfig with . + /// + public IntegrationConfig(IntegrationConfig.Orb value) + { + Type = "orb"; + Value = value.Value; + } + + /// + /// Create an instance of IntegrationConfig with . + /// + public IntegrationConfig(IntegrationConfig.Stripe value) + { + Type = "stripe"; + Value = value.Value; + } + + /// + /// Discriminant value + /// + [JsonPropertyName("type")] + public string Type { get; internal set; } + + /// + /// Discriminated union value + /// + public object? Value { get; internal set; } + + /// + /// Returns true if is "clerk" + /// + public bool IsClerk => Type == "clerk"; + + /// + /// Returns true if is "orb" + /// + public bool IsOrb => Type == "orb"; + + /// + /// Returns true if is "stripe" + /// + public bool IsStripe => Type == "stripe"; + + /// + /// Returns the value as a if is 'clerk', otherwise throws an exception. + /// + /// Thrown when is not 'clerk'. + public SchematicHQ.Client.ClerkIntegrationConfig AsClerk() => + IsClerk + ? (SchematicHQ.Client.ClerkIntegrationConfig)Value! + : throw new global::System.Exception("IntegrationConfig.Type is not 'clerk'"); + + /// + /// Returns the value as a if is 'orb', otherwise throws an exception. + /// + /// Thrown when is not 'orb'. + public SchematicHQ.Client.OrbIntegrationConfig AsOrb() => + IsOrb + ? (SchematicHQ.Client.OrbIntegrationConfig)Value! + : throw new global::System.Exception("IntegrationConfig.Type is not 'orb'"); + + /// + /// Returns the value as a if is 'stripe', otherwise throws an exception. + /// + /// Thrown when is not 'stripe'. + public SchematicHQ.Client.StripeIntegrationConfig AsStripe() => + IsStripe + ? (SchematicHQ.Client.StripeIntegrationConfig)Value! + : throw new global::System.Exception("IntegrationConfig.Type is not 'stripe'"); + + public T Match( + Func onClerk, + Func onOrb, + Func onStripe, + Func onUnknown_ + ) + { + return Type switch + { + "clerk" => onClerk(AsClerk()), + "orb" => onOrb(AsOrb()), + "stripe" => onStripe(AsStripe()), + _ => onUnknown_(Type, Value), + }; + } + + public void Visit( + Action onClerk, + Action onOrb, + Action onStripe, + Action onUnknown_ + ) + { + switch (Type) + { + case "clerk": + onClerk(AsClerk()); + break; + case "orb": + onOrb(AsOrb()); + break; + case "stripe": + onStripe(AsStripe()); + break; + default: + onUnknown_(Type, Value); + break; + } + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryAsClerk(out SchematicHQ.Client.ClerkIntegrationConfig? value) + { + if (Type == "clerk") + { + value = (SchematicHQ.Client.ClerkIntegrationConfig)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryAsOrb(out SchematicHQ.Client.OrbIntegrationConfig? value) + { + if (Type == "orb") + { + value = (SchematicHQ.Client.OrbIntegrationConfig)Value!; + return true; + } + value = null; + return false; + } + + /// + /// Attempts to cast the value to a and returns true if successful. + /// + public bool TryAsStripe(out SchematicHQ.Client.StripeIntegrationConfig? value) + { + if (Type == "stripe") + { + value = (SchematicHQ.Client.StripeIntegrationConfig)Value!; + return true; + } + value = null; + return false; + } + + public override string ToString() => JsonUtils.Serialize(this); + + public static implicit operator IntegrationConfig(IntegrationConfig.Clerk value) => new(value); + + public static implicit operator IntegrationConfig(IntegrationConfig.Orb value) => new(value); + + public static implicit operator IntegrationConfig(IntegrationConfig.Stripe value) => new(value); + + [Serializable] + internal sealed class JsonConverter : JsonConverter + { + public override bool CanConvert(global::System.Type typeToConvert) => + typeof(IntegrationConfig).IsAssignableFrom(typeToConvert); + + public override IntegrationConfig Read( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + var json = JsonElement.ParseValue(ref reader); + if (!json.TryGetProperty("type", out var discriminatorElement)) + { + throw new JsonException("Missing discriminator property 'type'"); + } + if (discriminatorElement.ValueKind != JsonValueKind.String) + { + if (discriminatorElement.ValueKind == JsonValueKind.Null) + { + throw new JsonException("Discriminator property 'type' is null"); + } + + throw new JsonException( + $"Discriminator property 'type' is not a string, instead is {discriminatorElement.ToString()}" + ); + } + + var discriminator = + discriminatorElement.GetString() + ?? throw new JsonException("Discriminator property 'type' is null"); + + // Strip the discriminant property to prevent it from leaking into AdditionalProperties + var jsonObject = System.Text.Json.Nodes.JsonObject.Create(json); + jsonObject?.Remove("type"); + var jsonWithoutDiscriminator = + jsonObject != null ? JsonSerializer.SerializeToElement(jsonObject, options) : json; + + var value = discriminator switch + { + "clerk" => + jsonWithoutDiscriminator.Deserialize( + options + ) + ?? throw new JsonException( + "Failed to deserialize SchematicHQ.Client.ClerkIntegrationConfig" + ), + "orb" => + jsonWithoutDiscriminator.Deserialize( + options + ) + ?? throw new JsonException( + "Failed to deserialize SchematicHQ.Client.OrbIntegrationConfig" + ), + "stripe" => + jsonWithoutDiscriminator.Deserialize( + options + ) + ?? throw new JsonException( + "Failed to deserialize SchematicHQ.Client.StripeIntegrationConfig" + ), + _ => json.Deserialize(options), + }; + return new IntegrationConfig(discriminator, value); + } + + public override void Write( + Utf8JsonWriter writer, + IntegrationConfig value, + JsonSerializerOptions options + ) + { + JsonNode json = + value.Type switch + { + "clerk" => JsonSerializer.SerializeToNode(value.Value, options), + "orb" => JsonSerializer.SerializeToNode(value.Value, options), + "stripe" => JsonSerializer.SerializeToNode(value.Value, options), + _ => JsonSerializer.SerializeToNode(value.Value, options), + } ?? new JsonObject(); + json["type"] = value.Type; + json.WriteTo(writer, options); + } + + public override IntegrationConfig ReadAsPropertyName( + ref Utf8JsonReader reader, + global::System.Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new JsonException("The JSON property name could not be read as a string."); + return new IntegrationConfig(stringValue, stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + IntegrationConfig value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Type); + } + } + + /// + /// Discriminated union type for clerk + /// + [Serializable] + public struct Clerk + { + public Clerk(SchematicHQ.Client.ClerkIntegrationConfig value) + { + Value = value; + } + + internal SchematicHQ.Client.ClerkIntegrationConfig Value { get; set; } + + public override string ToString() => Value.ToString() ?? "null"; + + public static implicit operator IntegrationConfig.Clerk( + SchematicHQ.Client.ClerkIntegrationConfig value + ) => new(value); + } + + /// + /// Discriminated union type for orb + /// + [Serializable] + public struct Orb + { + public Orb(SchematicHQ.Client.OrbIntegrationConfig value) + { + Value = value; + } + + internal SchematicHQ.Client.OrbIntegrationConfig Value { get; set; } + + public override string ToString() => Value.ToString() ?? "null"; + + public static implicit operator IntegrationConfig.Orb( + SchematicHQ.Client.OrbIntegrationConfig value + ) => new(value); + } + + /// + /// Discriminated union type for stripe + /// + [Serializable] + public struct Stripe + { + public Stripe(SchematicHQ.Client.StripeIntegrationConfig value) + { + Value = value; + } + + internal SchematicHQ.Client.StripeIntegrationConfig Value { get; set; } + + public override string ToString() => Value.ToString() ?? "null"; + + public static implicit operator IntegrationConfig.Stripe( + SchematicHQ.Client.StripeIntegrationConfig value + ) => new(value); + } +} diff --git a/src/SchematicHQ.Client/Types/IntegrationResponseData.cs b/src/SchematicHQ.Client/Types/IntegrationResponseData.cs new file mode 100644 index 00000000..97dd2c6c --- /dev/null +++ b/src/SchematicHQ.Client/Types/IntegrationResponseData.cs @@ -0,0 +1,40 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record IntegrationResponseData : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("state")] + public required IntegrationState State { get; set; } + + [JsonPropertyName("type")] + public required IntegrationType Type { get; set; } + + [JsonPropertyName("updated_at")] + public required DateTime UpdatedAt { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/IntegrationState.cs b/src/SchematicHQ.Client/Types/IntegrationState.cs new file mode 100644 index 00000000..e377329c --- /dev/null +++ b/src/SchematicHQ.Client/Types/IntegrationState.cs @@ -0,0 +1,119 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(IntegrationState.IntegrationStateSerializer))] +[Serializable] +public readonly record struct IntegrationState : IStringEnum +{ + public static readonly IntegrationState Active = new(Values.Active); + + public static readonly IntegrationState Created = new(Values.Created); + + public static readonly IntegrationState Pending = new(Values.Pending); + + public IntegrationState(string value) + { + Value = value; + } + + /// + /// The string value of the enum. + /// + public string Value { get; } + + /// + /// Create a string enum with the given value. + /// + public static IntegrationState FromCustom(string value) + { + return new IntegrationState(value); + } + + public bool Equals(string? other) + { + return Value.Equals(other); + } + + /// + /// Returns the string value of the enum. + /// + public override string ToString() + { + return Value; + } + + public static bool operator ==(IntegrationState value1, string value2) => + value1.Value.Equals(value2); + + public static bool operator !=(IntegrationState value1, string value2) => + !value1.Value.Equals(value2); + + public static explicit operator string(IntegrationState value) => value.Value; + + public static explicit operator IntegrationState(string value) => new(value); + + internal class IntegrationStateSerializer : JsonConverter + { + public override IntegrationState Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON value could not be read as a string." + ); + return new IntegrationState(stringValue); + } + + public override void Write( + Utf8JsonWriter writer, + IntegrationState value, + JsonSerializerOptions options + ) + { + writer.WriteStringValue(value.Value); + } + + public override IntegrationState ReadAsPropertyName( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + var stringValue = + reader.GetString() + ?? throw new global::System.Exception( + "The JSON property name could not be read as a string." + ); + return new IntegrationState(stringValue); + } + + public override void WriteAsPropertyName( + Utf8JsonWriter writer, + IntegrationState value, + JsonSerializerOptions options + ) + { + writer.WritePropertyName(value.Value); + } + } + + /// + /// Constant strings for enum values + /// + [Serializable] + public static class Values + { + public const string Active = "active"; + + public const string Created = "created"; + + public const string Pending = "pending"; + } +} diff --git a/src/SchematicHQ.Client/Types/IntegrationsDataSetResponseData.cs b/src/SchematicHQ.Client/Types/IntegrationsDataSetResponseData.cs new file mode 100644 index 00000000..2f11fd74 --- /dev/null +++ b/src/SchematicHQ.Client/Types/IntegrationsDataSetResponseData.cs @@ -0,0 +1,28 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record IntegrationsDataSetResponseData : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("keys")] + public IEnumerable Keys { get; set; } = new List(); + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/IntegrationsListResponseData.cs b/src/SchematicHQ.Client/Types/IntegrationsListResponseData.cs new file mode 100644 index 00000000..a31094f1 --- /dev/null +++ b/src/SchematicHQ.Client/Types/IntegrationsListResponseData.cs @@ -0,0 +1,46 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record IntegrationsListResponseData : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("capabilities")] + public required IntegrationCapabilities Capabilities { get; set; } + + [JsonPropertyName("config")] + public IntegrationConfig? Config { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("is_app_install")] + public required bool IsAppInstall { get; set; } + + [JsonPropertyName("is_connect_install")] + public required bool IsConnectInstall { get; set; } + + [JsonPropertyName("state")] + public required IntegrationState State { get; set; } + + [JsonPropertyName("type")] + public required IntegrationType Type { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/IntegrationsResponseData.cs b/src/SchematicHQ.Client/Types/IntegrationsResponseData.cs new file mode 100644 index 00000000..bdaa35b2 --- /dev/null +++ b/src/SchematicHQ.Client/Types/IntegrationsResponseData.cs @@ -0,0 +1,40 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record IntegrationsResponseData : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("created_at")] + public required DateTime CreatedAt { get; set; } + + [JsonPropertyName("id")] + public required string Id { get; set; } + + [JsonPropertyName("state")] + public required IntegrationState State { get; set; } + + [JsonPropertyName("type")] + public required IntegrationType Type { get; set; } + + [JsonPropertyName("updated_at")] + public required DateTime UpdatedAt { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/OrbIntegrationConfig.cs b/src/SchematicHQ.Client/Types/OrbIntegrationConfig.cs new file mode 100644 index 00000000..0e4c2c31 --- /dev/null +++ b/src/SchematicHQ.Client/Types/OrbIntegrationConfig.cs @@ -0,0 +1,31 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record OrbIntegrationConfig : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Schematic company key used to store Orb's external_customer_id; when unset, defaults to orb_external_customer_id + /// + [JsonPropertyName("external_customer_id_key")] + public string? ExternalCustomerIdKey { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/PlanCreditGrantView.cs b/src/SchematicHQ.Client/Types/PlanCreditGrantView.cs index bf55634a..e6f36c64 100644 --- a/src/SchematicHQ.Client/Types/PlanCreditGrantView.cs +++ b/src/SchematicHQ.Client/Types/PlanCreditGrantView.cs @@ -29,6 +29,9 @@ public record PlanCreditGrantView : IJsonOnDeserialized [JsonPropertyName("billing_credit_auto_topup_expiry_unit_count")] public long? BillingCreditAutoTopupExpiryUnitCount { get; set; } + [JsonPropertyName("billing_credit_auto_topup_self_service")] + public required bool BillingCreditAutoTopupSelfService { get; set; } + [JsonPropertyName("billing_credit_auto_topup_threshold_credits")] public long? BillingCreditAutoTopupThresholdCredits { get; set; } diff --git a/src/SchematicHQ.Client/Types/RulesEngineSchemaVersion.cs b/src/SchematicHQ.Client/Types/RulesEngineSchemaVersion.cs index 4d4eace8..3d1a8427 100644 --- a/src/SchematicHQ.Client/Types/RulesEngineSchemaVersion.cs +++ b/src/SchematicHQ.Client/Types/RulesEngineSchemaVersion.cs @@ -8,7 +8,7 @@ namespace SchematicHQ.Client; [Serializable] public readonly record struct RulesEngineSchemaVersion : IStringEnum { - public static readonly RulesEngineSchemaVersion Vf05Bf5Da = new(Values.Vf05Bf5Da); + public static readonly RulesEngineSchemaVersion V97288F60 = new(Values.V97288F60); public static readonly RulesEngineSchemaVersion PlaceholderForFernCompatibility = new( Values.PlaceholderForFernCompatibility @@ -110,7 +110,7 @@ JsonSerializerOptions options [Serializable] public static class Values { - public const string Vf05Bf5Da = "vf05bf5da"; + public const string V97288F60 = "v97288f60"; public const string PlaceholderForFernCompatibility = "placeholder-for-fern-compatibility"; } diff --git a/src/SchematicHQ.Client/Types/StripeIntegrationConfig.cs b/src/SchematicHQ.Client/Types/StripeIntegrationConfig.cs new file mode 100644 index 00000000..9161137c --- /dev/null +++ b/src/SchematicHQ.Client/Types/StripeIntegrationConfig.cs @@ -0,0 +1,67 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record StripeIntegrationConfig : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + /// + /// Connected Stripe account ID (acct_*) + /// + [JsonPropertyName("account_id")] + public string? AccountId { get; set; } + + /// + /// Display name of the connected Stripe account + /// + [JsonPropertyName("account_name")] + public string? AccountName { get; set; } + + /// + /// When importing Stripe customers, only update existing companies, do not create new companies + /// + [JsonPropertyName("company_update_only")] + public bool? CompanyUpdateOnly { get; set; } + + /// + /// Whether the integration is connected to a Stripe sandbox account + /// + [JsonPropertyName("is_sandbox")] + public required bool IsSandbox { get; set; } + + /// + /// Whether the integration is connected to a live Stripe account + /// + [JsonPropertyName("live_mode")] + public required bool LiveMode { get; set; } + + /// + /// Onboarding URL returned during the v2 (Connect) install flow before activation + /// + [JsonPropertyName("onboard_url")] + public string? OnboardUrl { get; set; } + + /// + /// Stripe integration config version (1 = legacy API key install, 2 = Connect/App install) + /// + [JsonPropertyName("version")] + public required int Version { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/UpdateAutoTopupOverrideRequestBody.cs b/src/SchematicHQ.Client/Types/UpdateAutoTopupOverrideRequestBody.cs new file mode 100644 index 00000000..1468e05e --- /dev/null +++ b/src/SchematicHQ.Client/Types/UpdateAutoTopupOverrideRequestBody.cs @@ -0,0 +1,37 @@ +using global::System.Text.Json; +using global::System.Text.Json.Serialization; +using SchematicHQ.Client.Core; + +namespace SchematicHQ.Client; + +[Serializable] +public record UpdateAutoTopupOverrideRequestBody : IJsonOnDeserialized +{ + [JsonExtensionData] + private readonly IDictionary _extensionData = + new Dictionary(); + + [JsonPropertyName("auto_topup_amount")] + public long? AutoTopupAmount { get; set; } + + [JsonPropertyName("auto_topup_enabled")] + public bool? AutoTopupEnabled { get; set; } + + [JsonPropertyName("auto_topup_threshold_credits")] + public long? AutoTopupThresholdCredits { get; set; } + + [JsonPropertyName("plan_credit_grant_id")] + public required string PlanCreditGrantId { get; set; } + + [JsonIgnore] + public ReadOnlyAdditionalProperties AdditionalProperties { get; private set; } = new(); + + void IJsonOnDeserialized.OnDeserialized() => + AdditionalProperties.CopyFromExtensionData(_extensionData); + + /// + public override string ToString() + { + return JsonUtils.Serialize(this); + } +} diff --git a/src/SchematicHQ.Client/Types/UpdateBillingPlanCreditGrantRequestBody.cs b/src/SchematicHQ.Client/Types/UpdateBillingPlanCreditGrantRequestBody.cs index 17a4cad5..1fc4bd01 100644 --- a/src/SchematicHQ.Client/Types/UpdateBillingPlanCreditGrantRequestBody.cs +++ b/src/SchematicHQ.Client/Types/UpdateBillingPlanCreditGrantRequestBody.cs @@ -32,6 +32,9 @@ public record UpdateBillingPlanCreditGrantRequestBody : IJsonOnDeserialized [JsonPropertyName("auto_topup_expiry_unit_count")] public long? AutoTopupExpiryUnitCount { get; set; } + [JsonPropertyName("auto_topup_self_service")] + public bool? AutoTopupSelfService { get; set; } + [JsonPropertyName("auto_topup_threshold_credits")] public long? AutoTopupThresholdCredits { get; set; } diff --git a/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs b/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs index ec2130b8..b0651858 100644 --- a/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs +++ b/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs @@ -844,7 +844,7 @@ private async Task> CountWebhooksAsyncCor /// await client.Webhooks.ListWebhookEventsAsync( /// new ListWebhookEventsRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Q = "q", /// WebhookId = "webhook_id", /// Limit = 1000000, @@ -881,7 +881,7 @@ public WithRawResponseTask GetWebhookEventAsync( /// await client.Webhooks.CountWebhookEventsAsync( /// new CountWebhookEventsRequest /// { - /// Ids = [new List<string>() { "ids" }], + /// Ids = new List<string>() { "ids" }, /// Q = "q", /// WebhookId = "webhook_id", /// Limit = 1000000,