diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23c152b..ac82e8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,22 +24,6 @@ jobs: - name: Build Release run: dotnet build src -c Release /p:ContinuousIntegrationBuild=true - test: - runs-on: ubuntu-latest - - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - uses: actions/checkout@master - - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 8.x - - - name: Build Release - run: dotnet test src publish: needs: [compile] diff --git a/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.csproj b/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.csproj index bfe53df..4241ce0 100644 --- a/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.csproj +++ b/src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.csproj @@ -1,7 +1,7 @@ - net8.0 + net7.0 enable enable @@ -10,17 +10,15 @@ - - - - - - - + + + + + - + \ No newline at end of file diff --git a/src/SchematicHQ.Client.Test/TestClient.cs b/src/SchematicHQ.Client.Test/TestClient.cs index 2ca2fed..fb88bfc 100644 --- a/src/SchematicHQ.Client.Test/TestClient.cs +++ b/src/SchematicHQ.Client.Test/TestClient.cs @@ -153,7 +153,7 @@ public async Task Identify_EnqueuesEventNonBlocking() var company = new EventBodyIdentifyCompany { Name = "test_company" }; // Act - var identifyTask = Task.Run(() => _schematic.Identify(keys, company, "John Doe", new Dictionary>>())); + var identifyTask = Task.Run(() => _schematic.Identify(keys, company, "John Doe", new Dictionary())); // Assert await identifyTask; // Ensure the task completes @@ -170,7 +170,7 @@ public async Task Track_EnqueuesEventNonBlocking() var user = new Dictionary { { "user_id", "12345" } }; // Act - var trackTask = Task.Run(() => _schematic.Track("event_name", company, user, new Dictionary>>())); + var trackTask = Task.Run(() => _schematic.Track("event_name", company, user, new Dictionary())); // Assert await trackTask; // Ensure the task completes @@ -223,7 +223,7 @@ public void Identify_OfflineMode() // Act for (int i = 0; i < 10; i++) { - _schematic.Identify(keys, company, "John Doe", new Dictionary>>()); + _schematic.Identify(keys, company, "John Doe", new Dictionary()); } // Assert @@ -247,4 +247,4 @@ public async Task CheckFlag_OfflineModeReturnsDefault() Assert.That(result, Is.True); } } -} \ No newline at end of file +} diff --git a/src/SchematicHQ.Client.sln b/src/SchematicHQ.Client.sln index 432cb43..0c93b5d 100644 --- a/src/SchematicHQ.Client.sln +++ b/src/SchematicHQ.Client.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client", "SchematicHQ.Client\SchematicHQ.Client.csproj", "{41730C42-98CA-44C9-97CA-B06F136101CD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client", "SchematicHQ.Client\SchematicHQ.Client.csproj", "{EBD4CF4C-350D-46AA-A99D-7304014BAF37}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client.Test", "SchematicHQ.Client.Test\SchematicHQ.Client.Test.csproj", "{439AE051-B290-400E-A575-103ACCA138E9}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client.Test", "SchematicHQ.Client.Test\SchematicHQ.Client.Test.csproj", "{8412F3CF-8C8C-4A87-A39E-56894D4DAB79}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -16,13 +16,13 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {41730C42-98CA-44C9-97CA-B06F136101CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {41730C42-98CA-44C9-97CA-B06F136101CD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {41730C42-98CA-44C9-97CA-B06F136101CD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {41730C42-98CA-44C9-97CA-B06F136101CD}.Release|Any CPU.Build.0 = Release|Any CPU - {439AE051-B290-400E-A575-103ACCA138E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {439AE051-B290-400E-A575-103ACCA138E9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {439AE051-B290-400E-A575-103ACCA138E9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {439AE051-B290-400E-A575-103ACCA138E9}.Release|Any CPU.Build.0 = Release|Any CPU + {EBD4CF4C-350D-46AA-A99D-7304014BAF37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EBD4CF4C-350D-46AA-A99D-7304014BAF37}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EBD4CF4C-350D-46AA-A99D-7304014BAF37}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EBD4CF4C-350D-46AA-A99D-7304014BAF37}.Release|Any CPU.Build.0 = Release|Any CPU + {8412F3CF-8C8C-4A87-A39E-56894D4DAB79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8412F3CF-8C8C-4A87-A39E-56894D4DAB79}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8412F3CF-8C8C-4A87-A39E-56894D4DAB79}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8412F3CF-8C8C-4A87-A39E-56894D4DAB79}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/SchematicHQ.Client/Accounts/AccountsClient.cs b/src/SchematicHQ.Client/Accounts/AccountsClient.cs index 9bdb911..00f323d 100644 --- a/src/SchematicHQ.Client/Accounts/AccountsClient.cs +++ b/src/SchematicHQ.Client/Accounts/AccountsClient.cs @@ -26,17 +26,17 @@ public async Task ListApiKeysAsync(ListApiKeysRequest reque } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/api-keys", + Path = "api-keys", Query = _query } ); @@ -51,10 +51,10 @@ public async Task ListApiKeysAsync(ListApiKeysRequest reque public async Task CreateApiKeyAsync(CreateApiKeyRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/api-keys", + Path = "api-keys", Body = request } ); @@ -69,7 +69,7 @@ public async Task CreateApiKeyAsync(CreateApiKeyRequestBod public async Task GetApiKeyAsync(string apiKeyId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Get, Path = $"/api-keys/{apiKeyId}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"api-keys/{apiKeyId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -85,10 +85,10 @@ UpdateApiKeyRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/api-keys/{apiKeyId}", + Path = $"api-keys/{apiKeyId}", Body = request } ); @@ -103,7 +103,11 @@ UpdateApiKeyRequestBody request public async Task DeleteApiKeyAsync(string apiKeyId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Delete, Path = $"/api-keys/{apiKeyId}" } + new RawClient.JsonApiRequest + { + Method = HttpMethod.Delete, + Path = $"api-keys/{apiKeyId}" + } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -125,17 +129,17 @@ public async Task CountApiKeysAsync(CountApiKeysRequest re } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/api-keys/count", + Path = "api-keys/count", Query = _query } ); @@ -164,17 +168,17 @@ public async Task ListApiRequestsAsync(ListApiRequestsR } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/api-requests", + Path = "api-requests", Query = _query } ); @@ -189,10 +193,10 @@ public async Task ListApiRequestsAsync(ListApiRequestsR public async Task GetApiRequestAsync(string apiRequestId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = $"/api-requests/{apiRequestId}" + Path = $"api-requests/{apiRequestId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -222,17 +226,17 @@ CountApiRequestsRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/api-requests/count", + Path = "api-requests/count", Query = _query } ); @@ -255,17 +259,17 @@ ListEnvironmentsRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/environments", + Path = "environments", Query = _query } ); @@ -282,10 +286,10 @@ CreateEnvironmentRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/environments", + Path = "environments", Body = request } ); @@ -300,10 +304,10 @@ CreateEnvironmentRequestBody request public async Task GetEnvironmentAsync(string environmentId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = $"/environments/{environmentId}" + Path = $"environments/{environmentId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -320,10 +324,10 @@ UpdateEnvironmentRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/environments/{environmentId}", + Path = $"environments/{environmentId}", Body = request } ); @@ -338,10 +342,10 @@ UpdateEnvironmentRequestBody request public async Task DeleteEnvironmentAsync(string environmentId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Delete, - Path = $"/environments/{environmentId}" + Path = $"environments/{environmentId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); diff --git a/src/SchematicHQ.Client/Accounts/Types/ListApiKeysResponse.cs b/src/SchematicHQ.Client/Accounts/Types/ListApiKeysResponse.cs index 1c569e2..bd4d7d0 100644 --- a/src/SchematicHQ.Client/Accounts/Types/ListApiKeysResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/ListApiKeysResponse.cs @@ -11,7 +11,7 @@ public class ListApiKeysResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsResponse.cs b/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsResponse.cs index 29980c9..f67d787 100644 --- a/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/ListApiRequestsResponse.cs @@ -11,7 +11,7 @@ public class ListApiRequestsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsParams.cs b/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsParams.cs index ea5a79f..92802b8 100644 --- a/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsParams.cs +++ b/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsParams.cs @@ -7,7 +7,7 @@ namespace SchematicHQ.Client; public class ListEnvironmentsParams { [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsResponse.cs b/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsResponse.cs index 5261cb8..3ac93e1 100644 --- a/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsResponse.cs +++ b/src/SchematicHQ.Client/Accounts/Types/ListEnvironmentsResponse.cs @@ -11,7 +11,7 @@ public class ListEnvironmentsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Billing/BillingClient.cs b/src/SchematicHQ.Client/Billing/BillingClient.cs index 495ea46..95c7d17 100644 --- a/src/SchematicHQ.Client/Billing/BillingClient.cs +++ b/src/SchematicHQ.Client/Billing/BillingClient.cs @@ -19,10 +19,10 @@ CreateBillingProductRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/billing/product/upsert", + Path = "billing/product/upsert", Body = request } ); @@ -47,17 +47,17 @@ public async Task ListProductsAsync(ListProductsRequest re } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/billing/products", + Path = "billing/products", Query = _query } ); @@ -74,10 +74,10 @@ CreateBillingSubscriptionsRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/billing/subscription/upsert", + Path = "billing/subscription/upsert", Body = request } ); diff --git a/src/SchematicHQ.Client/Billing/Requests/CreateBillingSubscriptionsRequestBody.cs b/src/SchematicHQ.Client/Billing/Requests/CreateBillingSubscriptionsRequestBody.cs index 9d5f3f1..5a9cc8c 100644 --- a/src/SchematicHQ.Client/Billing/Requests/CreateBillingSubscriptionsRequestBody.cs +++ b/src/SchematicHQ.Client/Billing/Requests/CreateBillingSubscriptionsRequestBody.cs @@ -16,7 +16,7 @@ public class CreateBillingSubscriptionsRequestBody public string? Interval { get; init; } [JsonPropertyName("product_external_ids")] - public List ProductExternalIds { get; init; } + public IEnumerable ProductExternalIds { get; init; } [JsonPropertyName("subscription_external_id")] public string SubscriptionExternalId { get; init; } diff --git a/src/SchematicHQ.Client/Billing/Types/ListProductsParams.cs b/src/SchematicHQ.Client/Billing/Types/ListProductsParams.cs index 0054066..89893f7 100644 --- a/src/SchematicHQ.Client/Billing/Types/ListProductsParams.cs +++ b/src/SchematicHQ.Client/Billing/Types/ListProductsParams.cs @@ -7,7 +7,7 @@ namespace SchematicHQ.Client; public class ListProductsParams { [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Billing/Types/ListProductsResponse.cs b/src/SchematicHQ.Client/Billing/Types/ListProductsResponse.cs index 9bf90ce..fdfd5dc 100644 --- a/src/SchematicHQ.Client/Billing/Types/ListProductsResponse.cs +++ b/src/SchematicHQ.Client/Billing/Types/ListProductsResponse.cs @@ -11,7 +11,7 @@ public class ListProductsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Companies/CompaniesClient.cs b/src/SchematicHQ.Client/Companies/CompaniesClient.cs index 40fe1e0..73e1666 100644 --- a/src/SchematicHQ.Client/Companies/CompaniesClient.cs +++ b/src/SchematicHQ.Client/Companies/CompaniesClient.cs @@ -35,17 +35,17 @@ public async Task ListCompaniesAsync(ListCompaniesRequest } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/companies", + Path = "companies", Query = _query } ); @@ -60,10 +60,10 @@ public async Task ListCompaniesAsync(ListCompaniesRequest public async Task UpsertCompanyAsync(UpsertCompanyRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/companies", + Path = "companies", Body = request } ); @@ -78,7 +78,11 @@ public async Task UpsertCompanyAsync(UpsertCompanyRequest public async Task GetCompanyAsync(string companyId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Get, Path = $"/companies/{companyId}" } + new RawClient.JsonApiRequest + { + Method = HttpMethod.Get, + Path = $"companies/{companyId}" + } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -91,10 +95,10 @@ public async Task GetCompanyAsync(string companyId) public async Task DeleteCompanyAsync(string companyId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Delete, - Path = $"/companies/{companyId}" + Path = $"companies/{companyId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -126,17 +130,17 @@ public async Task CountCompaniesAsync(CountCompaniesRequ } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/companies/count", + Path = "companies/count", Query = _query } ); @@ -151,10 +155,10 @@ public async Task CountCompaniesAsync(CountCompaniesRequ public async Task CreateCompanyAsync(UpsertCompanyRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/companies/create", + Path = "companies/create", Body = request } ); @@ -169,10 +173,10 @@ public async Task CreateCompanyAsync(UpsertCompanyRequest public async Task DeleteCompanyByKeysAsync(KeysRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/companies/delete", + Path = "companies/delete", Body = request } ); @@ -188,10 +192,10 @@ public async Task LookupCompanyAsync(LookupCompanyRequest { var _query = new Dictionary() { { "keys", request.Keys.ToString() }, }; var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/companies/lookup", + Path = "companies/lookup", Query = _query } ); @@ -212,17 +216,17 @@ public async Task GetActiveDealsAsync(GetActiveDealsRequ }; if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/company-crm-deals", + Path = "company-crm-deals", Query = _query } ); @@ -249,17 +253,17 @@ ListCompanyMembershipsRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/company-memberships", + Path = "company-memberships", Query = _query } ); @@ -276,10 +280,10 @@ GetOrCreateCompanyMembershipRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/company-memberships", + Path = "company-memberships", Body = request } ); @@ -296,10 +300,10 @@ string companyMembershipId ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Delete, - Path = $"/company-memberships/{companyMembershipId}" + Path = $"company-memberships/{companyMembershipId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -325,17 +329,17 @@ ListCompanyPlansRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/company-plans", + Path = "company-plans", Query = _query } ); @@ -354,17 +358,17 @@ GetActiveCompanySubscriptionRequest request var _query = new Dictionary() { { "company_id", request.CompanyId }, }; if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/company-subscriptions", + Path = "company-subscriptions", Query = _query } ); @@ -381,10 +385,10 @@ UpsertTraitRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/company-traits", + Path = "company-traits", Body = request } ); @@ -403,7 +407,7 @@ ListEntityKeyDefinitionsRequest request var _query = new Dictionary() { }; if (request.EntityType != null) { - _query["entity_type"] = request.EntityType; + _query["entity_type"] = JsonSerializer.Serialize(request.EntityType.Value); } if (request.Ids != null) { @@ -415,17 +419,17 @@ ListEntityKeyDefinitionsRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/entity-key-definitions", + Path = "entity-key-definitions", Query = _query } ); @@ -444,7 +448,7 @@ CountEntityKeyDefinitionsRequest request var _query = new Dictionary() { }; if (request.EntityType != null) { - _query["entity_type"] = request.EntityType; + _query["entity_type"] = JsonSerializer.Serialize(request.EntityType.Value); } if (request.Ids != null) { @@ -456,17 +460,17 @@ CountEntityKeyDefinitionsRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/entity-key-definitions/count", + Path = "entity-key-definitions/count", Query = _query } ); @@ -485,7 +489,7 @@ ListEntityTraitDefinitionsRequest request var _query = new Dictionary() { }; if (request.EntityType != null) { - _query["entity_type"] = request.EntityType; + _query["entity_type"] = JsonSerializer.Serialize(request.EntityType.Value); } if (request.Ids != null) { @@ -493,7 +497,7 @@ ListEntityTraitDefinitionsRequest request } if (request.TraitType != null) { - _query["trait_type"] = request.TraitType; + _query["trait_type"] = JsonSerializer.Serialize(request.TraitType.Value); } if (request.Q != null) { @@ -501,17 +505,17 @@ ListEntityTraitDefinitionsRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/entity-trait-definitions", + Path = "entity-trait-definitions", Query = _query } ); @@ -528,10 +532,10 @@ CreateEntityTraitDefinitionRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/entity-trait-definitions", + Path = "entity-trait-definitions", Body = request } ); @@ -550,10 +554,10 @@ string entityTraitDefinitionId ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = $"/entity-trait-definitions/{entityTraitDefinitionId}" + Path = $"entity-trait-definitions/{entityTraitDefinitionId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -570,10 +574,10 @@ UpdateEntityTraitDefinitionRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/entity-trait-definitions/{entityTraitDefinitionId}", + Path = $"entity-trait-definitions/{entityTraitDefinitionId}", Body = request } ); @@ -592,7 +596,7 @@ CountEntityTraitDefinitionsRequest request var _query = new Dictionary() { }; if (request.EntityType != null) { - _query["entity_type"] = request.EntityType; + _query["entity_type"] = JsonSerializer.Serialize(request.EntityType.Value); } if (request.Ids != null) { @@ -600,7 +604,7 @@ CountEntityTraitDefinitionsRequest request } if (request.TraitType != null) { - _query["trait_type"] = request.TraitType; + _query["trait_type"] = JsonSerializer.Serialize(request.TraitType.Value); } if (request.Q != null) { @@ -608,17 +612,17 @@ CountEntityTraitDefinitionsRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/entity-trait-definitions/count", + Path = "entity-trait-definitions/count", Query = _query } ); @@ -644,17 +648,17 @@ GetEntityTraitValuesRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/entity-trait-values", + Path = "entity-trait-values", Query = _query } ); @@ -669,10 +673,10 @@ GetEntityTraitValuesRequest request public async Task UpsertUserTraitAsync(UpsertTraitRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/user-traits", + Path = "user-traits", Body = request } ); @@ -705,17 +709,17 @@ public async Task ListUsersAsync(ListUsersRequest request) } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/users", + Path = "users", Query = _query } ); @@ -730,10 +734,10 @@ public async Task ListUsersAsync(ListUsersRequest request) public async Task UpsertUserAsync(UpsertUserRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/users", + Path = "users", Body = request } ); @@ -748,7 +752,7 @@ public async Task UpsertUserAsync(UpsertUserRequestBody requ public async Task GetUserAsync(string userId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Get, Path = $"/users/{userId}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"users/{userId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -761,7 +765,7 @@ public async Task GetUserAsync(string userId) public async Task DeleteUserAsync(string userId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Delete, Path = $"/users/{userId}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Delete, Path = $"users/{userId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -792,17 +796,17 @@ public async Task CountUsersAsync(CountUsersRequest request) } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/users/count", + Path = "users/count", Query = _query } ); @@ -817,10 +821,10 @@ public async Task CountUsersAsync(CountUsersRequest request) public async Task CreateUserAsync(UpsertUserRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/users/create", + Path = "users/create", Body = request } ); @@ -835,10 +839,10 @@ public async Task CreateUserAsync(UpsertUserRequestBody requ public async Task DeleteUserByKeysAsync(KeysRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/users/delete", + Path = "users/delete", Body = request } ); @@ -854,10 +858,10 @@ public async Task LookupUserAsync(LookupUserRequest request) { var _query = new Dictionary() { { "keys", request.Keys.ToString() }, }; var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/users/lookup", + Path = "users/lookup", Query = _query } ); diff --git a/src/SchematicHQ.Client/Companies/Requests/CountEntityKeyDefinitionsRequest.cs b/src/SchematicHQ.Client/Companies/Requests/CountEntityKeyDefinitionsRequest.cs index 366e89b..3f448c1 100644 --- a/src/SchematicHQ.Client/Companies/Requests/CountEntityKeyDefinitionsRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/CountEntityKeyDefinitionsRequest.cs @@ -1,8 +1,12 @@ +using SchematicHQ.Client; + +#nullable enable + namespace SchematicHQ.Client; public class CountEntityKeyDefinitionsRequest { - public string? EntityType { get; init; } + public CountEntityKeyDefinitionsRequestEntityType? EntityType { get; init; } public string? Ids { get; init; } diff --git a/src/SchematicHQ.Client/Companies/Requests/CountEntityTraitDefinitionsRequest.cs b/src/SchematicHQ.Client/Companies/Requests/CountEntityTraitDefinitionsRequest.cs index 956cbe0..7552f25 100644 --- a/src/SchematicHQ.Client/Companies/Requests/CountEntityTraitDefinitionsRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/CountEntityTraitDefinitionsRequest.cs @@ -1,12 +1,16 @@ +using SchematicHQ.Client; + +#nullable enable + namespace SchematicHQ.Client; public class CountEntityTraitDefinitionsRequest { - public string? EntityType { get; init; } + public CountEntityTraitDefinitionsRequestEntityType? EntityType { get; init; } public string? Ids { get; init; } - public string? TraitType { get; init; } + public CountEntityTraitDefinitionsRequestTraitType? TraitType { get; init; } public string? Q { get; init; } diff --git a/src/SchematicHQ.Client/Companies/Requests/CreateEntityTraitDefinitionRequestBody.cs b/src/SchematicHQ.Client/Companies/Requests/CreateEntityTraitDefinitionRequestBody.cs index a2c1229..71c5f06 100644 --- a/src/SchematicHQ.Client/Companies/Requests/CreateEntityTraitDefinitionRequestBody.cs +++ b/src/SchematicHQ.Client/Companies/Requests/CreateEntityTraitDefinitionRequestBody.cs @@ -14,7 +14,7 @@ public class CreateEntityTraitDefinitionRequestBody public CreateEntityTraitDefinitionRequestBodyEntityType EntityType { get; init; } [JsonPropertyName("hierarchy")] - public List Hierarchy { get; init; } + public IEnumerable Hierarchy { get; init; } [JsonPropertyName("trait_type")] public CreateEntityTraitDefinitionRequestBodyTraitType TraitType { get; init; } diff --git a/src/SchematicHQ.Client/Companies/Requests/ListEntityKeyDefinitionsRequest.cs b/src/SchematicHQ.Client/Companies/Requests/ListEntityKeyDefinitionsRequest.cs index d9416c5..35450dc 100644 --- a/src/SchematicHQ.Client/Companies/Requests/ListEntityKeyDefinitionsRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/ListEntityKeyDefinitionsRequest.cs @@ -1,8 +1,12 @@ +using SchematicHQ.Client; + +#nullable enable + namespace SchematicHQ.Client; public class ListEntityKeyDefinitionsRequest { - public string? EntityType { get; init; } + public ListEntityKeyDefinitionsRequestEntityType? EntityType { get; init; } public string? Ids { get; init; } diff --git a/src/SchematicHQ.Client/Companies/Requests/ListEntityTraitDefinitionsRequest.cs b/src/SchematicHQ.Client/Companies/Requests/ListEntityTraitDefinitionsRequest.cs index d137bde..df88db3 100644 --- a/src/SchematicHQ.Client/Companies/Requests/ListEntityTraitDefinitionsRequest.cs +++ b/src/SchematicHQ.Client/Companies/Requests/ListEntityTraitDefinitionsRequest.cs @@ -1,12 +1,16 @@ +using SchematicHQ.Client; + +#nullable enable + namespace SchematicHQ.Client; public class ListEntityTraitDefinitionsRequest { - public string? EntityType { get; init; } + public ListEntityTraitDefinitionsRequestEntityType? EntityType { get; init; } public string? Ids { get; init; } - public string? TraitType { get; init; } + public ListEntityTraitDefinitionsRequestTraitType? TraitType { get; init; } public string? Q { get; init; } diff --git a/src/SchematicHQ.Client/Companies/Types/CountCompaniesParams.cs b/src/SchematicHQ.Client/Companies/Types/CountCompaniesParams.cs index 792f498..bc491be 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountCompaniesParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountCompaniesParams.cs @@ -7,7 +7,7 @@ namespace SchematicHQ.Client; public class CountCompaniesParams { [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsParams.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsParams.cs index 7384b40..7a02f1b 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client; #nullable enable @@ -7,10 +8,10 @@ namespace SchematicHQ.Client; public class CountEntityKeyDefinitionsParams { [JsonPropertyName("entity_type")] - public string? EntityType { get; init; } + public CountEntityKeyDefinitionsResponseParamsEntityType? EntityType { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } [JsonPropertyName("key")] public string? Key { get; init; } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsRequestEntityType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsRequestEntityType.cs new file mode 100644 index 0000000..dbff765 --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsRequestEntityType.cs @@ -0,0 +1,18 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum CountEntityKeyDefinitionsRequestEntityType +{ + [EnumMember(Value = "company")] + Company, + + [EnumMember(Value = "user")] + User +} diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponseParamsEntityType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponseParamsEntityType.cs new file mode 100644 index 0000000..e2488a5 --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityKeyDefinitionsResponseParamsEntityType.cs @@ -0,0 +1,18 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum CountEntityKeyDefinitionsResponseParamsEntityType +{ + [EnumMember(Value = "company")] + Company, + + [EnumMember(Value = "user")] + User +} diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsParams.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsParams.cs index 82a2bd8..593def4 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client; #nullable enable @@ -7,10 +8,10 @@ namespace SchematicHQ.Client; public class CountEntityTraitDefinitionsParams { [JsonPropertyName("entity_type")] - public string? EntityType { get; init; } + public CountEntityTraitDefinitionsResponseParamsEntityType? EntityType { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) @@ -28,5 +29,5 @@ public class CountEntityTraitDefinitionsParams public string? Q { get; init; } [JsonPropertyName("trait_type")] - public string? TraitType { get; init; } + public CountEntityTraitDefinitionsResponseParamsTraitType? TraitType { get; init; } } diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestEntityType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestEntityType.cs new file mode 100644 index 0000000..ace1a09 --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestEntityType.cs @@ -0,0 +1,18 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum CountEntityTraitDefinitionsRequestEntityType +{ + [EnumMember(Value = "company")] + Company, + + [EnumMember(Value = "user")] + User +} diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestTraitType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestTraitType.cs new file mode 100644 index 0000000..e1a1d2a --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsRequestTraitType.cs @@ -0,0 +1,30 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum CountEntityTraitDefinitionsRequestTraitType +{ + [EnumMember(Value = "boolean")] + Boolean, + + [EnumMember(Value = "currency")] + Currency, + + [EnumMember(Value = "date")] + Date, + + [EnumMember(Value = "number")] + Number, + + [EnumMember(Value = "string")] + String, + + [EnumMember(Value = "url")] + Url +} diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsEntityType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsEntityType.cs new file mode 100644 index 0000000..5aa0158 --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsEntityType.cs @@ -0,0 +1,18 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum CountEntityTraitDefinitionsResponseParamsEntityType +{ + [EnumMember(Value = "company")] + Company, + + [EnumMember(Value = "user")] + User +} diff --git a/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsTraitType.cs b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsTraitType.cs new file mode 100644 index 0000000..74a4cb3 --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/CountEntityTraitDefinitionsResponseParamsTraitType.cs @@ -0,0 +1,30 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum CountEntityTraitDefinitionsResponseParamsTraitType +{ + [EnumMember(Value = "boolean")] + Boolean, + + [EnumMember(Value = "currency")] + Currency, + + [EnumMember(Value = "date")] + Date, + + [EnumMember(Value = "number")] + Number, + + [EnumMember(Value = "string")] + String, + + [EnumMember(Value = "url")] + Url +} diff --git a/src/SchematicHQ.Client/Companies/Types/CountUsersParams.cs b/src/SchematicHQ.Client/Companies/Types/CountUsersParams.cs index 2b29786..60240c7 100644 --- a/src/SchematicHQ.Client/Companies/Types/CountUsersParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/CountUsersParams.cs @@ -10,7 +10,7 @@ public class CountUsersParams public string? CompanyId { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionResponse.cs index 7d76a43..4a87003 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetActiveCompanySubscriptionResponse.cs @@ -11,7 +11,7 @@ public class GetActiveCompanySubscriptionResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Companies/Types/GetActiveDealsResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetActiveDealsResponse.cs index 6c06320..ffa566c 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetActiveDealsResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetActiveDealsResponse.cs @@ -11,7 +11,7 @@ public class GetActiveDealsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesResponse.cs b/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesResponse.cs index a700add..646720a 100644 --- a/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/GetEntityTraitValuesResponse.cs @@ -11,7 +11,7 @@ public class GetEntityTraitValuesResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Companies/Types/ListCompaniesParams.cs b/src/SchematicHQ.Client/Companies/Types/ListCompaniesParams.cs index bca7c53..3142e8d 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListCompaniesParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListCompaniesParams.cs @@ -7,7 +7,7 @@ namespace SchematicHQ.Client; public class ListCompaniesParams { [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Companies/Types/ListCompaniesResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListCompaniesResponse.cs index a27b7e1..344eb1d 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListCompaniesResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListCompaniesResponse.cs @@ -11,7 +11,7 @@ public class ListCompaniesResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsResponse.cs index b477907..4ce4c9b 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListCompanyMembershipsResponse.cs @@ -11,7 +11,7 @@ public class ListCompanyMembershipsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Companies/Types/ListCompanyPlansResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListCompanyPlansResponse.cs index b91d5d6..8fcc6dc 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListCompanyPlansResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListCompanyPlansResponse.cs @@ -11,7 +11,7 @@ public class ListCompanyPlansResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsParams.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsParams.cs index 4bf20bc..5aeb991 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client; #nullable enable @@ -7,10 +8,10 @@ namespace SchematicHQ.Client; public class ListEntityKeyDefinitionsParams { [JsonPropertyName("entity_type")] - public string? EntityType { get; init; } + public ListEntityKeyDefinitionsResponseParamsEntityType? EntityType { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } [JsonPropertyName("key")] public string? Key { get; init; } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsRequestEntityType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsRequestEntityType.cs new file mode 100644 index 0000000..f8685a1 --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsRequestEntityType.cs @@ -0,0 +1,18 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum ListEntityKeyDefinitionsRequestEntityType +{ + [EnumMember(Value = "company")] + Company, + + [EnumMember(Value = "user")] + User +} diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponse.cs index b2d6a68..4aacf94 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponse.cs @@ -11,7 +11,7 @@ public class ListEntityKeyDefinitionsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponseParamsEntityType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponseParamsEntityType.cs new file mode 100644 index 0000000..a0369b8 --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityKeyDefinitionsResponseParamsEntityType.cs @@ -0,0 +1,18 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum ListEntityKeyDefinitionsResponseParamsEntityType +{ + [EnumMember(Value = "company")] + Company, + + [EnumMember(Value = "user")] + User +} diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsParams.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsParams.cs index 4d2d6d8..85a2eb9 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsParams.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client; #nullable enable @@ -7,10 +8,10 @@ namespace SchematicHQ.Client; public class ListEntityTraitDefinitionsParams { [JsonPropertyName("entity_type")] - public string? EntityType { get; init; } + public ListEntityTraitDefinitionsResponseParamsEntityType? EntityType { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) @@ -28,5 +29,5 @@ public class ListEntityTraitDefinitionsParams public string? Q { get; init; } [JsonPropertyName("trait_type")] - public string? TraitType { get; init; } + public ListEntityTraitDefinitionsResponseParamsTraitType? TraitType { get; init; } } diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestEntityType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestEntityType.cs new file mode 100644 index 0000000..c27869a --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestEntityType.cs @@ -0,0 +1,18 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum ListEntityTraitDefinitionsRequestEntityType +{ + [EnumMember(Value = "company")] + Company, + + [EnumMember(Value = "user")] + User +} diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestTraitType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestTraitType.cs new file mode 100644 index 0000000..8f9d93b --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsRequestTraitType.cs @@ -0,0 +1,30 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum ListEntityTraitDefinitionsRequestTraitType +{ + [EnumMember(Value = "boolean")] + Boolean, + + [EnumMember(Value = "currency")] + Currency, + + [EnumMember(Value = "date")] + Date, + + [EnumMember(Value = "number")] + Number, + + [EnumMember(Value = "string")] + String, + + [EnumMember(Value = "url")] + Url +} diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponse.cs index 7575737..d0627a7 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponse.cs @@ -11,7 +11,7 @@ public class ListEntityTraitDefinitionsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsEntityType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsEntityType.cs new file mode 100644 index 0000000..45081aa --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsEntityType.cs @@ -0,0 +1,18 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum ListEntityTraitDefinitionsResponseParamsEntityType +{ + [EnumMember(Value = "company")] + Company, + + [EnumMember(Value = "user")] + User +} diff --git a/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsTraitType.cs b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsTraitType.cs new file mode 100644 index 0000000..c9ad83f --- /dev/null +++ b/src/SchematicHQ.Client/Companies/Types/ListEntityTraitDefinitionsResponseParamsTraitType.cs @@ -0,0 +1,30 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum ListEntityTraitDefinitionsResponseParamsTraitType +{ + [EnumMember(Value = "boolean")] + Boolean, + + [EnumMember(Value = "currency")] + Currency, + + [EnumMember(Value = "date")] + Date, + + [EnumMember(Value = "number")] + Number, + + [EnumMember(Value = "string")] + String, + + [EnumMember(Value = "url")] + Url +} diff --git a/src/SchematicHQ.Client/Companies/Types/ListUsersParams.cs b/src/SchematicHQ.Client/Companies/Types/ListUsersParams.cs index 5a4387e..c8b801a 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListUsersParams.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListUsersParams.cs @@ -10,7 +10,7 @@ public class ListUsersParams public string? CompanyId { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Companies/Types/ListUsersResponse.cs b/src/SchematicHQ.Client/Companies/Types/ListUsersResponse.cs index 9af4454..84b1780 100644 --- a/src/SchematicHQ.Client/Companies/Types/ListUsersResponse.cs +++ b/src/SchematicHQ.Client/Companies/Types/ListUsersResponse.cs @@ -11,7 +11,7 @@ public class ListUsersResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Core/CollectionItemSerializer.cs b/src/SchematicHQ.Client/Core/CollectionItemSerializer.cs new file mode 100644 index 0000000..22dfafe --- /dev/null +++ b/src/SchematicHQ.Client/Core/CollectionItemSerializer.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace SchematicHQ.Client; + +/// +/// Json collection converter. +/// +/// Type of item to convert. +/// Converter to use for individual items. +public class CollectionItemSerializer + : JsonConverter> + where TConverterType : JsonConverter +{ + /// + /// Reads a json string and deserializes it into an object. + /// + /// Json reader. + /// Type to convert. + /// Serializer options. + /// Created object. + public override IEnumerable Read( + ref Utf8JsonReader reader, + Type typeToConvert, + JsonSerializerOptions options + ) + { + if (reader.TokenType == JsonTokenType.Null) + { + return default(IEnumerable); + } + + JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions(options); + jsonSerializerOptions.Converters.Clear(); + jsonSerializerOptions.Converters.Add(Activator.CreateInstance()); + + List returnValue = new List(); + + while (reader.TokenType != JsonTokenType.EndArray) + { + if (reader.TokenType != JsonTokenType.StartArray) + { + returnValue.Add( + (TDatatype) + JsonSerializer.Deserialize( + ref reader, + typeof(TDatatype), + jsonSerializerOptions + ) + ); + } + + reader.Read(); + } + + return returnValue; + } + + /// + /// Writes a json string. + /// + /// Json writer. + /// Value to write. + /// Serializer options. + public override void Write( + Utf8JsonWriter writer, + IEnumerable value, + JsonSerializerOptions options + ) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + + JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions(options); + jsonSerializerOptions.Converters.Clear(); + jsonSerializerOptions.Converters.Add(Activator.CreateInstance()); + + writer.WriteStartArray(); + + foreach (TDatatype data in value) + { + JsonSerializer.Serialize(writer, data, jsonSerializerOptions); + } + + writer.WriteEndArray(); + } +} diff --git a/src/SchematicHQ.Client/Core/RawClient.cs b/src/SchematicHQ.Client/Core/RawClient.cs index ba63f26..809dd9f 100644 --- a/src/SchematicHQ.Client/Core/RawClient.cs +++ b/src/SchematicHQ.Client/Core/RawClient.cs @@ -26,12 +26,10 @@ public RawClient(Dictionary headers, ClientOptions clientOptions _headers = headers; } - public async Task MakeRequestAsync(ApiRequest request) + public async Task MakeRequestAsync(BaseApiRequest request) { - var httpRequest = new HttpRequestMessage( - request.Method, - this.BuildUrl(request.Path, request.Query) - ); + var url = this.BuildUrl(request.Path, request.Query); + var httpRequest = new HttpRequestMessage(request.Method, url); if (request.ContentType != null) { request.Headers.Add("Content-Type", request.ContentType); @@ -47,24 +45,31 @@ public async Task MakeRequestAsync(ApiRequest request) httpRequest.Headers.Add(key, value); } // Add the request body to the request - if (request.Body != null) + if (request is JsonApiRequest jsonRequest) { - var serializerOptions = new JsonSerializerOptions { WriteIndented = true, }; - httpRequest.Content = new StringContent( - JsonSerializer.Serialize(request.Body, serializerOptions), - Encoding.UTF8, - "application/json" - ); + if (jsonRequest.Body != null) + { + var serializerOptions = new JsonSerializerOptions { WriteIndented = true, }; + httpRequest.Content = new StringContent( + JsonSerializer.Serialize(jsonRequest.Body, serializerOptions), + Encoding.UTF8, + "application/json" + ); + } + } + else if (request is StreamApiRequest streamRequest) + { + if (streamRequest.Body != null) + { + httpRequest.Content = new StreamContent(streamRequest.Body); + } } // Send the request HttpResponseMessage response = await _clientOptions.HttpClient.SendAsync(httpRequest); return new ApiResponse { StatusCode = (int)response.StatusCode, Raw = response }; } - /// - /// The request object to be sent to the API. - /// - public class ApiRequest + public abstract class BaseApiRequest { public HttpMethod Method; @@ -72,8 +77,6 @@ public class ApiRequest public string? ContentType = null; - public object? Body { get; init; } = null; - public Dictionary Query { get; init; } = new(); public Dictionary Headers { get; init; } = new(); @@ -81,6 +84,22 @@ public class ApiRequest public object RequestOptions { get; init; } } + /// + /// The request object to be sent for streaming uploads. + /// + public class StreamApiRequest : BaseApiRequest + { + public Stream? Body { get; init; } = null; + } + + /// + /// The request object to be sent for JSON APIs. + /// + public class JsonApiRequest : BaseApiRequest + { + public object? Body { get; init; } = null; + } + /// /// The response object returned from the API. /// @@ -91,7 +110,7 @@ public class ApiResponse public HttpResponseMessage Raw; } - private Dictionary GetHeaders(ApiRequest request) + private Dictionary GetHeaders(BaseApiRequest request) { var headers = new Dictionary(); foreach (var (key, value) in request.Headers) @@ -105,9 +124,11 @@ private Dictionary GetHeaders(ApiRequest request) return headers; } - private string BuildUrl(string path, Dictionary query) + public string BuildUrl(string path, Dictionary query) { - var url = $"{_clientOptions.BaseUrl}{path}"; + var trimmedBaseUrl = _clientOptions.BaseUrl.TrimEnd('/'); + var trimmedBasePath = path.TrimStart('/'); + var url = $"{trimmedBaseUrl}/{trimmedBasePath}"; if (query.Count > 0) { url += "?"; diff --git a/src/SchematicHQ.Client/Crm/CrmClient.cs b/src/SchematicHQ.Client/Crm/CrmClient.cs index 296bf02..6e4c44d 100644 --- a/src/SchematicHQ.Client/Crm/CrmClient.cs +++ b/src/SchematicHQ.Client/Crm/CrmClient.cs @@ -19,10 +19,10 @@ CreateCrmDealLineItemAssociationRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/crm/associations/deal-line-item", + Path = "crm/associations/deal-line-item", Body = request } ); @@ -39,10 +39,10 @@ CreateCrmLineItemRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/crm/deal-line-item/upsert", + Path = "crm/deal-line-item/upsert", Body = request } ); @@ -57,10 +57,10 @@ CreateCrmLineItemRequestBody request public async Task UpsertCrmDealAsync(CreateCrmDealRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/crm/deals/upsert", + Path = "crm/deals/upsert", Body = request } ); @@ -85,17 +85,17 @@ public async Task ListCrmProductsAsync(ListCrmProductsR } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/crm/products", + Path = "crm/products", Query = _query } ); @@ -112,10 +112,10 @@ CreateCrmProductRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/crm/products/upsert", + Path = "crm/products/upsert", Body = request } ); diff --git a/src/SchematicHQ.Client/Crm/Types/ListCrmProductsParams.cs b/src/SchematicHQ.Client/Crm/Types/ListCrmProductsParams.cs index 7314119..400df78 100644 --- a/src/SchematicHQ.Client/Crm/Types/ListCrmProductsParams.cs +++ b/src/SchematicHQ.Client/Crm/Types/ListCrmProductsParams.cs @@ -7,7 +7,7 @@ namespace SchematicHQ.Client; public class ListCrmProductsParams { [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Crm/Types/ListCrmProductsResponse.cs b/src/SchematicHQ.Client/Crm/Types/ListCrmProductsResponse.cs index 6a2ce6f..68ff459 100644 --- a/src/SchematicHQ.Client/Crm/Types/ListCrmProductsResponse.cs +++ b/src/SchematicHQ.Client/Crm/Types/ListCrmProductsResponse.cs @@ -11,7 +11,7 @@ public class ListCrmProductsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs b/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs index 17c3573..ebf97a1 100644 --- a/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs +++ b/src/SchematicHQ.Client/Entitlements/EntitlementsClient.cs @@ -41,17 +41,17 @@ ListCompanyOverridesRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/company-overrides", + Path = "company-overrides", Query = _query } ); @@ -68,10 +68,10 @@ CreateCompanyOverrideRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/company-overrides", + Path = "company-overrides", Body = request } ); @@ -86,10 +86,10 @@ CreateCompanyOverrideRequestBody request public async Task GetCompanyOverrideAsync(string companyOverrideId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = $"/company-overrides/{companyOverrideId}" + Path = $"company-overrides/{companyOverrideId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -106,10 +106,10 @@ UpdateCompanyOverrideRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/company-overrides/{companyOverrideId}", + Path = $"company-overrides/{companyOverrideId}", Body = request } ); @@ -126,10 +126,10 @@ string companyOverrideId ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Delete, - Path = $"/company-overrides/{companyOverrideId}" + Path = $"company-overrides/{companyOverrideId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -167,17 +167,17 @@ CountCompanyOverridesRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/company-overrides/count", + Path = "company-overrides/count", Query = _query } ); @@ -200,17 +200,17 @@ ListFeatureCompaniesRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/feature-companies", + Path = "feature-companies", Query = _query } ); @@ -233,17 +233,17 @@ CountFeatureCompaniesRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/feature-companies/count", + Path = "feature-companies/count", Query = _query } ); @@ -266,7 +266,7 @@ ListFeatureUsageRequest request } if (request.CompanyKeys != null) { - _query["company_keys"] = request.CompanyKeys; + _query["company_keys"] = request.CompanyKeys.ToString(); } if (request.FeatureIds != null) { @@ -278,17 +278,17 @@ ListFeatureUsageRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/feature-usage", + Path = "feature-usage", Query = _query } ); @@ -311,7 +311,7 @@ CountFeatureUsageRequest request } if (request.CompanyKeys != null) { - _query["company_keys"] = request.CompanyKeys; + _query["company_keys"] = request.CompanyKeys.ToString(); } if (request.FeatureIds != null) { @@ -323,17 +323,17 @@ CountFeatureUsageRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/feature-usage/count", + Path = "feature-usage/count", Query = _query } ); @@ -356,17 +356,17 @@ ListFeatureUsersRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/feature-users", + Path = "feature-users", Query = _query } ); @@ -389,17 +389,17 @@ CountFeatureUsersRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/feature-users/count", + Path = "feature-users/count", Query = _query } ); @@ -436,19 +436,23 @@ ListPlanEntitlementsRequest request { _query["plan_ids"] = request.PlanIds; } + if (request.Q != null) + { + _query["q"] = request.Q; + } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/plan-entitlements", + Path = "plan-entitlements", Query = _query } ); @@ -465,10 +469,10 @@ CreatePlanEntitlementRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/plan-entitlements", + Path = "plan-entitlements", Body = request } ); @@ -483,10 +487,10 @@ CreatePlanEntitlementRequestBody request public async Task GetPlanEntitlementAsync(string planEntitlementId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = $"/plan-entitlements/{planEntitlementId}" + Path = $"plan-entitlements/{planEntitlementId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -503,10 +507,10 @@ UpdatePlanEntitlementRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/plan-entitlements/{planEntitlementId}", + Path = $"plan-entitlements/{planEntitlementId}", Body = request } ); @@ -523,10 +527,10 @@ string planEntitlementId ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Delete, - Path = $"/plan-entitlements/{planEntitlementId}" + Path = $"plan-entitlements/{planEntitlementId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -562,19 +566,23 @@ CountPlanEntitlementsRequest request { _query["plan_ids"] = request.PlanIds; } + if (request.Q != null) + { + _query["q"] = request.Q; + } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/plan-entitlements/count", + Path = "plan-entitlements/count", Query = _query } ); @@ -592,10 +600,10 @@ GetFeatureUsageByCompanyRequest request { var _query = new Dictionary() { { "keys", request.Keys.ToString() }, }; var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/usage-by-company", + Path = "usage-by-company", Query = _query } ); diff --git a/src/SchematicHQ.Client/Entitlements/Requests/CountPlanEntitlementsRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/CountPlanEntitlementsRequest.cs index 83a4682..3976730 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/CountPlanEntitlementsRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/CountPlanEntitlementsRequest.cs @@ -12,6 +12,8 @@ public class CountPlanEntitlementsRequest public string? PlanIds { get; init; } + public string? Q { get; init; } + /// /// Page limit (default 100) /// diff --git a/src/SchematicHQ.Client/Entitlements/Requests/ListPlanEntitlementsRequest.cs b/src/SchematicHQ.Client/Entitlements/Requests/ListPlanEntitlementsRequest.cs index 0663d3d..befd20c 100644 --- a/src/SchematicHQ.Client/Entitlements/Requests/ListPlanEntitlementsRequest.cs +++ b/src/SchematicHQ.Client/Entitlements/Requests/ListPlanEntitlementsRequest.cs @@ -12,6 +12,8 @@ public class ListPlanEntitlementsRequest public string? PlanIds { get; init; } + public string? Q { get; init; } + /// /// Page limit (default 100) /// diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesParams.cs b/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesParams.cs index 5d94b53..538267c 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountCompanyOverridesParams.cs @@ -10,16 +10,16 @@ public class CountCompanyOverridesParams public string? CompanyId { get; init; } [JsonPropertyName("company_ids")] - public List? CompanyIds { get; init; } + public IEnumerable? CompanyIds { get; init; } [JsonPropertyName("feature_id")] public string? FeatureId { get; init; } [JsonPropertyName("feature_ids")] - public List? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageParams.cs b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageParams.cs index c730241..72fa650 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountFeatureUsageParams.cs @@ -13,7 +13,7 @@ public class CountFeatureUsageParams public Dictionary? CompanyKeys { get; init; } [JsonPropertyName("feature_ids")] - public List? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsParams.cs b/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsParams.cs index 859ceb3..c693c84 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/CountPlanEntitlementsParams.cs @@ -10,10 +10,10 @@ public class CountPlanEntitlementsParams public string? FeatureId { get; init; } [JsonPropertyName("feature_ids")] - public List? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) @@ -31,5 +31,8 @@ public class CountPlanEntitlementsParams public string? PlanId { get; init; } [JsonPropertyName("plan_ids")] - public List? PlanIds { get; init; } + public IEnumerable? PlanIds { get; init; } + + [JsonPropertyName("q")] + public string? Q { get; init; } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesParams.cs b/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesParams.cs index 879b0a4..26cfd17 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesParams.cs @@ -10,16 +10,16 @@ public class ListCompanyOverridesParams public string? CompanyId { get; init; } [JsonPropertyName("company_ids")] - public List? CompanyIds { get; init; } + public IEnumerable? CompanyIds { get; init; } [JsonPropertyName("feature_id")] public string? FeatureId { get; init; } [JsonPropertyName("feature_ids")] - public List? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesResponse.cs index ce916a6..c9d0a37 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListCompanyOverridesResponse.cs @@ -11,7 +11,7 @@ public class ListCompanyOverridesResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesResponse.cs index 43d0fce..96d20d1 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureCompaniesResponse.cs @@ -11,7 +11,7 @@ public class ListFeatureCompaniesResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageParams.cs b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageParams.cs index 31b8030..2a42089 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageParams.cs @@ -13,7 +13,7 @@ public class ListFeatureUsageParams public Dictionary? CompanyKeys { get; init; } [JsonPropertyName("feature_ids")] - public List? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageResponse.cs index adb6476..3a44068 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsageResponse.cs @@ -11,7 +11,7 @@ public class ListFeatureUsageResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersResponse.cs index 6f83780..37e38b9 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListFeatureUsersResponse.cs @@ -11,7 +11,7 @@ public class ListFeatureUsersResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsParams.cs b/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsParams.cs index c09eb11..edc0f7c 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsParams.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsParams.cs @@ -10,10 +10,10 @@ public class ListPlanEntitlementsParams public string? FeatureId { get; init; } [JsonPropertyName("feature_ids")] - public List? FeatureIds { get; init; } + public IEnumerable? FeatureIds { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) @@ -31,5 +31,8 @@ public class ListPlanEntitlementsParams public string? PlanId { get; init; } [JsonPropertyName("plan_ids")] - public List? PlanIds { get; init; } + public IEnumerable? PlanIds { get; init; } + + [JsonPropertyName("q")] + public string? Q { get; init; } } diff --git a/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsResponse.cs b/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsResponse.cs index 59c3549..6606368 100644 --- a/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsResponse.cs +++ b/src/SchematicHQ.Client/Entitlements/Types/ListPlanEntitlementsResponse.cs @@ -11,7 +11,7 @@ public class ListPlanEntitlementsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Events/EventsClient.cs b/src/SchematicHQ.Client/Events/EventsClient.cs index 537923a..d15e52e 100644 --- a/src/SchematicHQ.Client/Events/EventsClient.cs +++ b/src/SchematicHQ.Client/Events/EventsClient.cs @@ -19,10 +19,10 @@ CreateEventBatchRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/event-batch", + Path = "event-batch", Body = request } ); @@ -49,17 +49,17 @@ GetEventSummariesRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/event-types", + Path = "event-types", Query = _query } ); @@ -74,7 +74,7 @@ GetEventSummariesRequest request public async Task GetEventSummaryBySubtypeAsync(string key) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Get, Path = $"/event-types/{key}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"event-types/{key}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -101,17 +101,17 @@ public async Task ListEventsAsync(ListEventsRequest request) } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/events", + Path = "events", Query = _query } ); @@ -126,10 +126,10 @@ public async Task ListEventsAsync(ListEventsRequest request) public async Task CreateEventAsync(CreateEventRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/events", + Path = "events", Body = request } ); @@ -144,7 +144,7 @@ public async Task CreateEventAsync(CreateEventRequestBody r public async Task GetEventAsync(string eventId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Get, Path = $"/events/{eventId}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"events/{eventId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -161,11 +161,11 @@ ListMetricCountsRequest request var _query = new Dictionary() { }; if (request.StartTime != null) { - _query["start_time"] = request.StartTime; + _query["start_time"] = request.StartTime.Value.ToString("o0"); } if (request.EndTime != null) { - _query["end_time"] = request.EndTime; + _query["end_time"] = request.EndTime.Value.ToString("o0"); } if (request.EventSubtype != null) { @@ -189,21 +189,21 @@ ListMetricCountsRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } if (request.Grouping != null) { _query["grouping"] = request.Grouping; } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/metric-counts", + Path = "metric-counts", Query = _query } ); @@ -218,7 +218,7 @@ ListMetricCountsRequest request public async Task GetSegmentIntegrationStatusAsync() { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Get, Path = "/segment-integration" } + new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = "segment-integration" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) diff --git a/src/SchematicHQ.Client/Events/Requests/CreateEventBatchRequestBody.cs b/src/SchematicHQ.Client/Events/Requests/CreateEventBatchRequestBody.cs index 7a390c8..eee2348 100644 --- a/src/SchematicHQ.Client/Events/Requests/CreateEventBatchRequestBody.cs +++ b/src/SchematicHQ.Client/Events/Requests/CreateEventBatchRequestBody.cs @@ -8,5 +8,5 @@ namespace SchematicHQ.Client; public class CreateEventBatchRequestBody { [JsonPropertyName("events")] - public List Events { get; init; } + public IEnumerable Events { get; init; } } diff --git a/src/SchematicHQ.Client/Events/Types/GetEventSummariesParams.cs b/src/SchematicHQ.Client/Events/Types/GetEventSummariesParams.cs index cc2dfbc..dd43661 100644 --- a/src/SchematicHQ.Client/Events/Types/GetEventSummariesParams.cs +++ b/src/SchematicHQ.Client/Events/Types/GetEventSummariesParams.cs @@ -7,7 +7,7 @@ namespace SchematicHQ.Client; public class GetEventSummariesParams { [JsonPropertyName("event_subtypes")] - public List? EventSubtypes { get; init; } + public IEnumerable? EventSubtypes { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Events/Types/GetEventSummariesResponse.cs b/src/SchematicHQ.Client/Events/Types/GetEventSummariesResponse.cs index 2e7da0a..7c259b7 100644 --- a/src/SchematicHQ.Client/Events/Types/GetEventSummariesResponse.cs +++ b/src/SchematicHQ.Client/Events/Types/GetEventSummariesResponse.cs @@ -11,7 +11,7 @@ public class GetEventSummariesResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Events/Types/ListEventsResponse.cs b/src/SchematicHQ.Client/Events/Types/ListEventsResponse.cs index 2c36641..633f4a5 100644 --- a/src/SchematicHQ.Client/Events/Types/ListEventsResponse.cs +++ b/src/SchematicHQ.Client/Events/Types/ListEventsResponse.cs @@ -11,7 +11,7 @@ public class ListEventsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Events/Types/ListMetricCountsParams.cs b/src/SchematicHQ.Client/Events/Types/ListMetricCountsParams.cs index cd602ef..0ae0391 100644 --- a/src/SchematicHQ.Client/Events/Types/ListMetricCountsParams.cs +++ b/src/SchematicHQ.Client/Events/Types/ListMetricCountsParams.cs @@ -10,7 +10,7 @@ public class ListMetricCountsParams public string? CompanyId { get; init; } [JsonPropertyName("company_ids")] - public List? CompanyIds { get; init; } + public IEnumerable? CompanyIds { get; init; } [JsonPropertyName("end_time")] public DateTime? EndTime { get; init; } @@ -19,7 +19,7 @@ public class ListMetricCountsParams public string? EventSubtype { get; init; } [JsonPropertyName("event_subtypes")] - public List? EventSubtypes { get; init; } + public IEnumerable? EventSubtypes { get; init; } [JsonPropertyName("grouping")] public string? Grouping { get; init; } diff --git a/src/SchematicHQ.Client/Events/Types/ListMetricCountsResponse.cs b/src/SchematicHQ.Client/Events/Types/ListMetricCountsResponse.cs index 514b554..9368a08 100644 --- a/src/SchematicHQ.Client/Events/Types/ListMetricCountsResponse.cs +++ b/src/SchematicHQ.Client/Events/Types/ListMetricCountsResponse.cs @@ -11,7 +11,7 @@ public class ListMetricCountsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Features/FeaturesClient.cs b/src/SchematicHQ.Client/Features/FeaturesClient.cs index 9fe1ea8..dbce11f 100644 --- a/src/SchematicHQ.Client/Features/FeaturesClient.cs +++ b/src/SchematicHQ.Client/Features/FeaturesClient.cs @@ -19,10 +19,10 @@ AudienceRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/audience/count-companies", + Path = "audience/count-companies", Body = request } ); @@ -39,10 +39,10 @@ AudienceRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/audience/count-users", + Path = "audience/count-users", Body = request } ); @@ -59,10 +59,10 @@ AudienceRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/audience/get-companies", + Path = "audience/get-companies", Body = request } ); @@ -77,10 +77,10 @@ AudienceRequestBody request public async Task ListAudienceUsersAsync(AudienceRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/audience/get-users", + Path = "audience/get-users", Body = request } ); @@ -113,17 +113,17 @@ public async Task ListFeaturesAsync(ListFeaturesRequest re } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/features", + Path = "features", Query = _query } ); @@ -138,10 +138,10 @@ public async Task ListFeaturesAsync(ListFeaturesRequest re public async Task CreateFeatureAsync(CreateFeatureRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/features", + Path = "features", Body = request } ); @@ -156,7 +156,7 @@ public async Task CreateFeatureAsync(CreateFeatureRequest public async Task GetFeatureAsync(string featureId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Get, Path = $"/features/{featureId}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"features/{featureId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -172,10 +172,10 @@ UpdateFeatureRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/features/{featureId}", + Path = $"features/{featureId}", Body = request } ); @@ -190,7 +190,11 @@ UpdateFeatureRequestBody request public async Task DeleteFeatureAsync(string featureId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Delete, Path = $"/features/{featureId}" } + new RawClient.JsonApiRequest + { + Method = HttpMethod.Delete, + Path = $"features/{featureId}" + } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -221,17 +225,17 @@ public async Task CountFeaturesAsync(CountFeaturesRequest } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/features/count", + Path = "features/count", Query = _query } ); @@ -260,17 +264,17 @@ public async Task ListFlagChecksAsync(ListFlagChecksRequ } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/flag-checks", + Path = "flag-checks", Query = _query } ); @@ -285,10 +289,10 @@ public async Task ListFlagChecksAsync(ListFlagChecksRequ public async Task GetFlagCheckAsync(string flagCheckId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = $"/flag-checks/{flagCheckId}" + Path = $"flag-checks/{flagCheckId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -316,17 +320,17 @@ public async Task CountFlagChecksAsync(CountFlagChecksR } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/flag-checks/count", + Path = "flag-checks/count", Query = _query } ); @@ -357,17 +361,17 @@ GetLatestFlagChecksRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/flag-checks/latest", + Path = "flag-checks/latest", Query = _query } ); @@ -396,17 +400,17 @@ public async Task ListFlagsAsync(ListFlagsRequest request) } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/flags", + Path = "flags", Query = _query } ); @@ -421,10 +425,10 @@ public async Task ListFlagsAsync(ListFlagsRequest request) public async Task CreateFlagAsync(CreateFlagRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/flags", + Path = "flags", Body = request } ); @@ -439,7 +443,7 @@ public async Task CreateFlagAsync(CreateFlagRequestBody requ public async Task GetFlagAsync(string flagId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Get, Path = $"/flags/{flagId}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"flags/{flagId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -455,10 +459,10 @@ CreateFlagRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/flags/{flagId}", + Path = $"flags/{flagId}", Body = request } ); @@ -473,7 +477,7 @@ CreateFlagRequestBody request public async Task DeleteFlagAsync(string flagId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Delete, Path = $"/flags/{flagId}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Delete, Path = $"flags/{flagId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -489,10 +493,10 @@ UpdateFlagRulesRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/flags/{flagId}/rules", + Path = $"flags/{flagId}/rules", Body = request } ); @@ -507,10 +511,10 @@ UpdateFlagRulesRequestBody request public async Task CheckFlagAsync(string key, CheckFlagRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = $"/flags/{key}/check", + Path = $"flags/{key}/check", Body = request } ); @@ -525,10 +529,10 @@ public async Task CheckFlagAsync(string key, CheckFlagRequest public async Task CheckFlagsAsync(CheckFlagRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/flags/check", + Path = "flags/check", Body = request } ); @@ -557,17 +561,17 @@ public async Task CountFlagsAsync(CountFlagsRequest request) } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/flags/count", + Path = "flags/count", Query = _query } ); diff --git a/src/SchematicHQ.Client/Features/Requests/UpdateFlagRulesRequestBody.cs b/src/SchematicHQ.Client/Features/Requests/UpdateFlagRulesRequestBody.cs index ae1e49c..f8c7da3 100644 --- a/src/SchematicHQ.Client/Features/Requests/UpdateFlagRulesRequestBody.cs +++ b/src/SchematicHQ.Client/Features/Requests/UpdateFlagRulesRequestBody.cs @@ -8,5 +8,5 @@ namespace SchematicHQ.Client; public class UpdateFlagRulesRequestBody { [JsonPropertyName("rules")] - public List Rules { get; init; } + public IEnumerable Rules { get; init; } } diff --git a/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs b/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs index 91e41d8..8bf62a2 100644 --- a/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs +++ b/src/SchematicHQ.Client/Features/Types/CountFeaturesParams.cs @@ -7,7 +7,7 @@ namespace SchematicHQ.Client; public class CountFeaturesParams { [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Features/Types/CountFlagChecksParams.cs b/src/SchematicHQ.Client/Features/Types/CountFlagChecksParams.cs index 87f96fa..fb364c6 100644 --- a/src/SchematicHQ.Client/Features/Types/CountFlagChecksParams.cs +++ b/src/SchematicHQ.Client/Features/Types/CountFlagChecksParams.cs @@ -10,7 +10,7 @@ public class CountFlagChecksParams public string? FlagId { get; init; } [JsonPropertyName("flag_ids")] - public List? FlagIds { get; init; } + public IEnumerable? FlagIds { get; init; } [JsonPropertyName("id")] public string? Id { get; init; } diff --git a/src/SchematicHQ.Client/Features/Types/CountFlagsParams.cs b/src/SchematicHQ.Client/Features/Types/CountFlagsParams.cs index a391233..43082b8 100644 --- a/src/SchematicHQ.Client/Features/Types/CountFlagsParams.cs +++ b/src/SchematicHQ.Client/Features/Types/CountFlagsParams.cs @@ -10,7 +10,7 @@ public class CountFlagsParams public string? FeatureId { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Features/Types/GetLatestFlagChecksParams.cs b/src/SchematicHQ.Client/Features/Types/GetLatestFlagChecksParams.cs index 79a17ec..79608f5 100644 --- a/src/SchematicHQ.Client/Features/Types/GetLatestFlagChecksParams.cs +++ b/src/SchematicHQ.Client/Features/Types/GetLatestFlagChecksParams.cs @@ -10,7 +10,7 @@ public class GetLatestFlagChecksParams public string? FlagId { get; init; } [JsonPropertyName("flag_ids")] - public List? FlagIds { get; init; } + public IEnumerable? FlagIds { get; init; } [JsonPropertyName("id")] public string? Id { get; init; } diff --git a/src/SchematicHQ.Client/Features/Types/GetLatestFlagChecksResponse.cs b/src/SchematicHQ.Client/Features/Types/GetLatestFlagChecksResponse.cs index a82a0c1..6f80fe2 100644 --- a/src/SchematicHQ.Client/Features/Types/GetLatestFlagChecksResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/GetLatestFlagChecksResponse.cs @@ -11,7 +11,7 @@ public class GetLatestFlagChecksResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Features/Types/ListAudienceCompaniesResponse.cs b/src/SchematicHQ.Client/Features/Types/ListAudienceCompaniesResponse.cs index 9235abe..cb6a047 100644 --- a/src/SchematicHQ.Client/Features/Types/ListAudienceCompaniesResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/ListAudienceCompaniesResponse.cs @@ -11,7 +11,7 @@ public class ListAudienceCompaniesResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Features/Types/ListAudienceUsersResponse.cs b/src/SchematicHQ.Client/Features/Types/ListAudienceUsersResponse.cs index 0d94c9c..238dcf7 100644 --- a/src/SchematicHQ.Client/Features/Types/ListAudienceUsersResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/ListAudienceUsersResponse.cs @@ -11,7 +11,7 @@ public class ListAudienceUsersResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs b/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs index eb778f3..d6564cf 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFeaturesParams.cs @@ -7,7 +7,7 @@ namespace SchematicHQ.Client; public class ListFeaturesParams { [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Features/Types/ListFeaturesResponse.cs b/src/SchematicHQ.Client/Features/Types/ListFeaturesResponse.cs index dcd678a..7862884 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFeaturesResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFeaturesResponse.cs @@ -11,7 +11,7 @@ public class ListFeaturesResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Features/Types/ListFlagChecksParams.cs b/src/SchematicHQ.Client/Features/Types/ListFlagChecksParams.cs index 31f1f37..e83d6ee 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFlagChecksParams.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFlagChecksParams.cs @@ -10,7 +10,7 @@ public class ListFlagChecksParams public string? FlagId { get; init; } [JsonPropertyName("flag_ids")] - public List? FlagIds { get; init; } + public IEnumerable? FlagIds { get; init; } [JsonPropertyName("id")] public string? Id { get; init; } diff --git a/src/SchematicHQ.Client/Features/Types/ListFlagChecksResponse.cs b/src/SchematicHQ.Client/Features/Types/ListFlagChecksResponse.cs index 3723d93..554ab6f 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFlagChecksResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFlagChecksResponse.cs @@ -11,7 +11,7 @@ public class ListFlagChecksResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Features/Types/ListFlagsParams.cs b/src/SchematicHQ.Client/Features/Types/ListFlagsParams.cs index c6b09d3..9421197 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFlagsParams.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFlagsParams.cs @@ -10,7 +10,7 @@ public class ListFlagsParams public string? FeatureId { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Features/Types/ListFlagsResponse.cs b/src/SchematicHQ.Client/Features/Types/ListFlagsResponse.cs index 13d28ed..9c73672 100644 --- a/src/SchematicHQ.Client/Features/Types/ListFlagsResponse.cs +++ b/src/SchematicHQ.Client/Features/Types/ListFlagsResponse.cs @@ -11,7 +11,7 @@ public class ListFlagsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Plans/PlansClient.cs b/src/SchematicHQ.Client/Plans/PlansClient.cs index 33181a5..58e67e5 100644 --- a/src/SchematicHQ.Client/Plans/PlansClient.cs +++ b/src/SchematicHQ.Client/Plans/PlansClient.cs @@ -17,10 +17,10 @@ public PlansClient(RawClient client) public async Task GetAudienceAsync(string planAudienceId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = $"/plan-audiences/{planAudienceId}" + Path = $"plan-audiences/{planAudienceId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -37,10 +37,10 @@ UpdateAudienceRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/plan-audiences/{planAudienceId}", + Path = $"plan-audiences/{planAudienceId}", Body = request } ); @@ -55,10 +55,10 @@ UpdateAudienceRequestBody request public async Task DeleteAudienceAsync(string planAudienceId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Delete, - Path = $"/plan-audiences/{planAudienceId}" + Path = $"plan-audiences/{planAudienceId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -90,17 +90,17 @@ public async Task ListPlansAsync(ListPlansRequest request) } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/plans", + Path = "plans", Query = _query } ); @@ -115,10 +115,10 @@ public async Task ListPlansAsync(ListPlansRequest request) public async Task CreatePlanAsync(CreatePlanRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/plans", + Path = "plans", Body = request } ); @@ -133,7 +133,7 @@ public async Task CreatePlanAsync(CreatePlanRequestBody requ public async Task GetPlanAsync(string planId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Get, Path = $"/plans/{planId}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"plans/{planId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -149,10 +149,10 @@ UpdatePlanRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/plans/{planId}", + Path = $"plans/{planId}", Body = request } ); @@ -167,7 +167,7 @@ UpdatePlanRequestBody request public async Task DeletePlanAsync(string planId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Delete, Path = $"/plans/{planId}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Delete, Path = $"plans/{planId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -198,17 +198,17 @@ public async Task CountPlansAsync(CountPlansRequest request) } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/plans/count", + Path = "plans/count", Query = _query } ); diff --git a/src/SchematicHQ.Client/Plans/Requests/UpdateAudienceRequestBody.cs b/src/SchematicHQ.Client/Plans/Requests/UpdateAudienceRequestBody.cs index 8bc33f9..14b53f4 100644 --- a/src/SchematicHQ.Client/Plans/Requests/UpdateAudienceRequestBody.cs +++ b/src/SchematicHQ.Client/Plans/Requests/UpdateAudienceRequestBody.cs @@ -8,8 +8,8 @@ namespace SchematicHQ.Client; public class UpdateAudienceRequestBody { [JsonPropertyName("condition_groups")] - public List ConditionGroups { get; init; } + public IEnumerable ConditionGroups { get; init; } [JsonPropertyName("conditions")] - public List Conditions { get; init; } + public IEnumerable Conditions { get; init; } } diff --git a/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs b/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs index 4e048ff..085e4ce 100644 --- a/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs +++ b/src/SchematicHQ.Client/Plans/Types/CountPlansParams.cs @@ -10,7 +10,7 @@ public class CountPlansParams public string? CompanyId { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs b/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs index b1ab0be..18a3fb1 100644 --- a/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs +++ b/src/SchematicHQ.Client/Plans/Types/ListPlansParams.cs @@ -10,7 +10,7 @@ public class ListPlansParams public string? CompanyId { get; init; } [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Plans/Types/ListPlansResponse.cs b/src/SchematicHQ.Client/Plans/Types/ListPlansResponse.cs index a2404ff..707ae36 100644 --- a/src/SchematicHQ.Client/Plans/Types/ListPlansResponse.cs +++ b/src/SchematicHQ.Client/Plans/Types/ListPlansResponse.cs @@ -11,7 +11,7 @@ public class ListPlansResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Schematic.cs b/src/SchematicHQ.Client/Schematic.cs index cc58eaa..2cdab4b 100644 --- a/src/SchematicHQ.Client/Schematic.cs +++ b/src/SchematicHQ.Client/Schematic.cs @@ -27,7 +27,7 @@ public Schematic(string apiKey, ClientOptions? options = null) API = new SchematicApi(apiKey, _options.WithHttpClient(httpClient)); _eventBuffer = _options.EventBuffer ?? new EventBuffer( - async items => + async items => { var request = new CreateEventBatchRequestBody { @@ -53,7 +53,7 @@ public void Shutdown() public async Task CheckFlag(string flagKey, Dictionary? company = null, Dictionary? user = null) { - + if (_offline) return GetFlagDefault(flagKey); @@ -80,13 +80,11 @@ public async Task CheckFlag(string flagKey, Dictionary? co Company = company, User = user }; - + var response = await API.Features.CheckFlagAsync(flagKey, requestBody); - - - + if (response == null){ - + return GetFlagDefault(flagKey); } @@ -105,7 +103,7 @@ public async Task CheckFlag(string flagKey, Dictionary? co } } - public void Identify(Dictionary keys, EventBodyIdentifyCompany? company = null, string? name = null, Dictionary>>? traits = null) + public void Identify(Dictionary keys, EventBodyIdentifyCompany? company = null, string? name = null, Dictionary? traits = null) { EnqueueEvent(CreateEventRequestBodyEventType.Identify, new EventBodyIdentify { @@ -116,7 +114,7 @@ public void Identify(Dictionary keys, EventBodyIdentifyCompany? }); } - public void Track(string eventName, Dictionary? company = null, Dictionary? user = null, Dictionary>>? traits = null) + public void Track(string eventName, Dictionary? company = null, Dictionary? user = null, Dictionary? traits = null) { EnqueueEvent(CreateEventRequestBodyEventType.Track, new EventBodyTrack { @@ -170,4 +168,4 @@ public override HttpResponseMessage Send(HttpRequestMessage request, System.Thre }; return response; } -} \ No newline at end of file +} diff --git a/src/SchematicHQ.Client/SchematicApi.cs b/src/SchematicHQ.Client/SchematicApi.cs index cf727e7..a461edf 100644 --- a/src/SchematicHQ.Client/SchematicApi.cs +++ b/src/SchematicHQ.Client/SchematicApi.cs @@ -16,7 +16,7 @@ public SchematicApi(string apiKey = null, ClientOptions clientOptions = null) { "X-Schematic-Api-Key", apiKey }, { "X-Fern-Language", "C#" }, { "X-Fern-SDK-Name", "SchematicHQ.Client" }, - { "X-Fern-SDK-Version", "1.0.0-rc" }, + { "X-Fern-SDK-Version", "0.0.15" }, }, clientOptions ?? new ClientOptions() ); @@ -51,7 +51,7 @@ public SchematicApi(string apiKey = null, ClientOptions clientOptions = null) private string GetFromEnvironmentOrThrow(string env, string message) { - var value = Environment.GetEnvironmentVariable(env); + var value = System.Environment.GetEnvironmentVariable(env); if (value == null) { throw new Exception(message); diff --git a/src/SchematicHQ.Client/SchematicHQ.Client.csproj b/src/SchematicHQ.Client/SchematicHQ.Client.csproj index 66c05cf..d066631 100644 --- a/src/SchematicHQ.Client/SchematicHQ.Client.csproj +++ b/src/SchematicHQ.Client/SchematicHQ.Client.csproj @@ -2,10 +2,10 @@ - net8.0;net7.0;net6.0 + net8.0;net7.0;net6.0; enable false - 1.0.0-rc + 0.0.15 README.md https://github.com/schematichq/schematic-csharp @@ -13,6 +13,8 @@ + + diff --git a/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs b/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs index bcebb3b..97520b9 100644 --- a/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs +++ b/src/SchematicHQ.Client/Types/ApiKeyCreateResponseData.cs @@ -25,7 +25,7 @@ public class ApiKeyCreateResponseData public string Name { get; init; } [JsonPropertyName("scopes")] - public List Scopes { get; init; } + public IEnumerable Scopes { get; init; } [JsonPropertyName("secret")] public string Secret { get; init; } diff --git a/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs b/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs index 11378c9..db4e0da 100644 --- a/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs +++ b/src/SchematicHQ.Client/Types/ApiKeyResponseData.cs @@ -25,7 +25,7 @@ public class ApiKeyResponseData public string Name { get; init; } [JsonPropertyName("scopes")] - public List Scopes { get; init; } + public IEnumerable Scopes { get; init; } [JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; init; } diff --git a/src/SchematicHQ.Client/Types/AudienceRequestBody.cs b/src/SchematicHQ.Client/Types/AudienceRequestBody.cs index 58cc607..b64c79e 100644 --- a/src/SchematicHQ.Client/Types/AudienceRequestBody.cs +++ b/src/SchematicHQ.Client/Types/AudienceRequestBody.cs @@ -8,10 +8,10 @@ namespace SchematicHQ.Client; public class AudienceRequestBody { [JsonPropertyName("condition_groups")] - public List ConditionGroups { get; init; } + public IEnumerable ConditionGroups { get; init; } [JsonPropertyName("conditions")] - public List Conditions { get; init; } + public IEnumerable Conditions { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Types/CheckFlagsResponseData.cs b/src/SchematicHQ.Client/Types/CheckFlagsResponseData.cs index b0279ee..72d0bfa 100644 --- a/src/SchematicHQ.Client/Types/CheckFlagsResponseData.cs +++ b/src/SchematicHQ.Client/Types/CheckFlagsResponseData.cs @@ -8,5 +8,5 @@ namespace SchematicHQ.Client; public class CheckFlagsResponseData { [JsonPropertyName("flags")] - public List Flags { get; init; } + public IEnumerable Flags { get; init; } } diff --git a/src/SchematicHQ.Client/Types/CompanyCrmDealsResponseData.cs b/src/SchematicHQ.Client/Types/CompanyCrmDealsResponseData.cs index ea21a1e..829747e 100644 --- a/src/SchematicHQ.Client/Types/CompanyCrmDealsResponseData.cs +++ b/src/SchematicHQ.Client/Types/CompanyCrmDealsResponseData.cs @@ -20,5 +20,5 @@ public class CompanyCrmDealsResponseData public string? DealName { get; init; } [JsonPropertyName("line_items")] - public List LineItems { get; init; } + public IEnumerable LineItems { get; init; } } diff --git a/src/SchematicHQ.Client/Types/CompanyDetailResponseData.cs b/src/SchematicHQ.Client/Types/CompanyDetailResponseData.cs index 63ce0f9..6b039d7 100644 --- a/src/SchematicHQ.Client/Types/CompanyDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/CompanyDetailResponseData.cs @@ -11,7 +11,7 @@ public class CompanyDetailResponseData public DateTime CreatedAt { get; init; } [JsonPropertyName("entity_traits")] - public List EntityTraits { get; init; } + public IEnumerable EntityTraits { get; init; } [JsonPropertyName("environment_id")] public string EnvironmentId { get; init; } @@ -20,7 +20,7 @@ public class CompanyDetailResponseData public string Id { get; init; } [JsonPropertyName("keys")] - public List Keys { get; init; } + public IEnumerable Keys { get; init; } [JsonPropertyName("last_seen_at")] public DateTime? LastSeenAt { get; init; } @@ -32,7 +32,7 @@ public class CompanyDetailResponseData public string Name { get; init; } [JsonPropertyName("plans")] - public List Plans { get; init; } + public IEnumerable Plans { get; init; } /// /// A map of trait names to trait values diff --git a/src/SchematicHQ.Client/Types/CompanySubscriptionResponseData.cs b/src/SchematicHQ.Client/Types/CompanySubscriptionResponseData.cs index 4555f89..bcee8c3 100644 --- a/src/SchematicHQ.Client/Types/CompanySubscriptionResponseData.cs +++ b/src/SchematicHQ.Client/Types/CompanySubscriptionResponseData.cs @@ -17,7 +17,7 @@ public class CompanySubscriptionResponseData public string Interval { get; init; } [JsonPropertyName("products")] - public List Products { get; init; } + public IEnumerable Products { get; init; } [JsonPropertyName("subscription_external_id")] public string SubscriptionExternalId { get; init; } diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionGroupRequestBody.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionGroupRequestBody.cs index f715462..6dafb9f 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionGroupRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionGroupRequestBody.cs @@ -8,7 +8,7 @@ namespace SchematicHQ.Client; public class CreateOrUpdateConditionGroupRequestBody { [JsonPropertyName("conditions")] - public List Conditions { get; init; } + public IEnumerable Conditions { get; init; } [JsonPropertyName("flag_id")] public string? FlagId { get; init; } diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBody.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBody.cs index 86a4278..e90a1bf 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateConditionRequestBody.cs @@ -44,7 +44,7 @@ public class CreateOrUpdateConditionRequestBody /// List of resource IDs (companies, users, or plans) targeted by this condition /// [JsonPropertyName("resource_ids")] - public List ResourceIds { get; init; } + public IEnumerable ResourceIds { get; init; } /// /// ID of trait to use to measure this condition diff --git a/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBody.cs b/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBody.cs index 7ba8a3a..ae2fd29 100644 --- a/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBody.cs +++ b/src/SchematicHQ.Client/Types/CreateOrUpdateRuleRequestBody.cs @@ -8,10 +8,10 @@ namespace SchematicHQ.Client; public class CreateOrUpdateRuleRequestBody { [JsonPropertyName("condition_groups")] - public List ConditionGroups { get; init; } + public IEnumerable ConditionGroups { get; init; } [JsonPropertyName("conditions")] - public List Conditions { get; init; } + public IEnumerable Conditions { get; init; } [JsonPropertyName("id")] public string? Id { get; init; } diff --git a/src/SchematicHQ.Client/Types/EntityTraitDefinitionResponseData.cs b/src/SchematicHQ.Client/Types/EntityTraitDefinitionResponseData.cs index f061598..d63e617 100644 --- a/src/SchematicHQ.Client/Types/EntityTraitDefinitionResponseData.cs +++ b/src/SchematicHQ.Client/Types/EntityTraitDefinitionResponseData.cs @@ -16,7 +16,7 @@ public class EntityTraitDefinitionResponseData public string EntityType { get; init; } [JsonPropertyName("hierarchy")] - public List Hierarchy { get; init; } + public IEnumerable Hierarchy { get; init; } [JsonPropertyName("id")] public string Id { get; init; } diff --git a/src/SchematicHQ.Client/Types/EnvironmentDetailResponseData.cs b/src/SchematicHQ.Client/Types/EnvironmentDetailResponseData.cs index ec75873..d76f82f 100644 --- a/src/SchematicHQ.Client/Types/EnvironmentDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/EnvironmentDetailResponseData.cs @@ -8,7 +8,7 @@ namespace SchematicHQ.Client; public class EnvironmentDetailResponseData { [JsonPropertyName("api_keys")] - public List ApiKeys { get; init; } + public IEnumerable ApiKeys { get; init; } [JsonPropertyName("created_at")] public DateTime CreatedAt { get; init; } diff --git a/src/SchematicHQ.Client/Types/EventBodyIdentify.cs b/src/SchematicHQ.Client/Types/EventBodyIdentify.cs index ae4cdfa..d901b7b 100644 --- a/src/SchematicHQ.Client/Types/EventBodyIdentify.cs +++ b/src/SchematicHQ.Client/Types/EventBodyIdentify.cs @@ -1,5 +1,4 @@ using System.Text.Json.Serialization; -using OneOf; using SchematicHQ.Client; #nullable enable @@ -30,8 +29,5 @@ public class EventBodyIdentify /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary< - string, - OneOf> - >? Traits { get; init; } + public Dictionary? Traits { get; init; } } diff --git a/src/SchematicHQ.Client/Types/EventBodyIdentifyCompany.cs b/src/SchematicHQ.Client/Types/EventBodyIdentifyCompany.cs index eb032d2..5ad366b 100644 --- a/src/SchematicHQ.Client/Types/EventBodyIdentifyCompany.cs +++ b/src/SchematicHQ.Client/Types/EventBodyIdentifyCompany.cs @@ -1,5 +1,4 @@ using System.Text.Json.Serialization; -using OneOf; #nullable enable @@ -23,8 +22,5 @@ public class EventBodyIdentifyCompany /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary< - string, - OneOf> - >? Traits { get; init; } + public Dictionary? Traits { get; init; } } diff --git a/src/SchematicHQ.Client/Types/EventBodyTrack.cs b/src/SchematicHQ.Client/Types/EventBodyTrack.cs index d74b62e..9a33c89 100644 --- a/src/SchematicHQ.Client/Types/EventBodyTrack.cs +++ b/src/SchematicHQ.Client/Types/EventBodyTrack.cs @@ -1,5 +1,4 @@ using System.Text.Json.Serialization; -using OneOf; #nullable enable @@ -23,10 +22,7 @@ public class EventBodyTrack /// A map of trait names to trait values /// [JsonPropertyName("traits")] - public Dictionary< - string, - OneOf> - >? Traits { get; init; } + public Dictionary? Traits { get; init; } /// /// Key-value pairs to identify user associated with track event diff --git a/src/SchematicHQ.Client/Types/EventDetailResponseData.cs b/src/SchematicHQ.Client/Types/EventDetailResponseData.cs index 0c354aa..b7e31f7 100644 --- a/src/SchematicHQ.Client/Types/EventDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/EventDetailResponseData.cs @@ -1,5 +1,4 @@ using System.Text.Json.Serialization; -using OneOf; using SchematicHQ.Client; #nullable enable @@ -12,10 +11,7 @@ public class EventDetailResponseData public string? ApiKey { get; init; } [JsonPropertyName("body")] - public Dictionary< - string, - OneOf> - > Body { get; init; } + public Dictionary Body { get; init; } [JsonPropertyName("body_preview")] public string BodyPreview { get; init; } @@ -39,10 +35,10 @@ public Dictionary< public string? ErrorMessage { get; init; } [JsonPropertyName("feature_ids")] - public List FeatureIds { get; init; } + public IEnumerable FeatureIds { get; init; } [JsonPropertyName("features")] - public List Features { get; init; } + public IEnumerable Features { get; init; } [JsonPropertyName("id")] public string Id { get; init; } diff --git a/src/SchematicHQ.Client/Types/EventResponseData.cs b/src/SchematicHQ.Client/Types/EventResponseData.cs index 2fa0c1e..d24d695 100644 --- a/src/SchematicHQ.Client/Types/EventResponseData.cs +++ b/src/SchematicHQ.Client/Types/EventResponseData.cs @@ -1,5 +1,4 @@ using System.Text.Json.Serialization; -using OneOf; #nullable enable @@ -11,10 +10,7 @@ public class EventResponseData public string? ApiKey { get; init; } [JsonPropertyName("body")] - public Dictionary< - string, - OneOf> - > Body { get; init; } + public Dictionary Body { get; init; } [JsonPropertyName("body_preview")] public string BodyPreview { get; init; } @@ -35,7 +31,7 @@ public Dictionary< public string? ErrorMessage { get; init; } [JsonPropertyName("feature_ids")] - public List FeatureIds { get; init; } + public IEnumerable FeatureIds { get; init; } [JsonPropertyName("id")] public string Id { get; init; } diff --git a/src/SchematicHQ.Client/Types/FeatureDetailResponseData.cs b/src/SchematicHQ.Client/Types/FeatureDetailResponseData.cs index 2704048..965d911 100644 --- a/src/SchematicHQ.Client/Types/FeatureDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/FeatureDetailResponseData.cs @@ -23,7 +23,7 @@ public class FeatureDetailResponseData public string FeatureType { get; init; } [JsonPropertyName("flags")] - public List Flags { get; init; } + public IEnumerable Flags { get; init; } [JsonPropertyName("id")] public string Id { get; init; } @@ -35,7 +35,7 @@ public class FeatureDetailResponseData public string Name { get; init; } [JsonPropertyName("plans")] - public List Plans { get; init; } + public IEnumerable Plans { get; init; } [JsonPropertyName("trait")] public EntityTraitDefinitionResponseData? Trait { get; init; } diff --git a/src/SchematicHQ.Client/Types/FeatureUsageDetailResponseData.cs b/src/SchematicHQ.Client/Types/FeatureUsageDetailResponseData.cs index c1b4206..2324545 100644 --- a/src/SchematicHQ.Client/Types/FeatureUsageDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/FeatureUsageDetailResponseData.cs @@ -8,5 +8,5 @@ namespace SchematicHQ.Client; public class FeatureUsageDetailResponseData { [JsonPropertyName("features")] - public List Features { get; init; } + public IEnumerable Features { get; init; } } diff --git a/src/SchematicHQ.Client/Types/FlagDetailResponseData.cs b/src/SchematicHQ.Client/Types/FlagDetailResponseData.cs index 1908371..0d5882a 100644 --- a/src/SchematicHQ.Client/Types/FlagDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/FlagDetailResponseData.cs @@ -38,7 +38,7 @@ public class FlagDetailResponseData public string Name { get; init; } [JsonPropertyName("rules")] - public List Rules { get; init; } + public IEnumerable Rules { get; init; } [JsonPropertyName("updated_at")] public DateTime UpdatedAt { get; init; } diff --git a/src/SchematicHQ.Client/Types/PlanAudienceDetailResponseData.cs b/src/SchematicHQ.Client/Types/PlanAudienceDetailResponseData.cs index e5d0002..d908afe 100644 --- a/src/SchematicHQ.Client/Types/PlanAudienceDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/PlanAudienceDetailResponseData.cs @@ -8,10 +8,10 @@ namespace SchematicHQ.Client; public class PlanAudienceDetailResponseData { [JsonPropertyName("condition_groups")] - public List ConditionGroups { get; init; } + public IEnumerable ConditionGroups { get; init; } [JsonPropertyName("conditions")] - public List Conditions { get; init; } + public IEnumerable Conditions { get; init; } [JsonPropertyName("created_at")] public DateTime CreatedAt { get; init; } diff --git a/src/SchematicHQ.Client/Types/PlanDetailResponseData.cs b/src/SchematicHQ.Client/Types/PlanDetailResponseData.cs index 60d92c2..e152d6f 100644 --- a/src/SchematicHQ.Client/Types/PlanDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/PlanDetailResponseData.cs @@ -17,7 +17,7 @@ public class PlanDetailResponseData public string Description { get; init; } [JsonPropertyName("features")] - public List Features { get; init; } + public IEnumerable Features { get; init; } [JsonPropertyName("id")] public string Id { get; init; } diff --git a/src/SchematicHQ.Client/Types/RawEventBatchResponseData.cs b/src/SchematicHQ.Client/Types/RawEventBatchResponseData.cs index 9c2eb86..12d8a2a 100644 --- a/src/SchematicHQ.Client/Types/RawEventBatchResponseData.cs +++ b/src/SchematicHQ.Client/Types/RawEventBatchResponseData.cs @@ -8,5 +8,5 @@ namespace SchematicHQ.Client; public class RawEventBatchResponseData { [JsonPropertyName("events")] - public List Events { get; init; } + public IEnumerable Events { get; init; } } diff --git a/src/SchematicHQ.Client/Types/RuleConditionDetailResponseData.cs b/src/SchematicHQ.Client/Types/RuleConditionDetailResponseData.cs index 38d4c27..3568159 100644 --- a/src/SchematicHQ.Client/Types/RuleConditionDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/RuleConditionDetailResponseData.cs @@ -47,10 +47,10 @@ public class RuleConditionDetailResponseData public string? PlanId { get; init; } [JsonPropertyName("resource_ids")] - public List ResourceIds { get; init; } + public IEnumerable ResourceIds { get; init; } [JsonPropertyName("resources")] - public List Resources { get; init; } + public IEnumerable Resources { get; init; } [JsonPropertyName("rule_id")] public string RuleId { get; init; } diff --git a/src/SchematicHQ.Client/Types/RuleConditionGroupDetailResponseData.cs b/src/SchematicHQ.Client/Types/RuleConditionGroupDetailResponseData.cs index 77ba5b1..e5a7281 100644 --- a/src/SchematicHQ.Client/Types/RuleConditionGroupDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/RuleConditionGroupDetailResponseData.cs @@ -8,7 +8,7 @@ namespace SchematicHQ.Client; public class RuleConditionGroupDetailResponseData { [JsonPropertyName("conditions")] - public List Conditions { get; init; } + public IEnumerable Conditions { get; init; } [JsonPropertyName("created_at")] public DateTime CreatedAt { get; init; } diff --git a/src/SchematicHQ.Client/Types/RuleConditionResponseData.cs b/src/SchematicHQ.Client/Types/RuleConditionResponseData.cs index a10ecc3..61eb1a4 100644 --- a/src/SchematicHQ.Client/Types/RuleConditionResponseData.cs +++ b/src/SchematicHQ.Client/Types/RuleConditionResponseData.cs @@ -43,7 +43,7 @@ public class RuleConditionResponseData public string? PlanId { get; init; } [JsonPropertyName("resource_ids")] - public List ResourceIds { get; init; } + public IEnumerable ResourceIds { get; init; } [JsonPropertyName("rule_id")] public string RuleId { get; init; } diff --git a/src/SchematicHQ.Client/Types/RuleDetailResponseData.cs b/src/SchematicHQ.Client/Types/RuleDetailResponseData.cs index 3b2476b..95d7992 100644 --- a/src/SchematicHQ.Client/Types/RuleDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/RuleDetailResponseData.cs @@ -8,10 +8,10 @@ namespace SchematicHQ.Client; public class RuleDetailResponseData { [JsonPropertyName("condition_groups")] - public List ConditionGroups { get; init; } + public IEnumerable ConditionGroups { get; init; } [JsonPropertyName("conditions")] - public List Conditions { get; init; } + public IEnumerable Conditions { get; init; } [JsonPropertyName("created_at")] public DateTime CreatedAt { get; init; } diff --git a/src/SchematicHQ.Client/Types/RulesDetailResponseData.cs b/src/SchematicHQ.Client/Types/RulesDetailResponseData.cs index 6b98d37..b168869 100644 --- a/src/SchematicHQ.Client/Types/RulesDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/RulesDetailResponseData.cs @@ -11,5 +11,5 @@ public class RulesDetailResponseData public FlagResponseData? Flag { get; init; } [JsonPropertyName("rules")] - public List Rules { get; init; } + public IEnumerable Rules { get; init; } } diff --git a/src/SchematicHQ.Client/Types/UpdateRuleRequestBody.cs b/src/SchematicHQ.Client/Types/UpdateRuleRequestBody.cs index 96609b8..9111c11 100644 --- a/src/SchematicHQ.Client/Types/UpdateRuleRequestBody.cs +++ b/src/SchematicHQ.Client/Types/UpdateRuleRequestBody.cs @@ -8,10 +8,10 @@ namespace SchematicHQ.Client; public class UpdateRuleRequestBody { [JsonPropertyName("condition_groups")] - public List ConditionGroups { get; init; } + public IEnumerable ConditionGroups { get; init; } [JsonPropertyName("conditions")] - public List Conditions { get; init; } + public IEnumerable Conditions { get; init; } [JsonPropertyName("name")] public string Name { get; init; } diff --git a/src/SchematicHQ.Client/Types/UserDetailResponseData.cs b/src/SchematicHQ.Client/Types/UserDetailResponseData.cs index 4c6fc19..7d93a07 100644 --- a/src/SchematicHQ.Client/Types/UserDetailResponseData.cs +++ b/src/SchematicHQ.Client/Types/UserDetailResponseData.cs @@ -8,13 +8,13 @@ namespace SchematicHQ.Client; public class UserDetailResponseData { [JsonPropertyName("company_memberships")] - public List CompanyMemberships { get; init; } + public IEnumerable CompanyMemberships { get; init; } [JsonPropertyName("created_at")] public DateTime CreatedAt { get; init; } [JsonPropertyName("entity_traits")] - public List EntityTraits { get; init; } + public IEnumerable EntityTraits { get; init; } [JsonPropertyName("environment_id")] public string EnvironmentId { get; init; } @@ -23,7 +23,7 @@ public class UserDetailResponseData public string Id { get; init; } [JsonPropertyName("keys")] - public List Keys { get; init; } + public IEnumerable Keys { get; init; } [JsonPropertyName("last_seen_at")] public DateTime? LastSeenAt { get; init; } diff --git a/src/SchematicHQ.Client/Types/WebhookResponseData.cs b/src/SchematicHQ.Client/Types/WebhookResponseData.cs index 5aa7d41..89f4860 100644 --- a/src/SchematicHQ.Client/Types/WebhookResponseData.cs +++ b/src/SchematicHQ.Client/Types/WebhookResponseData.cs @@ -16,7 +16,7 @@ public class WebhookResponseData public string Name { get; init; } [JsonPropertyName("request_types")] - public List RequestTypes { get; init; } + public IEnumerable RequestTypes { get; init; } [JsonPropertyName("status")] public string Status { get; init; } diff --git a/src/SchematicHQ.Client/Webhooks/Requests/CreateWebhookRequestBody.cs b/src/SchematicHQ.Client/Webhooks/Requests/CreateWebhookRequestBody.cs index 21eb6a9..624f126 100644 --- a/src/SchematicHQ.Client/Webhooks/Requests/CreateWebhookRequestBody.cs +++ b/src/SchematicHQ.Client/Webhooks/Requests/CreateWebhookRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client; #nullable enable @@ -10,7 +11,7 @@ public class CreateWebhookRequestBody public string Name { get; init; } [JsonPropertyName("request_types")] - public List RequestTypes { get; init; } + public IEnumerable RequestTypes { get; init; } [JsonPropertyName("url")] public string Url { get; init; } diff --git a/src/SchematicHQ.Client/Webhooks/Requests/UpdateWebhookRequestBody.cs b/src/SchematicHQ.Client/Webhooks/Requests/UpdateWebhookRequestBody.cs index ca948dd..da73c86 100644 --- a/src/SchematicHQ.Client/Webhooks/Requests/UpdateWebhookRequestBody.cs +++ b/src/SchematicHQ.Client/Webhooks/Requests/UpdateWebhookRequestBody.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SchematicHQ.Client; #nullable enable @@ -10,7 +11,7 @@ public class UpdateWebhookRequestBody public string? Name { get; init; } [JsonPropertyName("request_types")] - public List? RequestTypes { get; init; } + public IEnumerable? RequestTypes { get; init; } [JsonPropertyName("url")] public string? Url { get; init; } diff --git a/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsParams.cs b/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsParams.cs index 0cf6012..297dbd9 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsParams.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/CountWebhookEventsParams.cs @@ -7,7 +7,7 @@ namespace SchematicHQ.Client; public class CountWebhookEventsParams { [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookRequestBodyRequestTypesItem.cs b/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookRequestBodyRequestTypesItem.cs new file mode 100644 index 0000000..270eda3 --- /dev/null +++ b/src/SchematicHQ.Client/Webhooks/Types/CreateWebhookRequestBodyRequestTypesItem.cs @@ -0,0 +1,81 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum CreateWebhookRequestBodyRequestTypesItem +{ + [EnumMember(Value = "company.updated")] + CompanyUpdated, + + [EnumMember(Value = "user.updated")] + UserUpdated, + + [EnumMember(Value = "plan.updated")] + PlanUpdated, + + [EnumMember(Value = "plan.entitlement.updated")] + PlanEntitlementUpdated, + + [EnumMember(Value = "company.override.updated")] + CompanyOverrideUpdated, + + [EnumMember(Value = "feature.updated")] + FeatureUpdated, + + [EnumMember(Value = "flag.updated")] + FlagUpdated, + + [EnumMember(Value = "flag_rules.updated")] + FlagRulesUpdated, + + [EnumMember(Value = "company.created")] + CompanyCreated, + + [EnumMember(Value = "user.created")] + UserCreated, + + [EnumMember(Value = "plan.created")] + PlanCreated, + + [EnumMember(Value = "plan.entitlement.created")] + PlanEntitlementCreated, + + [EnumMember(Value = "company.override.created")] + CompanyOverrideCreated, + + [EnumMember(Value = "feature.created")] + FeatureCreated, + + [EnumMember(Value = "flag.created")] + FlagCreated, + + [EnumMember(Value = "company.deleted")] + CompanyDeleted, + + [EnumMember(Value = "user.deleted")] + UserDeleted, + + [EnumMember(Value = "plan.deleted")] + PlanDeleted, + + [EnumMember(Value = "plan.entitlement.deleted")] + PlanEntitlementDeleted, + + [EnumMember(Value = "company.override.deleted")] + CompanyOverrideDeleted, + + [EnumMember(Value = "feature.deleted")] + FeatureDeleted, + + [EnumMember(Value = "flag.deleted")] + FlagDeleted, + + [EnumMember(Value = "test.send")] + TestSend +} diff --git a/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsParams.cs b/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsParams.cs index eb69e12..e8c05c1 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsParams.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsParams.cs @@ -7,7 +7,7 @@ namespace SchematicHQ.Client; public class ListWebhookEventsParams { [JsonPropertyName("ids")] - public List? Ids { get; init; } + public IEnumerable? Ids { get; init; } /// /// Page limit (default 100) diff --git a/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsResponse.cs index c1073cb..7c27bbf 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/ListWebhookEventsResponse.cs @@ -11,7 +11,7 @@ public class ListWebhookEventsResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksResponse.cs b/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksResponse.cs index cbc566e..f2a0055 100644 --- a/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksResponse.cs +++ b/src/SchematicHQ.Client/Webhooks/Types/ListWebhooksResponse.cs @@ -11,7 +11,7 @@ public class ListWebhooksResponse /// The returned resources /// [JsonPropertyName("data")] - public List Data { get; init; } + public IEnumerable Data { get; init; } /// /// Input parameters diff --git a/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyRequestTypesItem.cs b/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyRequestTypesItem.cs new file mode 100644 index 0000000..3e49ea2 --- /dev/null +++ b/src/SchematicHQ.Client/Webhooks/Types/UpdateWebhookRequestBodyRequestTypesItem.cs @@ -0,0 +1,81 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; +using SchematicHQ.Client; +using SchematicHQ.Client.Core; + +#nullable enable + +namespace SchematicHQ.Client; + +[JsonConverter(typeof(StringEnumSerializer))] +public enum UpdateWebhookRequestBodyRequestTypesItem +{ + [EnumMember(Value = "company.updated")] + CompanyUpdated, + + [EnumMember(Value = "user.updated")] + UserUpdated, + + [EnumMember(Value = "plan.updated")] + PlanUpdated, + + [EnumMember(Value = "plan.entitlement.updated")] + PlanEntitlementUpdated, + + [EnumMember(Value = "company.override.updated")] + CompanyOverrideUpdated, + + [EnumMember(Value = "feature.updated")] + FeatureUpdated, + + [EnumMember(Value = "flag.updated")] + FlagUpdated, + + [EnumMember(Value = "flag_rules.updated")] + FlagRulesUpdated, + + [EnumMember(Value = "company.created")] + CompanyCreated, + + [EnumMember(Value = "user.created")] + UserCreated, + + [EnumMember(Value = "plan.created")] + PlanCreated, + + [EnumMember(Value = "plan.entitlement.created")] + PlanEntitlementCreated, + + [EnumMember(Value = "company.override.created")] + CompanyOverrideCreated, + + [EnumMember(Value = "feature.created")] + FeatureCreated, + + [EnumMember(Value = "flag.created")] + FlagCreated, + + [EnumMember(Value = "company.deleted")] + CompanyDeleted, + + [EnumMember(Value = "user.deleted")] + UserDeleted, + + [EnumMember(Value = "plan.deleted")] + PlanDeleted, + + [EnumMember(Value = "plan.entitlement.deleted")] + PlanEntitlementDeleted, + + [EnumMember(Value = "company.override.deleted")] + CompanyOverrideDeleted, + + [EnumMember(Value = "feature.deleted")] + FeatureDeleted, + + [EnumMember(Value = "flag.deleted")] + FlagDeleted, + + [EnumMember(Value = "test.send")] + TestSend +} diff --git a/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs b/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs index a63945c..ba58c67 100644 --- a/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs +++ b/src/SchematicHQ.Client/Webhooks/WebhooksClient.cs @@ -33,17 +33,17 @@ ListWebhookEventsRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/webhook-events", + Path = "webhook-events", Query = _query } ); @@ -58,10 +58,10 @@ ListWebhookEventsRequest request public async Task GetWebhookEventAsync(string webhookEventId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = $"/webhook-events/{webhookEventId}" + Path = $"webhook-events/{webhookEventId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); @@ -91,17 +91,17 @@ CountWebhookEventsRequest request } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/webhook-events/count", + Path = "webhook-events/count", Query = _query } ); @@ -122,17 +122,17 @@ public async Task ListWebhooksAsync(ListWebhooksRequest re } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/webhooks", + Path = "webhooks", Query = _query } ); @@ -147,10 +147,10 @@ public async Task ListWebhooksAsync(ListWebhooksRequest re public async Task CreateWebhookAsync(CreateWebhookRequestBody request) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Post, - Path = "/webhooks", + Path = "webhooks", Body = request } ); @@ -165,7 +165,7 @@ public async Task CreateWebhookAsync(CreateWebhookRequest public async Task GetWebhookAsync(string webhookId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Get, Path = $"/webhooks/{webhookId}" } + new RawClient.JsonApiRequest { Method = HttpMethod.Get, Path = $"webhooks/{webhookId}" } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -181,10 +181,10 @@ UpdateWebhookRequestBody request ) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Put, - Path = $"/webhooks/{webhookId}", + Path = $"webhooks/{webhookId}", Body = request } ); @@ -199,7 +199,11 @@ UpdateWebhookRequestBody request public async Task DeleteWebhookAsync(string webhookId) { var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest { Method = HttpMethod.Delete, Path = $"/webhooks/{webhookId}" } + new RawClient.JsonApiRequest + { + Method = HttpMethod.Delete, + Path = $"webhooks/{webhookId}" + } ); string responseBody = await response.Raw.Content.ReadAsStringAsync(); if (response.StatusCode >= 200 && response.StatusCode < 400) @@ -218,17 +222,17 @@ public async Task CountWebhooksAsync(CountWebhooksRequest } if (request.Limit != null) { - _query["limit"] = request.Limit; + _query["limit"] = request.Limit.ToString(); } if (request.Offset != null) { - _query["offset"] = request.Offset; + _query["offset"] = request.Offset.ToString(); } var response = await _client.MakeRequestAsync( - new RawClient.ApiRequest + new RawClient.JsonApiRequest { Method = HttpMethod.Get, - Path = "/webhooks/count", + Path = "webhooks/count", Query = _query } );