Skip to content

Commit 37366c3

Browse files
fix(internal): prefer to use implicit instantiation when possible
1 parent 304c45c commit 37366c3

File tree

84 files changed

+421
-652
lines changed

Some content is hidden

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

84 files changed

+421
-652
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ using Orb = Orb;
2727
using System = System;
2828

2929
// Configured using the ORB_API_KEY, ORB_WEBHOOK_SECRET and ORB_BASE_URL environment variables
30-
Orb::OrbClient client = new Orb::OrbClient();
30+
Orb::OrbClient client = new();
3131

32-
var param = new Customers::CustomerCreateParams()
32+
Customers::CustomerCreateParams param = new()
3333
{
3434
Email = "example-customer@withorb.com", Name = "My Customer"
3535
};
@@ -47,15 +47,15 @@ Configure the client using environment variables:
4747
using Orb = Orb;
4848

4949
// Configured using the ORB_API_KEY, ORB_WEBHOOK_SECRET and ORB_BASE_URL environment variables
50-
Orb::OrbClient client = new Orb::OrbClient();
50+
Orb::OrbClient client = new();
5151
```
5252

5353
Or manually:
5454

5555
```C#
5656
using Orb = Orb;
5757

58-
Orb::OrbClient client = new Orb::OrbClient()
58+
Orb::OrbClient client = new()
5959
{
6060
APIKey = "My API Key"
6161
};

src/Orb.Tests/Service/Alerts/AlertServiceTest.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using AlertCreateForCustomerParamsProperties = Orb.Models.Alerts.AlertCreateForCustomerParamsProperties;
22
using AlertCreateForExternalCustomerParamsProperties = Orb.Models.Alerts.AlertCreateForExternalCustomerParamsProperties;
33
using AlertCreateForSubscriptionParamsProperties = Orb.Models.Alerts.AlertCreateForSubscriptionParamsProperties;
4-
using Alerts = Orb.Models.Alerts;
54
using System = System;
65
using Tasks = System.Threading.Tasks;
76
using Tests = Orb.Tests;
@@ -13,20 +12,18 @@ public class AlertServiceTest : Tests::TestBase
1312
[Fact]
1413
public async Tasks::Task Retrieve_Works()
1514
{
16-
var alert = await this.client.Alerts.Retrieve(
17-
new Alerts::AlertRetrieveParams() { AlertID = "alert_id" }
18-
);
15+
var alert = await this.client.Alerts.Retrieve(new() { AlertID = "alert_id" });
1916
alert.Validate();
2017
}
2118

2219
[Fact]
2320
public async Tasks::Task Update_Works()
2421
{
2522
var alert = await this.client.Alerts.Update(
26-
new Alerts::AlertUpdateParams()
23+
new()
2724
{
2825
AlertConfigurationID = "alert_configuration_id",
29-
Thresholds = [new Alerts::Threshold() { Value = 0 }],
26+
Thresholds = [new() { Value = 0 }],
3027
}
3128
);
3229
alert.Validate();
@@ -36,7 +33,7 @@ public class AlertServiceTest : Tests::TestBase
3633
public async Tasks::Task List_Works()
3734
{
3835
var page = await this.client.Alerts.List(
39-
new Alerts::AlertListParams()
36+
new()
4037
{
4138
CreatedAtGt = System::DateTime.Parse("2019-12-27T18:11:19.117Z"),
4239
CreatedAtGte = System::DateTime.Parse("2019-12-27T18:11:19.117Z"),
@@ -56,12 +53,12 @@ public class AlertServiceTest : Tests::TestBase
5653
public async Tasks::Task CreateForCustomer_Works()
5754
{
5855
var alert = await this.client.Alerts.CreateForCustomer(
59-
new Alerts::AlertCreateForCustomerParams()
56+
new()
6057
{
6158
CustomerID = "customer_id",
6259
Currency = "currency",
6360
Type = AlertCreateForCustomerParamsProperties::Type.CreditBalanceDepleted,
64-
Thresholds = [new Alerts::Threshold() { Value = 0 }],
61+
Thresholds = [new() { Value = 0 }],
6562
}
6663
);
6764
alert.Validate();
@@ -71,12 +68,12 @@ public class AlertServiceTest : Tests::TestBase
7168
public async Tasks::Task CreateForExternalCustomer_Works()
7269
{
7370
var alert = await this.client.Alerts.CreateForExternalCustomer(
74-
new Alerts::AlertCreateForExternalCustomerParams()
71+
new()
7572
{
7673
ExternalCustomerID = "external_customer_id",
7774
Currency = "currency",
7875
Type = AlertCreateForExternalCustomerParamsProperties::Type.CreditBalanceDepleted,
79-
Thresholds = [new Alerts::Threshold() { Value = 0 }],
76+
Thresholds = [new() { Value = 0 }],
8077
}
8178
);
8279
alert.Validate();
@@ -86,10 +83,10 @@ public class AlertServiceTest : Tests::TestBase
8683
public async Tasks::Task CreateForSubscription_Works()
8784
{
8885
var alert = await this.client.Alerts.CreateForSubscription(
89-
new Alerts::AlertCreateForSubscriptionParams()
86+
new()
9087
{
9188
SubscriptionID = "subscription_id",
92-
Thresholds = [new Alerts::Threshold() { Value = 0 }],
89+
Thresholds = [new() { Value = 0 }],
9390
Type = AlertCreateForSubscriptionParamsProperties::Type.UsageExceeded,
9491
MetricID = "metric_id",
9592
}
@@ -101,7 +98,7 @@ public class AlertServiceTest : Tests::TestBase
10198
public async Tasks::Task Disable_Works()
10299
{
103100
var alert = await this.client.Alerts.Disable(
104-
new Alerts::AlertDisableParams()
101+
new()
105102
{
106103
AlertConfigurationID = "alert_configuration_id",
107104
SubscriptionID = "subscription_id",
@@ -114,7 +111,7 @@ public class AlertServiceTest : Tests::TestBase
114111
public async Tasks::Task Enable_Works()
115112
{
116113
var alert = await this.client.Alerts.Enable(
117-
new Alerts::AlertEnableParams()
114+
new()
118115
{
119116
AlertConfigurationID = "alert_configuration_id",
120117
SubscriptionID = "subscription_id",

src/Orb.Tests/Service/Beta/BetaServiceTest.cs

Lines changed: 37 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using Beta = Orb.Models.Beta;
2-
using BetaCreatePlanVersionParamsProperties = Orb.Models.Beta.BetaCreatePlanVersionParamsProperties;
31
using CustomExpirationProperties = Orb.Models.CustomExpirationProperties;
42
using Models = Orb.Models;
53
using NewAllocationPriceProperties = Orb.Models.NewAllocationPriceProperties;
@@ -19,13 +17,13 @@ public class BetaServiceTest : Tests::TestBase
1917
public async Tasks::Task CreatePlanVersion_Works()
2018
{
2119
var planVersion = await this.client.Beta.CreatePlanVersion(
22-
new Beta::BetaCreatePlanVersionParams()
20+
new()
2321
{
2422
PlanID = "plan_id",
2523
Version = 0,
2624
AddAdjustments =
2725
[
28-
new BetaCreatePlanVersionParamsProperties::AddAdjustment()
26+
new()
2927
{
3028
Adjustment = new Models::NewPercentageDiscount()
3129
{
@@ -38,7 +36,7 @@ public class BetaServiceTest : Tests::TestBase
3836
Currency = "currency",
3937
Filters =
4038
[
41-
new Models::TransformPriceFilter()
39+
new()
4240
{
4341
Field = TransformPriceFilterProperties::Field.PriceID,
4442
Operator = TransformPriceFilterProperties::Operator.Includes,
@@ -53,14 +51,14 @@ public class BetaServiceTest : Tests::TestBase
5351
],
5452
AddPrices =
5553
[
56-
new BetaCreatePlanVersionParamsProperties::AddPrice()
54+
new()
5755
{
58-
AllocationPrice = new Models::NewAllocationPrice()
56+
AllocationPrice = new()
5957
{
6058
Amount = "10.00",
6159
Cadence = NewAllocationPriceProperties::Cadence.Monthly,
6260
Currency = "USD",
63-
CustomExpiration = new Models::CustomExpiration()
61+
CustomExpiration = new()
6462
{
6563
Duration = 0,
6664
DurationUnit = CustomExpirationProperties::DurationUnit.Day,
@@ -74,10 +72,10 @@ public class BetaServiceTest : Tests::TestBase
7472
ItemID = "item_id",
7573
ModelType = NewPlanUnitPriceProperties::ModelType.Unit,
7674
Name = "Annual fee",
77-
UnitConfig = new Models::UnitConfig() { UnitAmount = "unit_amount" },
75+
UnitConfig = new() { UnitAmount = "unit_amount" },
7876
BillableMetricID = "billable_metric_id",
7977
BilledInAdvance = true,
80-
BillingCycleConfiguration = new Models::NewBillingCycleConfiguration()
78+
BillingCycleConfiguration = new()
8179
{
8280
Duration = 0,
8381
DurationUnit =
@@ -88,24 +86,20 @@ public class BetaServiceTest : Tests::TestBase
8886
{
8987
ConversionRateType =
9088
UnitConversionRateConfigProperties::ConversionRateType.Unit,
91-
UnitConfig = new Models::ConversionRateUnitConfig()
92-
{
93-
UnitAmount = "unit_amount",
94-
},
89+
UnitConfig = new() { UnitAmount = "unit_amount" },
9590
},
9691
Currency = "currency",
97-
DimensionalPriceConfiguration =
98-
new Models::NewDimensionalPriceConfiguration()
99-
{
100-
DimensionValues = ["string"],
101-
DimensionalPriceGroupID = "dimensional_price_group_id",
102-
ExternalDimensionalPriceGroupID =
103-
"external_dimensional_price_group_id",
104-
},
92+
DimensionalPriceConfiguration = new()
93+
{
94+
DimensionValues = ["string"],
95+
DimensionalPriceGroupID = "dimensional_price_group_id",
96+
ExternalDimensionalPriceGroupID =
97+
"external_dimensional_price_group_id",
98+
},
10599
ExternalPriceID = "external_price_id",
106100
FixedPriceQuantity = 0,
107101
InvoiceGroupingKey = "x",
108-
InvoicingCycleConfiguration = new Models::NewBillingCycleConfiguration()
102+
InvoicingCycleConfiguration = new()
109103
{
110104
Duration = 0,
111105
DurationUnit =
@@ -116,25 +110,11 @@ public class BetaServiceTest : Tests::TestBase
116110
},
117111
},
118112
],
119-
RemoveAdjustments =
120-
[
121-
new BetaCreatePlanVersionParamsProperties::RemoveAdjustment()
122-
{
123-
AdjustmentID = "adjustment_id",
124-
PlanPhaseOrder = 0,
125-
},
126-
],
127-
RemovePrices =
128-
[
129-
new BetaCreatePlanVersionParamsProperties::RemovePrice()
130-
{
131-
PriceID = "price_id",
132-
PlanPhaseOrder = 0,
133-
},
134-
],
113+
RemoveAdjustments = [new() { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }],
114+
RemovePrices = [new() { PriceID = "price_id", PlanPhaseOrder = 0 }],
135115
ReplaceAdjustments =
136116
[
137-
new BetaCreatePlanVersionParamsProperties::ReplaceAdjustment()
117+
new()
138118
{
139119
Adjustment = new Models::NewPercentageDiscount()
140120
{
@@ -147,7 +127,7 @@ public class BetaServiceTest : Tests::TestBase
147127
Currency = "currency",
148128
Filters =
149129
[
150-
new Models::TransformPriceFilter()
130+
new()
151131
{
152132
Field = TransformPriceFilterProperties::Field.PriceID,
153133
Operator = TransformPriceFilterProperties::Operator.Includes,
@@ -163,15 +143,15 @@ public class BetaServiceTest : Tests::TestBase
163143
],
164144
ReplacePrices =
165145
[
166-
new BetaCreatePlanVersionParamsProperties::ReplacePrice()
146+
new()
167147
{
168148
ReplacesPriceID = "replaces_price_id",
169-
AllocationPrice = new Models::NewAllocationPrice()
149+
AllocationPrice = new()
170150
{
171151
Amount = "10.00",
172152
Cadence = NewAllocationPriceProperties::Cadence.Monthly,
173153
Currency = "USD",
174-
CustomExpiration = new Models::CustomExpiration()
154+
CustomExpiration = new()
175155
{
176156
Duration = 0,
177157
DurationUnit = CustomExpirationProperties::DurationUnit.Day,
@@ -185,10 +165,10 @@ public class BetaServiceTest : Tests::TestBase
185165
ItemID = "item_id",
186166
ModelType = NewPlanUnitPriceProperties::ModelType.Unit,
187167
Name = "Annual fee",
188-
UnitConfig = new Models::UnitConfig() { UnitAmount = "unit_amount" },
168+
UnitConfig = new() { UnitAmount = "unit_amount" },
189169
BillableMetricID = "billable_metric_id",
190170
BilledInAdvance = true,
191-
BillingCycleConfiguration = new Models::NewBillingCycleConfiguration()
171+
BillingCycleConfiguration = new()
192172
{
193173
Duration = 0,
194174
DurationUnit =
@@ -199,24 +179,20 @@ public class BetaServiceTest : Tests::TestBase
199179
{
200180
ConversionRateType =
201181
UnitConversionRateConfigProperties::ConversionRateType.Unit,
202-
UnitConfig = new Models::ConversionRateUnitConfig()
203-
{
204-
UnitAmount = "unit_amount",
205-
},
182+
UnitConfig = new() { UnitAmount = "unit_amount" },
206183
},
207184
Currency = "currency",
208-
DimensionalPriceConfiguration =
209-
new Models::NewDimensionalPriceConfiguration()
210-
{
211-
DimensionValues = ["string"],
212-
DimensionalPriceGroupID = "dimensional_price_group_id",
213-
ExternalDimensionalPriceGroupID =
214-
"external_dimensional_price_group_id",
215-
},
185+
DimensionalPriceConfiguration = new()
186+
{
187+
DimensionValues = ["string"],
188+
DimensionalPriceGroupID = "dimensional_price_group_id",
189+
ExternalDimensionalPriceGroupID =
190+
"external_dimensional_price_group_id",
191+
},
216192
ExternalPriceID = "external_price_id",
217193
FixedPriceQuantity = 0,
218194
InvoiceGroupingKey = "x",
219-
InvoicingCycleConfiguration = new Models::NewBillingCycleConfiguration()
195+
InvoicingCycleConfiguration = new()
220196
{
221197
Duration = 0,
222198
DurationUnit =
@@ -237,7 +213,7 @@ public class BetaServiceTest : Tests::TestBase
237213
public async Tasks::Task FetchPlanVersion_Works()
238214
{
239215
var planVersion = await this.client.Beta.FetchPlanVersion(
240-
new Beta::BetaFetchPlanVersionParams() { PlanID = "plan_id", Version = "version" }
216+
new() { PlanID = "plan_id", Version = "version" }
241217
);
242218
planVersion.Validate();
243219
}
@@ -246,7 +222,7 @@ public class BetaServiceTest : Tests::TestBase
246222
public async Tasks::Task SetDefaultPlanVersion_Works()
247223
{
248224
var plan = await this.client.Beta.SetDefaultPlanVersion(
249-
new Beta::BetaSetDefaultPlanVersionParams() { PlanID = "plan_id", Version = 0 }
225+
new() { PlanID = "plan_id", Version = 0 }
250226
);
251227
plan.Validate();
252228
}

0 commit comments

Comments
 (0)