Skip to content

Commit bab0e94

Browse files
feat(client): refactor unions
1 parent 6cf340c commit bab0e94

File tree

639 files changed

+33496
-32386
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

639 files changed

+33496
-32386
lines changed

src/Orb.Tests/Services/Coupons/CouponServiceTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class CouponServiceTest : TestBase
99
public async Task Create_Works()
1010
{
1111
var coupon = await this.client.Coupons.Create(
12-
new() { Discount = new Percentage(0), RedemptionCode = "HALFOFF" }
12+
new() { Discount = new(new Percentage(0)), RedemptionCode = "HALFOFF" }
1313
);
1414
coupon.Validate();
1515
}

src/Orb.Tests/Services/Customers/Credits/Ledger/LedgerServiceTest.cs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,27 @@ public async Task CreateEntry_Works()
2323
new()
2424
{
2525
CustomerID = "customer_id",
26-
Body = new BodyProperties::Increment()
27-
{
28-
Amount = 0,
29-
Currency = "currency",
30-
Description = "description",
31-
EffectiveDate = DateTime.Parse("2019-12-27T18:11:19.117Z"),
32-
ExpiryDate = DateTime.Parse("2019-12-27T18:11:19.117Z"),
33-
InvoiceSettings = new()
26+
Body = new(
27+
new BodyProperties::Increment()
3428
{
35-
AutoCollection = true,
36-
NetTerms = 0,
37-
CustomDueDate = DateOnly.Parse("2019-12-27"),
38-
InvoiceDate = DateOnly.Parse("2019-12-27"),
39-
Memo = "memo",
40-
RequireSuccessfulPayment = true,
41-
},
42-
Metadata = new Dictionary<string, string?>() { { "foo", "string" } },
43-
PerUnitCostBasis = "per_unit_cost_basis",
44-
},
29+
Amount = 0,
30+
Currency = "currency",
31+
Description = "description",
32+
EffectiveDate = DateTime.Parse("2019-12-27T18:11:19.117Z"),
33+
ExpiryDate = DateTime.Parse("2019-12-27T18:11:19.117Z"),
34+
InvoiceSettings = new()
35+
{
36+
AutoCollection = true,
37+
NetTerms = 0,
38+
CustomDueDate = new(DateOnly.Parse("2019-12-27")),
39+
InvoiceDate = new(DateOnly.Parse("2019-12-27")),
40+
Memo = "memo",
41+
RequireSuccessfulPayment = true,
42+
},
43+
Metadata = new Dictionary<string, string?>() { { "foo", "string" } },
44+
PerUnitCostBasis = "per_unit_cost_basis",
45+
}
46+
),
4547
}
4648
);
4749
response.Validate();
@@ -54,7 +56,7 @@ public async Task CreateEntryByExternalID_Works()
5456
new()
5557
{
5658
ExternalCustomerID = "external_customer_id",
57-
Body =
59+
Body = new(
5860
new global::Orb.Models.Customers.Credits.Ledger.LedgerCreateEntryByExternalIDParamsProperties.BodyProperties.Increment()
5961
{
6062
Amount = 0,
@@ -66,14 +68,15 @@ public async Task CreateEntryByExternalID_Works()
6668
{
6769
AutoCollection = true,
6870
NetTerms = 0,
69-
CustomDueDate = DateOnly.Parse("2019-12-27"),
70-
InvoiceDate = DateOnly.Parse("2019-12-27"),
71+
CustomDueDate = new(DateOnly.Parse("2019-12-27")),
72+
InvoiceDate = new(DateOnly.Parse("2019-12-27")),
7173
Memo = "memo",
7274
RequireSuccessfulPayment = true,
7375
},
7476
Metadata = new Dictionary<string, string?>() { { "foo", "string" } },
7577
PerUnitCostBasis = "per_unit_cost_basis",
76-
},
78+
}
79+
),
7780
}
7881
);
7982
response.Validate();

src/Orb.Tests/Services/Plans/PlanServiceTest.cs

Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,47 +36,54 @@ public async Task Create_Works()
3636
ExpiresAtEndOfCadence = true,
3737
},
3838
PlanPhaseOrder = 0,
39-
Price1 = new NewPlanUnitPrice()
40-
{
41-
Cadence = NewPlanUnitPriceProperties::Cadence.Annual,
42-
ItemID = "item_id",
43-
ModelType = NewPlanUnitPriceProperties::ModelType.Unit,
44-
Name = "Annual fee",
45-
UnitConfig = new("unit_amount"),
46-
BillableMetricID = "billable_metric_id",
47-
BilledInAdvance = true,
48-
BillingCycleConfiguration = new()
49-
{
50-
Duration = 0,
51-
DurationUnit =
52-
NewBillingCycleConfigurationProperties::DurationUnit.Day,
53-
},
54-
ConversionRate = 0,
55-
ConversionRateConfig = new UnitConversionRateConfig()
39+
Price1 = new(
40+
new NewPlanUnitPrice()
5641
{
57-
ConversionRateType = ConversionRateType.Unit,
42+
Cadence = NewPlanUnitPriceProperties::Cadence.Annual,
43+
ItemID = "item_id",
44+
ModelType = NewPlanUnitPriceProperties::ModelType.Unit,
45+
Name = "Annual fee",
5846
UnitConfig = new("unit_amount"),
59-
},
60-
Currency = "currency",
61-
DimensionalPriceConfiguration = new()
62-
{
63-
DimensionValues = ["string"],
64-
DimensionalPriceGroupID = "dimensional_price_group_id",
65-
ExternalDimensionalPriceGroupID =
66-
"external_dimensional_price_group_id",
67-
},
68-
ExternalPriceID = "external_price_id",
69-
FixedPriceQuantity = 0,
70-
InvoiceGroupingKey = "x",
71-
InvoicingCycleConfiguration = new()
72-
{
73-
Duration = 0,
74-
DurationUnit =
75-
NewBillingCycleConfigurationProperties::DurationUnit.Day,
76-
},
77-
Metadata = new Dictionary<string, string?>() { { "foo", "string" } },
78-
ReferenceID = "reference_id",
79-
},
47+
BillableMetricID = "billable_metric_id",
48+
BilledInAdvance = true,
49+
BillingCycleConfiguration = new()
50+
{
51+
Duration = 0,
52+
DurationUnit =
53+
NewBillingCycleConfigurationProperties::DurationUnit.Day,
54+
},
55+
ConversionRate = 0,
56+
ConversionRateConfig = new(
57+
new UnitConversionRateConfig()
58+
{
59+
ConversionRateType = ConversionRateType.Unit,
60+
UnitConfig = new("unit_amount"),
61+
}
62+
),
63+
Currency = "currency",
64+
DimensionalPriceConfiguration = new()
65+
{
66+
DimensionValues = ["string"],
67+
DimensionalPriceGroupID = "dimensional_price_group_id",
68+
ExternalDimensionalPriceGroupID =
69+
"external_dimensional_price_group_id",
70+
},
71+
ExternalPriceID = "external_price_id",
72+
FixedPriceQuantity = 0,
73+
InvoiceGroupingKey = "x",
74+
InvoicingCycleConfiguration = new()
75+
{
76+
Duration = 0,
77+
DurationUnit =
78+
NewBillingCycleConfigurationProperties::DurationUnit.Day,
79+
},
80+
Metadata = new Dictionary<string, string?>()
81+
{
82+
{ "foo", "string" },
83+
},
84+
ReferenceID = "reference_id",
85+
}
86+
),
8087
},
8188
],
8289
}

src/Orb.Tests/Services/Prices/PriceServiceTest.cs

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,47 @@ public async Task Create_Works()
1616
var price = await this.client.Prices.Create(
1717
new()
1818
{
19-
Body = new NewFloatingUnitPrice()
20-
{
21-
Cadence = Cadence.Annual,
22-
Currency = "currency",
23-
ItemID = "item_id",
24-
ModelType = ModelType.Unit,
25-
Name = "Annual fee",
26-
UnitConfig = new("unit_amount"),
27-
BillableMetricID = "billable_metric_id",
28-
BilledInAdvance = true,
29-
BillingCycleConfiguration = new()
19+
Body = new(
20+
new NewFloatingUnitPrice()
3021
{
31-
Duration = 0,
32-
DurationUnit = DurationUnit.Day,
33-
},
34-
ConversionRate = 0,
35-
ConversionRateConfig = new UnitConversionRateConfig()
36-
{
37-
ConversionRateType = ConversionRateType.Unit,
22+
Cadence = Cadence.Annual,
23+
Currency = "currency",
24+
ItemID = "item_id",
25+
ModelType = ModelType.Unit,
26+
Name = "Annual fee",
3827
UnitConfig = new("unit_amount"),
39-
},
40-
DimensionalPriceConfiguration = new()
41-
{
42-
DimensionValues = ["string"],
43-
DimensionalPriceGroupID = "dimensional_price_group_id",
44-
ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id",
45-
},
46-
ExternalPriceID = "external_price_id",
47-
FixedPriceQuantity = 0,
48-
InvoiceGroupingKey = "x",
49-
InvoicingCycleConfiguration = new()
50-
{
51-
Duration = 0,
52-
DurationUnit = DurationUnit.Day,
53-
},
54-
Metadata = new Dictionary<string, string?>() { { "foo", "string" } },
55-
},
28+
BillableMetricID = "billable_metric_id",
29+
BilledInAdvance = true,
30+
BillingCycleConfiguration = new()
31+
{
32+
Duration = 0,
33+
DurationUnit = DurationUnit.Day,
34+
},
35+
ConversionRate = 0,
36+
ConversionRateConfig = new(
37+
new UnitConversionRateConfig()
38+
{
39+
ConversionRateType = ConversionRateType.Unit,
40+
UnitConfig = new("unit_amount"),
41+
}
42+
),
43+
DimensionalPriceConfiguration = new()
44+
{
45+
DimensionValues = ["string"],
46+
DimensionalPriceGroupID = "dimensional_price_group_id",
47+
ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id",
48+
},
49+
ExternalPriceID = "external_price_id",
50+
FixedPriceQuantity = 0,
51+
InvoiceGroupingKey = "x",
52+
InvoicingCycleConfiguration = new()
53+
{
54+
Duration = 0,
55+
DurationUnit = DurationUnit.Day,
56+
},
57+
Metadata = new Dictionary<string, string?>() { { "foo", "string" } },
58+
}
59+
),
5660
}
5761
);
5862
price.Validate();

src/Orb.Tests/Services/Subscriptions/SubscriptionServiceTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public async Task UpdateTrial_Works()
169169
new()
170170
{
171171
SubscriptionID = "subscription_id",
172-
TrialEndDate = DateTime.Parse("2017-07-21T17:32:28Z"),
172+
TrialEndDate = new(DateTime.Parse("2017-07-21T17:32:28Z")),
173173
}
174174
);
175175
mutatedSubscription.Validate();

src/Orb/Core/ModelBase.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Orb.Models.Customers.Costs.CostListParamsProperties;
1010
using Orb.Models.Customers.Credits.CreditListPageResponseProperties.DataProperties;
1111
using Orb.Models.Customers.Credits.Ledger.AmendmentLedgerEntryProperties;
12-
using Orb.Models.Customers.Credits.Ledger.LedgerCreateEntryParamsProperties.BodyProperties.VoidProperties;
1312
using Orb.Models.Customers.Credits.TopUps.TopUpCreateResponseProperties;
1413
using Orb.Models.Customers.CustomerProperties.AccountingSyncConfigurationProperties.AccountingProviderProperties;
1514
using Orb.Models.Customers.NewAvalaraTaxConfigurationProperties;
@@ -212,7 +211,7 @@
212211
using UsageDiscountProperties = Orb.Models.UsageDiscountProperties;
213212
using VoidInitiatedLedgerEntryProperties = Orb.Models.Customers.Credits.Ledger.VoidInitiatedLedgerEntryProperties;
214213
using VoidLedgerEntryProperties = Orb.Models.Customers.Credits.Ledger.VoidLedgerEntryProperties;
215-
using VoidProperties = Orb.Models.Customers.Credits.Ledger.LedgerCreateEntryByExternalIDParamsProperties.BodyProperties.VoidProperties;
214+
using VoidProperties = Orb.Models.Customers.Credits.Ledger.LedgerCreateEntryParamsProperties.BodyProperties.VoidProperties;
216215

217216
namespace Orb.Core;
218217

@@ -682,8 +681,11 @@ public abstract record class ModelBase
682681
new ApiEnumConverter<string, VoidLedgerEntryProperties::EntryType>(),
683682
new ApiEnumConverter<string, LedgerListParamsProperties::EntryStatus>(),
684683
new ApiEnumConverter<string, LedgerListParamsProperties::EntryType>(),
685-
new ApiEnumConverter<string, VoidReason>(),
686684
new ApiEnumConverter<string, VoidProperties::VoidReason>(),
685+
new ApiEnumConverter<
686+
string,
687+
global::Orb.Models.Customers.Credits.Ledger.LedgerCreateEntryByExternalIDParamsProperties.BodyProperties.VoidProperties.VoidReason
688+
>(),
687689
new ApiEnumConverter<string, LedgerListByExternalIDParamsProperties::EntryStatus>(),
688690
new ApiEnumConverter<string, LedgerListByExternalIDParamsProperties::EntryType>(),
689691
new ApiEnumConverter<string, ExpiresAfterUnit>(),

0 commit comments

Comments
 (0)