Skip to content

Commit 48bcc78

Browse files
SDK regeneration (#43)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent fc0f30f commit 48bcc78

22 files changed

+1059
-25
lines changed

reference.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2360,6 +2360,7 @@ await client.Billing.CountBillingProductsAsync(new CountBillingProductsRequest()
23602360
await client.Billing.UpsertBillingSubscriptionAsync(
23612361
new CreateBillingSubscriptionsRequestBody
23622362
{
2363+
CancelAtPeriodEnd = true,
23632364
Currency = "currency",
23642365
CustomerExternalId = "customer_external_id",
23652366
Discounts = new List<BillingSubscriptionDiscount>()
@@ -2383,7 +2384,7 @@ await client.Billing.UpsertBillingSubscriptionAsync(
23832384
PriceExternalId = "price_external_id",
23842385
ProductExternalId = "product_external_id",
23852386
Quantity = 1,
2386-
UsageType = "usage_type",
2387+
UsageType = BillingProductPricingUsageType.Licensed,
23872388
},
23882389
},
23892390
SubscriptionExternalId = "subscription_external_id",
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using NUnit.Framework;
2+
using SchematicHQ.Client.Core;
3+
4+
namespace SchematicHQ.Client.Test.Core.Json;
5+
6+
[TestFixture]
7+
public class DateOnlyJsonTests
8+
{
9+
[Test]
10+
public void SerializeDateOnly_ShouldMatchExpectedFormat()
11+
{
12+
(DateOnly dateOnly, string expected)[] testCases =
13+
[
14+
(new DateOnly(2023, 10, 5), "\"2023-10-05\""),
15+
(new DateOnly(2023, 1, 1), "\"2023-01-01\""),
16+
(new DateOnly(2023, 12, 31), "\"2023-12-31\""),
17+
(new DateOnly(2023, 6, 15), "\"2023-06-15\""),
18+
(new DateOnly(2023, 3, 10), "\"2023-03-10\""),
19+
];
20+
foreach (var (dateOnly, expected) in testCases)
21+
{
22+
var json = JsonUtils.Serialize(dateOnly);
23+
Assert.That(json, Is.EqualTo(expected));
24+
}
25+
}
26+
27+
[Test]
28+
public void DeserializeDateOnly_ShouldMatchExpectedDateOnly()
29+
{
30+
(DateOnly expected, string json)[] testCases =
31+
[
32+
(new DateOnly(2023, 10, 5), "\"2023-10-05\""),
33+
(new DateOnly(2023, 1, 1), "\"2023-01-01\""),
34+
(new DateOnly(2023, 12, 31), "\"2023-12-31\""),
35+
(new DateOnly(2023, 6, 15), "\"2023-06-15\""),
36+
(new DateOnly(2023, 3, 10), "\"2023-03-10\""),
37+
];
38+
39+
foreach (var (expected, json) in testCases)
40+
{
41+
var dateOnly = JsonUtils.Deserialize<DateOnly>(json);
42+
Assert.That(dateOnly, Is.EqualTo(expected));
43+
}
44+
}
45+
46+
[Test]
47+
public void SerializeNullableDateOnly_ShouldMatchExpectedFormat()
48+
{
49+
(DateOnly? dateOnly, string expected)[] testCases =
50+
[
51+
(new DateOnly(2023, 10, 5), "\"2023-10-05\""),
52+
(null, "null"),
53+
];
54+
foreach (var (dateOnly, expected) in testCases)
55+
{
56+
var json = JsonUtils.Serialize(dateOnly);
57+
Assert.That(json, Is.EqualTo(expected));
58+
}
59+
}
60+
61+
[Test]
62+
public void DeserializeNullableDateOnly_ShouldMatchExpectedDateOnly()
63+
{
64+
(DateOnly? expected, string json)[] testCases =
65+
[
66+
(new DateOnly(2023, 10, 5), "\"2023-10-05\""),
67+
(null, "null"),
68+
];
69+
70+
foreach (var (expected, json) in testCases)
71+
{
72+
var dateOnly = JsonUtils.Deserialize<DateOnly?>(json);
73+
Assert.That(dateOnly, Is.EqualTo(expected));
74+
}
75+
}
76+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
using NUnit.Framework;
2+
using SchematicHQ.Client.Core;
3+
4+
namespace SchematicHQ.Client.Test.Core.Json;
5+
6+
[TestFixture]
7+
public class DateTimeJsonTests
8+
{
9+
[Test]
10+
public void SerializeDateTime_ShouldMatchExpectedFormat()
11+
{
12+
(DateTime dateTime, string expected)[] testCases =
13+
[
14+
(
15+
new DateTime(2023, 10, 5, 14, 30, 0, DateTimeKind.Utc),
16+
"\"2023-10-05T14:30:00.000Z\""
17+
),
18+
(new DateTime(2023, 1, 1, 0, 0, 0, DateTimeKind.Utc), "\"2023-01-01T00:00:00.000Z\""),
19+
(
20+
new DateTime(2023, 12, 31, 23, 59, 59, DateTimeKind.Utc),
21+
"\"2023-12-31T23:59:59.000Z\""
22+
),
23+
(new DateTime(2023, 6, 15, 12, 0, 0, DateTimeKind.Utc), "\"2023-06-15T12:00:00.000Z\""),
24+
(
25+
new DateTime(2023, 3, 10, 8, 45, 30, DateTimeKind.Utc),
26+
"\"2023-03-10T08:45:30.000Z\""
27+
),
28+
(
29+
new DateTime(2023, 3, 10, 8, 45, 30, 123, DateTimeKind.Utc),
30+
"\"2023-03-10T08:45:30.123Z\""
31+
),
32+
];
33+
foreach (var (dateTime, expected) in testCases)
34+
{
35+
var json = JsonUtils.Serialize(dateTime);
36+
Assert.That(json, Is.EqualTo(expected));
37+
}
38+
}
39+
40+
[Test]
41+
public void DeserializeDateTime_ShouldMatchExpectedDateTime()
42+
{
43+
(DateTime expected, string json)[] testCases =
44+
[
45+
(
46+
new DateTime(2023, 10, 5, 14, 30, 0, DateTimeKind.Utc),
47+
"\"2023-10-05T14:30:00.000Z\""
48+
),
49+
(new DateTime(2023, 1, 1, 0, 0, 0, DateTimeKind.Utc), "\"2023-01-01T00:00:00.000Z\""),
50+
(
51+
new DateTime(2023, 12, 31, 23, 59, 59, DateTimeKind.Utc),
52+
"\"2023-12-31T23:59:59.000Z\""
53+
),
54+
(new DateTime(2023, 6, 15, 12, 0, 0, DateTimeKind.Utc), "\"2023-06-15T12:00:00.000Z\""),
55+
(
56+
new DateTime(2023, 3, 10, 8, 45, 30, DateTimeKind.Utc),
57+
"\"2023-03-10T08:45:30.000Z\""
58+
),
59+
(new DateTime(2023, 3, 10, 8, 45, 30, DateTimeKind.Utc), "\"2023-03-10T08:45:30Z\""),
60+
(
61+
new DateTime(2023, 3, 10, 8, 45, 30, 123, DateTimeKind.Utc),
62+
"\"2023-03-10T08:45:30.123Z\""
63+
),
64+
];
65+
66+
foreach (var (expected, json) in testCases)
67+
{
68+
var dateTime = JsonUtils.Deserialize<DateTime>(json);
69+
Assert.That(dateTime, Is.EqualTo(expected));
70+
}
71+
}
72+
73+
[Test]
74+
public void SerializeNullableDateTime_ShouldMatchExpectedFormat()
75+
{
76+
(DateTime? expected, string json)[] testCases =
77+
[
78+
(
79+
new DateTime(2023, 10, 5, 14, 30, 0, DateTimeKind.Utc),
80+
"\"2023-10-05T14:30:00.000Z\""
81+
),
82+
(null, "null"),
83+
];
84+
85+
foreach (var (expected, json) in testCases)
86+
{
87+
var dateTime = JsonUtils.Deserialize<DateTime?>(json);
88+
Assert.That(dateTime, Is.EqualTo(expected));
89+
}
90+
}
91+
92+
[Test]
93+
public void DeserializeNullableDateTime_ShouldMatchExpectedDateTime()
94+
{
95+
(DateTime? expected, string json)[] testCases =
96+
[
97+
(
98+
new DateTime(2023, 10, 5, 14, 30, 0, DateTimeKind.Utc),
99+
"\"2023-10-05T14:30:00.000Z\""
100+
),
101+
(null, "null"),
102+
];
103+
104+
foreach (var (expected, json) in testCases)
105+
{
106+
var dateTime = JsonUtils.Deserialize<DateTime?>(json);
107+
Assert.That(dateTime, Is.EqualTo(expected));
108+
}
109+
}
110+
}

src/SchematicHQ.Client.Test/Core/EnumSerializerTests.cs renamed to src/SchematicHQ.Client.Test/Core/Json/EnumSerializerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using NUnit.Framework;
55
using SchematicHQ.Client.Core;
66

7-
namespace SchematicHQ.Client.Test.Core;
7+
namespace SchematicHQ.Client.Test.Core.Json;
88

99
[TestFixture]
1010
[Parallelizable(ParallelScope.All)]

src/SchematicHQ.Client.Test/SchematicHQ.Client.Test.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
<PrivateAssets>all</PrivateAssets>
1717
</PackageReference>
18-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
19-
<PackageReference Include="NUnit" Version="4.2.2" />
20-
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
18+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"/>
19+
<PackageReference Include="NUnit" Version="4.2.2"/>
20+
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
2121
<PackageReference Include="NUnit.Analyzers" Version="4.4.0">
2222
<PrivateAssets>all</PrivateAssets>
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -26,7 +26,6 @@
2626
<PrivateAssets>all</PrivateAssets>
2727
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2828
</PackageReference>
29-
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.6.0" />
3029
<PackageReference Include="WireMock.Net" Version="1.6.8" />
3130
<PackageReference Include="FluentAssertions.Json" Version="6.1.0" />
3231
</ItemGroup>

src/SchematicHQ.Client.sln

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.0.31903.59
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client", "SchematicHQ.Client\SchematicHQ.Client.csproj", "{D5BA368F-69EA-4A34-9557-9B2273F152FF}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client", "SchematicHQ.Client\SchematicHQ.Client.csproj", "{579B4CB7-28F4-463E-B36E-99A4CDD51F73}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client.Test", "SchematicHQ.Client.Test\SchematicHQ.Client.Test.csproj", "{65C6DF99-8D88-430A-B75A-800E3EED5FED}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchematicHQ.Client.Test", "SchematicHQ.Client.Test\SchematicHQ.Client.Test.csproj", "{30494002-FFCC-4613-90F8-64BEEEAC9ABB}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -16,13 +16,13 @@ Global
1616
HideSolutionNode = FALSE
1717
EndGlobalSection
1818
GlobalSection(ProjectConfigurationPlatforms) = postSolution
19-
{D5BA368F-69EA-4A34-9557-9B2273F152FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20-
{D5BA368F-69EA-4A34-9557-9B2273F152FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
21-
{D5BA368F-69EA-4A34-9557-9B2273F152FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
22-
{D5BA368F-69EA-4A34-9557-9B2273F152FF}.Release|Any CPU.Build.0 = Release|Any CPU
23-
{65C6DF99-8D88-430A-B75A-800E3EED5FED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24-
{65C6DF99-8D88-430A-B75A-800E3EED5FED}.Debug|Any CPU.Build.0 = Debug|Any CPU
25-
{65C6DF99-8D88-430A-B75A-800E3EED5FED}.Release|Any CPU.ActiveCfg = Release|Any CPU
26-
{65C6DF99-8D88-430A-B75A-800E3EED5FED}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{579B4CB7-28F4-463E-B36E-99A4CDD51F73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{579B4CB7-28F4-463E-B36E-99A4CDD51F73}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{579B4CB7-28F4-463E-B36E-99A4CDD51F73}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{579B4CB7-28F4-463E-B36E-99A4CDD51F73}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{30494002-FFCC-4613-90F8-64BEEEAC9ABB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{30494002-FFCC-4613-90F8-64BEEEAC9ABB}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{30494002-FFCC-4613-90F8-64BEEEAC9ABB}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{30494002-FFCC-4613-90F8-64BEEEAC9ABB}.Release|Any CPU.Build.0 = Release|Any CPU
2727
EndGlobalSection
2828
EndGlobal

src/SchematicHQ.Client/Billing/BillingClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ public async Task<SearchBillingPricesResponse> SearchBillingPricesAsync(
883883
}
884884
if (request.UsageType != null)
885885
{
886-
_query["usage_type"] = request.UsageType;
886+
_query["usage_type"] = request.UsageType.Value.Stringify();
887887
}
888888
if (request.Price != null)
889889
{
@@ -1454,6 +1454,7 @@ public async Task<CountBillingProductsResponse> CountBillingProductsAsync(
14541454
/// await client.Billing.UpsertBillingSubscriptionAsync(
14551455
/// new CreateBillingSubscriptionsRequestBody
14561456
/// {
1457+
/// CancelAtPeriodEnd = true,
14571458
/// Currency = "currency",
14581459
/// CustomerExternalId = "customer_external_id",
14591460
/// Discounts = new List&lt;BillingSubscriptionDiscount&gt;()
@@ -1477,7 +1478,7 @@ public async Task<CountBillingProductsResponse> CountBillingProductsAsync(
14771478
/// PriceExternalId = "price_external_id",
14781479
/// ProductExternalId = "product_external_id",
14791480
/// Quantity = 1,
1480-
/// UsageType = "usage_type",
1481+
/// UsageType = BillingProductPricingUsageType.Licensed,
14811482
/// },
14821483
/// },
14831484
/// SubscriptionExternalId = "subscription_external_id",

src/SchematicHQ.Client/Billing/Requests/CreateBillingSubscriptionsRequestBody.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ namespace SchematicHQ.Client;
55

66
public record CreateBillingSubscriptionsRequestBody
77
{
8+
[JsonPropertyName("cancel_at")]
9+
public int? CancelAt { get; set; }
10+
11+
[JsonPropertyName("cancel_at_period_end")]
12+
public required bool CancelAtPeriodEnd { get; set; }
13+
814
[JsonPropertyName("currency")]
915
public required string Currency { get; set; }
1016

@@ -47,7 +53,7 @@ public record CreateBillingSubscriptionsRequestBody
4753
public int? TrialEnd { get; set; }
4854

4955
[JsonPropertyName("trial_end_setting")]
50-
public string? TrialEndSetting { get; set; }
56+
public CreateBillingSubscriptionsRequestBodyTrialEndSetting? TrialEndSetting { get; set; }
5157

5258
public override string ToString()
5359
{

src/SchematicHQ.Client/Billing/Requests/SearchBillingPricesRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public record SearchBillingPricesRequest
1010

1111
public string? Interval { get; set; }
1212

13-
public string? UsageType { get; set; }
13+
public SearchBillingPricesRequestUsageType? UsageType { get; set; }
1414

1515
public int? Price { get; set; }
1616

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Runtime.Serialization;
2+
using System.Text.Json.Serialization;
3+
using SchematicHQ.Client.Core;
4+
5+
namespace SchematicHQ.Client;
6+
7+
[JsonConverter(typeof(EnumSerializer<CreateBillingSubscriptionsRequestBodyTrialEndSetting>))]
8+
public enum CreateBillingSubscriptionsRequestBodyTrialEndSetting
9+
{
10+
[EnumMember(Value = "subscribe")]
11+
Subscribe,
12+
13+
[EnumMember(Value = "cancel")]
14+
Cancel,
15+
}

src/SchematicHQ.Client/Billing/Types/SearchBillingPricesParams.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public record SearchBillingPricesParams
3030
public string? Q { get; set; }
3131

3232
[JsonPropertyName("usage_type")]
33-
public string? UsageType { get; set; }
33+
public SearchBillingPricesResponseParamsUsageType? UsageType { get; set; }
3434

3535
public override string ToString()
3636
{
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Runtime.Serialization;
2+
using System.Text.Json.Serialization;
3+
using SchematicHQ.Client.Core;
4+
5+
namespace SchematicHQ.Client;
6+
7+
[JsonConverter(typeof(EnumSerializer<SearchBillingPricesRequestUsageType>))]
8+
public enum SearchBillingPricesRequestUsageType
9+
{
10+
[EnumMember(Value = "licensed")]
11+
Licensed,
12+
13+
[EnumMember(Value = "metered")]
14+
Metered,
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Runtime.Serialization;
2+
using System.Text.Json.Serialization;
3+
using SchematicHQ.Client.Core;
4+
5+
namespace SchematicHQ.Client;
6+
7+
[JsonConverter(typeof(EnumSerializer<SearchBillingPricesResponseParamsUsageType>))]
8+
public enum SearchBillingPricesResponseParamsUsageType
9+
{
10+
[EnumMember(Value = "licensed")]
11+
Licensed,
12+
13+
[EnumMember(Value = "metered")]
14+
Metered,
15+
}

0 commit comments

Comments
 (0)