Skip to content

Commit 25e678a

Browse files
feat(client): automatically set constants for user
1 parent b08df82 commit 25e678a

File tree

91 files changed

+652
-2029
lines changed

Some content is hidden

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

91 files changed

+652
-2029
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using CouponCreateParamsProperties = Orb.Models.Coupons.CouponCreateParamsProperties;
22
using Coupons = Orb.Models.Coupons;
33
using DiscountProperties = Orb.Models.Coupons.CouponCreateParamsProperties.DiscountProperties;
4-
using PercentageProperties = Orb.Models.Coupons.CouponCreateParamsProperties.DiscountProperties.PercentageProperties;
54
using Tasks = System.Threading.Tasks;
65
using Tests = Orb.Tests;
76

@@ -16,11 +15,7 @@ public class CouponServiceTest : Tests::TestBase
1615
new Coupons::CouponCreateParams()
1716
{
1817
Discount = CouponCreateParamsProperties::Discount.Create(
19-
new DiscountProperties::Percentage()
20-
{
21-
DiscountType = PercentageProperties::DiscountType.Percentage,
22-
PercentageDiscount = 0,
23-
}
18+
new DiscountProperties::Percentage() { PercentageDiscount = 0 }
2419
),
2520
RedemptionCode = "HALFOFF",
2621
DurationInMonths = 12,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public class LedgerServiceTest : Tests::TestBase
5050
new BodyProperties::Increment()
5151
{
5252
Amount = 0,
53-
EntryType = IncrementProperties::EntryType.Increment,
5453
Currency = "currency",
5554
Description = "description",
5655
EffectiveDate = System::DateTime.Parse("2019-12-27T18:11:19.117Z"),
@@ -85,7 +84,6 @@ public class LedgerServiceTest : Tests::TestBase
8584
new BodyProperties1::Increment()
8685
{
8786
Amount = 0,
88-
EntryType = IncrementProperties1::EntryType.Increment,
8987
Currency = "currency",
9088
Description = "description",
9189
EffectiveDate = System::DateTime.Parse("2019-12-27T18:11:19.117Z"),

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using AddPriceProperties = Orb.Models.Subscriptions.SubscriptionCreateParamsProperties.AddPriceProperties;
55
using AddPriceProperties1 = Orb.Models.Subscriptions.SubscriptionSchedulePlanChangeParamsProperties.AddPriceProperties;
66
using AddProperties = Orb.Models.Subscriptions.SubscriptionPriceIntervalsParamsProperties.AddProperties;
7-
using AmountProperties = Orb.Models.Subscriptions.SubscriptionPriceIntervalsParamsProperties.AddProperties.DiscountProperties.AmountProperties;
87
using CustomExpirationProperties = Orb.Models.CustomExpirationProperties;
98
using DiscountOverrideProperties = Orb.Models.Subscriptions.DiscountOverrideProperties;
109
using DiscountProperties = Orb.Models.Subscriptions.SubscriptionPriceIntervalsParamsProperties.AddProperties.DiscountProperties;
@@ -493,11 +492,7 @@ public class SubscriptionServiceTest : Tests::TestBase
493492
Discounts =
494493
[
495494
AddProperties::Discount.Create(
496-
new DiscountProperties::Amount()
497-
{
498-
AmountDiscount = 0,
499-
DiscountType = AmountProperties::DiscountType.Amount,
500-
}
495+
new DiscountProperties::Amount() { AmountDiscount = 0 }
501496
),
502497
],
503498
EndDate = AddProperties::EndDate.Create(

src/Orb/Models/Coupons/CouponCreateParamsProperties/DiscountProperties/Amount.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using AmountProperties = Orb.Models.Coupons.CouponCreateParamsProperties.DiscountProperties.AmountProperties;
21
using CodeAnalysis = System.Diagnostics.CodeAnalysis;
32
using Generic = System.Collections.Generic;
43
using Json = System.Text.Json;
@@ -27,7 +26,7 @@ public required string AmountDiscount
2726
set { this.Properties["amount_discount"] = Json::JsonSerializer.SerializeToElement(value); }
2827
}
2928

30-
public required AmountProperties::DiscountType DiscountType
29+
public Json::JsonElement DiscountType
3130
{
3231
get
3332
{
@@ -37,19 +36,28 @@ public required string AmountDiscount
3736
"Missing required argument"
3837
);
3938

40-
return Json::JsonSerializer.Deserialize<AmountProperties::DiscountType>(element)
41-
?? throw new System::ArgumentNullException("discount_type");
39+
return Json::JsonSerializer.Deserialize<Json::JsonElement>(element);
4240
}
4341
set { this.Properties["discount_type"] = Json::JsonSerializer.SerializeToElement(value); }
4442
}
4543

4644
public override void Validate()
4745
{
4846
_ = this.AmountDiscount;
49-
this.DiscountType.Validate();
47+
if (
48+
!this.DiscountType.Equals(
49+
Json::JsonSerializer.Deserialize<Json::JsonElement>("\"amount\"")
50+
)
51+
)
52+
{
53+
throw new System::Exception();
54+
}
5055
}
5156

52-
public Amount() { }
57+
public Amount()
58+
{
59+
this.DiscountType = Json::JsonSerializer.Deserialize<Json::JsonElement>("\"amount\"");
60+
}
5361

5462
#pragma warning disable CS8618
5563
[CodeAnalysis::SetsRequiredMembers]

src/Orb/Models/Coupons/CouponCreateParamsProperties/DiscountProperties/AmountProperties/DiscountType.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/Orb/Models/Coupons/CouponCreateParamsProperties/DiscountProperties/Percentage.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Generic = System.Collections.Generic;
33
using Json = System.Text.Json;
44
using Orb = Orb;
5-
using PercentageProperties = Orb.Models.Coupons.CouponCreateParamsProperties.DiscountProperties.PercentageProperties;
65
using Serialization = System.Text.Json.Serialization;
76
using System = System;
87

@@ -11,7 +10,7 @@ namespace Orb.Models.Coupons.CouponCreateParamsProperties.DiscountProperties;
1110
[Serialization::JsonConverter(typeof(Orb::ModelConverter<Percentage>))]
1211
public sealed record class Percentage : Orb::ModelBase, Orb::IFromRaw<Percentage>
1312
{
14-
public required PercentageProperties::DiscountType DiscountType
13+
public Json::JsonElement DiscountType
1514
{
1615
get
1716
{
@@ -21,8 +20,7 @@ public sealed record class Percentage : Orb::ModelBase, Orb::IFromRaw<Percentage
2120
"Missing required argument"
2221
);
2322

24-
return Json::JsonSerializer.Deserialize<PercentageProperties::DiscountType>(element)
25-
?? throw new System::ArgumentNullException("discount_type");
23+
return Json::JsonSerializer.Deserialize<Json::JsonElement>(element);
2624
}
2725
set { this.Properties["discount_type"] = Json::JsonSerializer.SerializeToElement(value); }
2826
}
@@ -47,11 +45,21 @@ public required double PercentageDiscount
4745

4846
public override void Validate()
4947
{
50-
this.DiscountType.Validate();
48+
if (
49+
!this.DiscountType.Equals(
50+
Json::JsonSerializer.Deserialize<Json::JsonElement>("\"percentage\"")
51+
)
52+
)
53+
{
54+
throw new System::Exception();
55+
}
5156
_ = this.PercentageDiscount;
5257
}
5358

54-
public Percentage() { }
59+
public Percentage()
60+
{
61+
this.DiscountType = Json::JsonSerializer.Deserialize<Json::JsonElement>("\"percentage\"");
62+
}
5563

5664
#pragma warning disable CS8618
5765
[CodeAnalysis::SetsRequiredMembers]

src/Orb/Models/Coupons/CouponCreateParamsProperties/DiscountProperties/PercentageProperties/DiscountType.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsProperties/BodyProperties/Amendment.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using AmendmentProperties = Orb.Models.Customers.Credits.Ledger.LedgerCreateEntryByExternalIDParamsProperties.BodyProperties.AmendmentProperties;
21
using CodeAnalysis = System.Diagnostics.CodeAnalysis;
32
using Generic = System.Collections.Generic;
43
using Json = System.Text.Json;
@@ -49,7 +48,7 @@ public required string BlockID
4948
set { this.Properties["block_id"] = Json::JsonSerializer.SerializeToElement(value); }
5049
}
5150

52-
public required AmendmentProperties::EntryType EntryType
51+
public Json::JsonElement EntryType
5352
{
5453
get
5554
{
@@ -59,8 +58,7 @@ public required string BlockID
5958
"Missing required argument"
6059
);
6160

62-
return Json::JsonSerializer.Deserialize<AmendmentProperties::EntryType>(element)
63-
?? throw new System::ArgumentNullException("entry_type");
61+
return Json::JsonSerializer.Deserialize<Json::JsonElement>(element);
6462
}
6563
set { this.Properties["entry_type"] = Json::JsonSerializer.SerializeToElement(value); }
6664
}
@@ -119,7 +117,14 @@ public override void Validate()
119117
{
120118
_ = this.Amount;
121119
_ = this.BlockID;
122-
this.EntryType.Validate();
120+
if (
121+
!this.EntryType.Equals(
122+
Json::JsonSerializer.Deserialize<Json::JsonElement>("\"amendment\"")
123+
)
124+
)
125+
{
126+
throw new System::Exception();
127+
}
123128
_ = this.Currency;
124129
_ = this.Description;
125130
if (this.Metadata != null)
@@ -131,7 +136,10 @@ public override void Validate()
131136
}
132137
}
133138

134-
public Amendment() { }
139+
public Amendment()
140+
{
141+
this.EntryType = Json::JsonSerializer.Deserialize<Json::JsonElement>("\"amendment\"");
142+
}
135143

136144
#pragma warning disable CS8618
137145
[CodeAnalysis::SetsRequiredMembers]

src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsProperties/BodyProperties/AmendmentProperties/EntryType.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParamsProperties/BodyProperties/Decrement.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using CodeAnalysis = System.Diagnostics.CodeAnalysis;
2-
using DecrementProperties = Orb.Models.Customers.Credits.Ledger.LedgerCreateEntryByExternalIDParamsProperties.BodyProperties.DecrementProperties;
32
using Generic = System.Collections.Generic;
43
using Json = System.Text.Json;
54
using Orb = Orb;
@@ -30,7 +29,7 @@ public required double Amount
3029
set { this.Properties["amount"] = Json::JsonSerializer.SerializeToElement(value); }
3130
}
3231

33-
public required DecrementProperties::EntryType EntryType
32+
public Json::JsonElement EntryType
3433
{
3534
get
3635
{
@@ -40,8 +39,7 @@ public required double Amount
4039
"Missing required argument"
4140
);
4241

43-
return Json::JsonSerializer.Deserialize<DecrementProperties::EntryType>(element)
44-
?? throw new System::ArgumentNullException("entry_type");
42+
return Json::JsonSerializer.Deserialize<Json::JsonElement>(element);
4543
}
4644
set { this.Properties["entry_type"] = Json::JsonSerializer.SerializeToElement(value); }
4745
}
@@ -99,7 +97,14 @@ public string? Description
9997
public override void Validate()
10098
{
10199
_ = this.Amount;
102-
this.EntryType.Validate();
100+
if (
101+
!this.EntryType.Equals(
102+
Json::JsonSerializer.Deserialize<Json::JsonElement>("\"decrement\"")
103+
)
104+
)
105+
{
106+
throw new System::Exception();
107+
}
103108
_ = this.Currency;
104109
_ = this.Description;
105110
if (this.Metadata != null)
@@ -111,7 +116,10 @@ public override void Validate()
111116
}
112117
}
113118

114-
public Decrement() { }
119+
public Decrement()
120+
{
121+
this.EntryType = Json::JsonSerializer.Deserialize<Json::JsonElement>("\"decrement\"");
122+
}
115123

116124
#pragma warning disable CS8618
117125
[CodeAnalysis::SetsRequiredMembers]

0 commit comments

Comments
 (0)