Skip to content

Commit 8e82a6b

Browse files
feat(client): add some convenience constructors
1 parent 928b193 commit 8e82a6b

File tree

78 files changed

+387
-42
lines changed

Some content is hidden

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

78 files changed

+387
-42
lines changed

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ public async Task Retrieve_Works()
1919
public async Task Update_Works()
2020
{
2121
var alert = await this.client.Alerts.Update(
22-
new()
23-
{
24-
AlertConfigurationID = "alert_configuration_id",
25-
Thresholds = [new() { Value = 0 }],
26-
}
22+
new() { AlertConfigurationID = "alert_configuration_id", Thresholds = [new(0)] }
2723
);
2824
alert.Validate();
2925
}
@@ -57,7 +53,7 @@ public async Task CreateForCustomer_Works()
5753
CustomerID = "customer_id",
5854
Currency = "currency",
5955
Type = AlertCreateForCustomerParamsProperties::Type.CreditBalanceDepleted,
60-
Thresholds = [new() { Value = 0 }],
56+
Thresholds = [new(0)],
6157
}
6258
);
6359
alert.Validate();
@@ -72,7 +68,7 @@ public async Task CreateForExternalCustomer_Works()
7268
ExternalCustomerID = "external_customer_id",
7369
Currency = "currency",
7470
Type = AlertCreateForExternalCustomerParamsProperties::Type.CreditBalanceDepleted,
75-
Thresholds = [new() { Value = 0 }],
71+
Thresholds = [new(0)],
7672
}
7773
);
7874
alert.Validate();
@@ -85,7 +81,7 @@ public async Task CreateForSubscription_Works()
8581
new()
8682
{
8783
SubscriptionID = "subscription_id",
88-
Thresholds = [new() { Value = 0 }],
84+
Thresholds = [new(0)],
8985
Type = AlertCreateForSubscriptionParamsProperties::Type.UsageExceeded,
9086
MetricID = "metric_id",
9187
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public async Task CreatePlanVersion_Works()
7070
ItemID = "item_id",
7171
ModelType = NewPlanUnitPriceProperties::ModelType.Unit,
7272
Name = "Annual fee",
73-
UnitConfig = new() { UnitAmount = "unit_amount" },
73+
UnitConfig = new("unit_amount"),
7474
BillableMetricID = "billable_metric_id",
7575
BilledInAdvance = true,
7676
BillingCycleConfiguration = new()
@@ -83,7 +83,7 @@ public async Task CreatePlanVersion_Works()
8383
ConversionRateConfig = new UnitConversionRateConfig()
8484
{
8585
ConversionRateType = ConversionRateType.Unit,
86-
UnitConfig = new() { UnitAmount = "unit_amount" },
86+
UnitConfig = new("unit_amount"),
8787
},
8888
Currency = "currency",
8989
DimensionalPriceConfiguration = new()
@@ -161,7 +161,7 @@ public async Task CreatePlanVersion_Works()
161161
ItemID = "item_id",
162162
ModelType = NewPlanUnitPriceProperties::ModelType.Unit,
163163
Name = "Annual fee",
164-
UnitConfig = new() { UnitAmount = "unit_amount" },
164+
UnitConfig = new("unit_amount"),
165165
BillableMetricID = "billable_metric_id",
166166
BilledInAdvance = true,
167167
BillingCycleConfiguration = new()
@@ -174,7 +174,7 @@ public async Task CreatePlanVersion_Works()
174174
ConversionRateConfig = new UnitConversionRateConfig()
175175
{
176176
ConversionRateType = ConversionRateType.Unit,
177-
UnitConfig = new() { UnitAmount = "unit_amount" },
177+
UnitConfig = new("unit_amount"),
178178
},
179179
Currency = "currency",
180180
DimensionalPriceConfiguration = new()

src/Orb.Tests/Services/Beta/ExternalPlanID/ExternalPlanIDServiceTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public async Task CreatePlanVersion_Works()
7070
ItemID = "item_id",
7171
ModelType = NewPlanUnitPriceProperties::ModelType.Unit,
7272
Name = "Annual fee",
73-
UnitConfig = new() { UnitAmount = "unit_amount" },
73+
UnitConfig = new("unit_amount"),
7474
BillableMetricID = "billable_metric_id",
7575
BilledInAdvance = true,
7676
BillingCycleConfiguration = new()
@@ -83,7 +83,7 @@ public async Task CreatePlanVersion_Works()
8383
ConversionRateConfig = new UnitConversionRateConfig()
8484
{
8585
ConversionRateType = ConversionRateType.Unit,
86-
UnitConfig = new() { UnitAmount = "unit_amount" },
86+
UnitConfig = new("unit_amount"),
8787
},
8888
Currency = "currency",
8989
DimensionalPriceConfiguration = new()
@@ -161,7 +161,7 @@ public async Task CreatePlanVersion_Works()
161161
ItemID = "item_id",
162162
ModelType = NewPlanUnitPriceProperties::ModelType.Unit,
163163
Name = "Annual fee",
164-
UnitConfig = new() { UnitAmount = "unit_amount" },
164+
UnitConfig = new("unit_amount"),
165165
BillableMetricID = "billable_metric_id",
166166
BilledInAdvance = true,
167167
BillingCycleConfiguration = new()
@@ -174,7 +174,7 @@ public async Task CreatePlanVersion_Works()
174174
ConversionRateConfig = new UnitConversionRateConfig()
175175
{
176176
ConversionRateType = ConversionRateType.Unit,
177-
UnitConfig = new() { UnitAmount = "unit_amount" },
177+
UnitConfig = new("unit_amount"),
178178
},
179179
Currency = "currency",
180180
DimensionalPriceConfiguration = new()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public async Task Create_Works()
1111
var coupon = await this.client.Coupons.Create(
1212
new()
1313
{
14-
Discount = new Percentage() { PercentageDiscount = 0 },
14+
Discount = new Percentage(0),
1515
RedemptionCode = "HALFOFF",
1616
DurationInMonths = 12,
1717
MaxRedemptions = 1,

src/Orb.Tests/Services/Customers/CustomerServiceTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public async Task Create_Works()
5353
Metadata = new() { { "foo", "string" } },
5454
PaymentProvider = PaymentProvider.Quickbooks,
5555
PaymentProviderID = "payment_provider_id",
56-
ReportingConfiguration = new() { Exempt = true },
56+
ReportingConfiguration = new(true),
5757
ShippingAddress = new()
5858
{
5959
City = "city",
@@ -124,7 +124,7 @@ public async Task Update_Works()
124124
Name = "name",
125125
PaymentProvider = CustomerUpdateParamsProperties::PaymentProvider.Quickbooks,
126126
PaymentProviderID = "payment_provider_id",
127-
ReportingConfiguration = new() { Exempt = true },
127+
ReportingConfiguration = new(true),
128128
ShippingAddress = new()
129129
{
130130
City = "city",
@@ -250,7 +250,7 @@ public async Task UpdateByExternalID_Works()
250250
PaymentProvider =
251251
CustomerUpdateByExternalIDParamsProperties::PaymentProvider.Quickbooks,
252252
PaymentProviderID = "payment_provider_id",
253-
ReportingConfiguration = new() { Exempt = true },
253+
ReportingConfiguration = new(true),
254254
ShippingAddress = new()
255255
{
256256
City = "city",

src/Orb.Tests/Services/Invoices/InvoiceServiceTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public async Task Create_Works()
2828
Name = "Line Item Name",
2929
Quantity = 1,
3030
StartDate = DateOnly.Parse("2023-09-22"),
31-
UnitConfig = new() { UnitAmount = "unit_amount" },
31+
UnitConfig = new("unit_amount"),
3232
},
3333
],
3434
CustomerID = "4khy3nwzktxv7",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public async Task Create_Works()
4747
ItemID = "item_id",
4848
ModelType = NewPlanUnitPriceProperties::ModelType.Unit,
4949
Name = "Annual fee",
50-
UnitConfig = new() { UnitAmount = "unit_amount" },
50+
UnitConfig = new("unit_amount"),
5151
BillableMetricID = "billable_metric_id",
5252
BilledInAdvance = true,
5353
BillingCycleConfiguration = new()
@@ -60,7 +60,7 @@ public async Task Create_Works()
6060
ConversionRateConfig = new UnitConversionRateConfig()
6161
{
6262
ConversionRateType = ConversionRateType.Unit,
63-
UnitConfig = new() { UnitAmount = "unit_amount" },
63+
UnitConfig = new("unit_amount"),
6464
},
6565
Currency = "currency",
6666
DimensionalPriceConfiguration = new()

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public async Task Create_Works()
2323
ItemID = "item_id",
2424
ModelType = ModelType.Unit,
2525
Name = "Annual fee",
26-
UnitConfig = new() { UnitAmount = "unit_amount" },
26+
UnitConfig = new("unit_amount"),
2727
BillableMetricID = "billable_metric_id",
2828
BilledInAdvance = true,
2929
BillingCycleConfiguration = new()
@@ -35,7 +35,7 @@ public async Task Create_Works()
3535
ConversionRateConfig = new UnitConversionRateConfig()
3636
{
3737
ConversionRateType = ConversionRateType.Unit,
38-
UnitConfig = new() { UnitAmount = "unit_amount" },
38+
UnitConfig = new("unit_amount"),
3939
},
4040
DimensionalPriceConfiguration = new()
4141
{
@@ -120,7 +120,7 @@ public async Task EvaluateMultiple_Works()
120120
ItemID = "item_id",
121121
ModelType = ModelType.Unit,
122122
Name = "Annual fee",
123-
UnitConfig = new() { UnitAmount = "unit_amount" },
123+
UnitConfig = new("unit_amount"),
124124
BillableMetricID = "billable_metric_id",
125125
BilledInAdvance = true,
126126
BillingCycleConfiguration = new()
@@ -132,7 +132,7 @@ public async Task EvaluateMultiple_Works()
132132
ConversionRateConfig = new UnitConversionRateConfig()
133133
{
134134
ConversionRateType = ConversionRateType.Unit,
135-
UnitConfig = new() { UnitAmount = "unit_amount" },
135+
UnitConfig = new("unit_amount"),
136136
},
137137
DimensionalPriceConfiguration = new()
138138
{
@@ -194,7 +194,7 @@ public async Task EvaluatePreviewEvents_Works()
194194
ItemID = "item_id",
195195
ModelType = ModelType.Unit,
196196
Name = "Annual fee",
197-
UnitConfig = new() { UnitAmount = "unit_amount" },
197+
UnitConfig = new("unit_amount"),
198198
BillableMetricID = "billable_metric_id",
199199
BilledInAdvance = true,
200200
BillingCycleConfiguration = new()
@@ -206,7 +206,7 @@ public async Task EvaluatePreviewEvents_Works()
206206
ConversionRateConfig = new UnitConversionRateConfig()
207207
{
208208
ConversionRateType = ConversionRateType.Unit,
209-
UnitConfig = new() { UnitAmount = "unit_amount" },
209+
UnitConfig = new("unit_amount"),
210210
},
211211
DimensionalPriceConfiguration = new()
212212
{

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public async Task Create_Works()
9898
ItemID = "item_id",
9999
ModelType = NewSubscriptionUnitPriceProperties::ModelType.Unit,
100100
Name = "Annual fee",
101-
UnitConfig = new() { UnitAmount = "unit_amount" },
101+
UnitConfig = new("unit_amount"),
102102
BillableMetricID = "billable_metric_id",
103103
BilledInAdvance = true,
104104
BillingCycleConfiguration = new()
@@ -111,7 +111,7 @@ public async Task Create_Works()
111111
ConversionRateConfig = new UnitConversionRateConfig()
112112
{
113113
ConversionRateType = ConversionRateType.Unit,
114-
UnitConfig = new() { UnitAmount = "unit_amount" },
114+
UnitConfig = new("unit_amount"),
115115
},
116116
Currency = "currency",
117117
DimensionalPriceConfiguration = new()
@@ -166,7 +166,7 @@ public async Task Create_Works()
166166
PlanID = "ZMwNQefe7J3ecf7W",
167167
PlanVersionNumber = 0,
168168
PriceOverrides = [JsonSerializer.Deserialize<JsonElement>("{}")],
169-
RemoveAdjustments = [new() { AdjustmentID = "h74gfhdjvn7ujokd" }],
169+
RemoveAdjustments = [new("h74gfhdjvn7ujokd")],
170170
RemovePrices =
171171
[
172172
new() { ExternalPriceID = "external_price_id", PriceID = "h74gfhdjvn7ujokd" },
@@ -235,7 +235,7 @@ public async Task Create_Works()
235235
ItemID = "item_id",
236236
ModelType = NewSubscriptionUnitPriceProperties::ModelType.Unit,
237237
Name = "Annual fee",
238-
UnitConfig = new() { UnitAmount = "unit_amount" },
238+
UnitConfig = new("unit_amount"),
239239
BillableMetricID = "billable_metric_id",
240240
BilledInAdvance = true,
241241
BillingCycleConfiguration = new()
@@ -248,7 +248,7 @@ public async Task Create_Works()
248248
ConversionRateConfig = new UnitConversionRateConfig()
249249
{
250250
ConversionRateType = ConversionRateType.Unit,
251-
UnitConfig = new() { UnitAmount = "unit_amount" },
251+
UnitConfig = new("unit_amount"),
252252
},
253253
Currency = "currency",
254254
DimensionalPriceConfiguration = new()
@@ -422,7 +422,7 @@ public async Task PriceIntervals_Works()
422422
},
423423
ExpiresAtEndOfCadence = true,
424424
},
425-
Discounts = [new Amount() { AmountDiscount = 0 }],
425+
Discounts = [new Amount(0)],
426426
EndDate = DateTime.Parse("2019-12-27T18:11:19.117Z"),
427427
ExternalPriceID = "external_price_id",
428428
Filter = "my_property > 100 AND my_other_property = 'bar'",
@@ -443,7 +443,7 @@ public async Task PriceIntervals_Works()
443443
ItemID = "item_id",
444444
ModelType = ModelType.Unit,
445445
Name = "Annual fee",
446-
UnitConfig = new() { UnitAmount = "unit_amount" },
446+
UnitConfig = new("unit_amount"),
447447
BillableMetricID = "billable_metric_id",
448448
BilledInAdvance = true,
449449
BillingCycleConfiguration = new()
@@ -456,7 +456,7 @@ public async Task PriceIntervals_Works()
456456
ConversionRateConfig = new UnitConversionRateConfig()
457457
{
458458
ConversionRateType = ConversionRateType.Unit,
459-
UnitConfig = new() { UnitAmount = "unit_amount" },
459+
UnitConfig = new("unit_amount"),
460460
},
461461
DimensionalPriceConfiguration = new()
462462
{
@@ -635,7 +635,7 @@ public async Task SchedulePlanChange_Works()
635635
ItemID = "item_id",
636636
ModelType = NewSubscriptionUnitPriceProperties::ModelType.Unit,
637637
Name = "Annual fee",
638-
UnitConfig = new() { UnitAmount = "unit_amount" },
638+
UnitConfig = new("unit_amount"),
639639
BillableMetricID = "billable_metric_id",
640640
BilledInAdvance = true,
641641
BillingCycleConfiguration = new()
@@ -648,7 +648,7 @@ public async Task SchedulePlanChange_Works()
648648
ConversionRateConfig = new UnitConversionRateConfig()
649649
{
650650
ConversionRateType = ConversionRateType.Unit,
651-
UnitConfig = new() { UnitAmount = "unit_amount" },
651+
UnitConfig = new("unit_amount"),
652652
},
653653
Currency = "currency",
654654
DimensionalPriceConfiguration = new()
@@ -697,7 +697,7 @@ public async Task SchedulePlanChange_Works()
697697
PlanID = "ZMwNQefe7J3ecf7W",
698698
PlanVersionNumber = 0,
699699
PriceOverrides = [JsonSerializer.Deserialize<JsonElement>("{}")],
700-
RemoveAdjustments = [new() { AdjustmentID = "h74gfhdjvn7ujokd" }],
700+
RemoveAdjustments = [new("h74gfhdjvn7ujokd")],
701701
RemovePrices =
702702
[
703703
new() { ExternalPriceID = "external_price_id", PriceID = "h74gfhdjvn7ujokd" },
@@ -766,7 +766,7 @@ public async Task SchedulePlanChange_Works()
766766
ItemID = "item_id",
767767
ModelType = NewSubscriptionUnitPriceProperties::ModelType.Unit,
768768
Name = "Annual fee",
769-
UnitConfig = new() { UnitAmount = "unit_amount" },
769+
UnitConfig = new("unit_amount"),
770770
BillableMetricID = "billable_metric_id",
771771
BilledInAdvance = true,
772772
BillingCycleConfiguration = new()
@@ -779,7 +779,7 @@ public async Task SchedulePlanChange_Works()
779779
ConversionRateConfig = new UnitConversionRateConfig()
780780
{
781781
ConversionRateType = ConversionRateType.Unit,
782-
UnitConfig = new() { UnitAmount = "unit_amount" },
782+
UnitConfig = new("unit_amount"),
783783
},
784784
Currency = "currency",
785785
DimensionalPriceConfiguration = new()

src/Orb/Models/Alerts/AlertProperties/Metric.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ public static Metric FromRawUnchecked(Dictionary<string, JsonElement> properties
4444
{
4545
return new(properties);
4646
}
47+
48+
public Metric(string id)
49+
{
50+
this.ID = id;
51+
}
4752
}

0 commit comments

Comments
 (0)