Skip to content

Commit 9504b00

Browse files
feat(api): api update
1 parent 713ee01 commit 9504b00

File tree

10 files changed

+539
-7
lines changed

10 files changed

+539
-7
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 118
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-faf1f7c723d2762f09e9690ef2ceda58cb0a6ddacf1a79c3754871b90e7db0dc.yml
3-
openapi_spec_hash: 22269f85fae1ec920bdb0b32435a7aa8
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-79664fa0b4ea00c978ae2516087d0ee591b0ef92ca8db29557a0424bde520e10.yml
3+
openapi_spec_hash: 1ff6eee9184312a3a0fd21eb589132f9
44
config_hash: dd4343ce95871032ef6e0735a4ca038c

src/Orb/Core/ModelBase.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
using Orb.Models.ChangedSubscriptionResourcesProperties.CreatedInvoiceProperties.PaymentAttemptProperties;
99
using Orb.Models.CreditNotes.CreditNoteCreateParamsProperties;
1010
using Orb.Models.Customers.Costs.CostListParamsProperties;
11-
using Orb.Models.Customers.Credits.CreditListPageResponseProperties.DataProperties;
1211
using Orb.Models.Customers.Credits.Ledger.AmendmentLedgerEntryProperties;
1312
using Orb.Models.Customers.Credits.TopUps.TopUpCreateResponseProperties;
1413
using Orb.Models.Customers.CustomerProperties.AccountingSyncConfigurationProperties.AccountingProviderProperties;
1514
using Orb.Models.Customers.NewAvalaraTaxConfigurationProperties;
15+
using Orb.Models.Events.Backfills.BackfillCreateResponseProperties;
1616
using Orb.Models.Invoices.InvoiceCreateParamsProperties.LineItemProperties;
1717
using Orb.Models.Items.ItemProperties.ExternalConnectionProperties;
1818
using Orb.Models.NewAllocationPriceProperties;
@@ -28,7 +28,6 @@
2828
using AlertProperties = Orb.Models.Alerts.AlertProperties;
2929
using AmountDiscountIntervalProperties = Orb.Models.AmountDiscountIntervalProperties;
3030
using BackfillCloseResponseProperties = Orb.Models.Events.Backfills.BackfillCloseResponseProperties;
31-
using BackfillCreateResponseProperties = Orb.Models.Events.Backfills.BackfillCreateResponseProperties;
3231
using BackfillFetchResponseProperties = Orb.Models.Events.Backfills.BackfillFetchResponseProperties;
3332
using BackfillRevertResponseProperties = Orb.Models.Events.Backfills.BackfillRevertResponseProperties;
3433
using BalanceTransactionCreateParamsProperties = Orb.Models.Customers.BalanceTransactions.BalanceTransactionCreateParamsProperties;
@@ -50,7 +49,7 @@
5049
using CustomerUpdateByExternalIDParamsProperties = Orb.Models.Customers.CustomerUpdateByExternalIDParamsProperties;
5150
using CustomerUpdateParamsProperties = Orb.Models.Customers.CustomerUpdateParamsProperties;
5251
using CustomExpirationProperties = Orb.Models.CustomExpirationProperties;
53-
using DataProperties = Orb.Models.Customers.Credits.CreditListByExternalIDPageResponseProperties.DataProperties;
52+
using DataProperties = Orb.Models.Customers.Credits.CreditListPageResponseProperties.DataProperties;
5453
using DecrementLedgerEntryProperties = Orb.Models.Customers.Credits.Ledger.DecrementLedgerEntryProperties;
5554
using DiscountOverrideProperties = Orb.Models.Subscriptions.DiscountOverrideProperties;
5655
using DiscountProperties = Orb.Models.CreditNoteProperties.LineItemProperties.DiscountProperties;
@@ -1124,8 +1123,27 @@ public abstract record class ModelBase
11241123
>(),
11251124
new ApiEnumConverter<string, ViewMode>(),
11261125
new ApiEnumConverter<string, CostListByExternalIDParamsProperties::ViewMode>(),
1127-
new ApiEnumConverter<string, Status>(),
1126+
new ApiEnumConverter<
1127+
string,
1128+
global::Orb.Models.Customers.Credits.CreditListPageResponseProperties.DataProperties.FilterProperties.Field
1129+
>(),
1130+
new ApiEnumConverter<
1131+
string,
1132+
global::Orb.Models.Customers.Credits.CreditListPageResponseProperties.DataProperties.FilterProperties.Operator
1133+
>(),
11281134
new ApiEnumConverter<string, DataProperties::Status>(),
1135+
new ApiEnumConverter<
1136+
string,
1137+
global::Orb.Models.Customers.Credits.CreditListByExternalIDPageResponseProperties.DataProperties.FilterProperties.Field
1138+
>(),
1139+
new ApiEnumConverter<
1140+
string,
1141+
global::Orb.Models.Customers.Credits.CreditListByExternalIDPageResponseProperties.DataProperties.FilterProperties.Operator
1142+
>(),
1143+
new ApiEnumConverter<
1144+
string,
1145+
global::Orb.Models.Customers.Credits.CreditListByExternalIDPageResponseProperties.DataProperties.Status
1146+
>(),
11291147
new ApiEnumConverter<
11301148
string,
11311149
global::Orb.Models.Customers.Credits.Ledger.AffectedBlockProperties.FilterProperties.Field
@@ -1186,7 +1204,7 @@ public abstract record class ModelBase
11861204
global::Orb.Models.Customers.BalanceTransactions.BalanceTransactionListPageResponseProperties.DataProperties.Type
11871205
>(),
11881206
new ApiEnumConverter<string, BalanceTransactionCreateParamsProperties::Type>(),
1189-
new ApiEnumConverter<string, BackfillCreateResponseProperties::Status>(),
1207+
new ApiEnumConverter<string, Status>(),
11901208
new ApiEnumConverter<
11911209
string,
11921210
global::Orb.Models.Events.Backfills.BackfillListPageResponseProperties.DataProperties.Status

src/Orb/Models/Customers/Credits/CreditListByExternalIDPageResponseProperties/Data.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,31 @@ public required DateTime? ExpiryDate
9494
}
9595
}
9696

97+
public required List<Filter> Filters
98+
{
99+
get
100+
{
101+
if (!this.Properties.TryGetValue("filters", out JsonElement element))
102+
throw new OrbInvalidDataException(
103+
"'filters' cannot be null",
104+
new ArgumentOutOfRangeException("filters", "Missing required argument")
105+
);
106+
107+
return JsonSerializer.Deserialize<List<Filter>>(element, ModelBase.SerializerOptions)
108+
?? throw new OrbInvalidDataException(
109+
"'filters' cannot be null",
110+
new ArgumentNullException("filters")
111+
);
112+
}
113+
set
114+
{
115+
this.Properties["filters"] = JsonSerializer.SerializeToElement(
116+
value,
117+
ModelBase.SerializerOptions
118+
);
119+
}
120+
}
121+
97122
public required double? MaximumInitialBalance
98123
{
99124
get
@@ -160,6 +185,10 @@ public override void Validate()
160185
_ = this.Balance;
161186
_ = this.EffectiveDate;
162187
_ = this.ExpiryDate;
188+
foreach (var item in this.Filters)
189+
{
190+
item.Validate();
191+
}
163192
_ = this.MaximumInitialBalance;
164193
_ = this.PerUnitCostBasis;
165194
this.Status.Validate();
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
4+
using System.Text.Json;
5+
using System.Text.Json.Serialization;
6+
using Orb.Core;
7+
using Orb.Exceptions;
8+
using Orb.Models.Customers.Credits.CreditListByExternalIDPageResponseProperties.DataProperties.FilterProperties;
9+
10+
namespace Orb.Models.Customers.Credits.CreditListByExternalIDPageResponseProperties.DataProperties;
11+
12+
[JsonConverter(typeof(ModelConverter<Filter>))]
13+
public sealed record class Filter : ModelBase, IFromRaw<Filter>
14+
{
15+
/// <summary>
16+
/// The property of the price to filter on.
17+
/// </summary>
18+
public required ApiEnum<string, Field> Field
19+
{
20+
get
21+
{
22+
if (!this.Properties.TryGetValue("field", out JsonElement element))
23+
throw new OrbInvalidDataException(
24+
"'field' cannot be null",
25+
new ArgumentOutOfRangeException("field", "Missing required argument")
26+
);
27+
28+
return JsonSerializer.Deserialize<ApiEnum<string, Field>>(
29+
element,
30+
ModelBase.SerializerOptions
31+
);
32+
}
33+
set
34+
{
35+
this.Properties["field"] = JsonSerializer.SerializeToElement(
36+
value,
37+
ModelBase.SerializerOptions
38+
);
39+
}
40+
}
41+
42+
/// <summary>
43+
/// Should prices that match the filter be included or excluded.
44+
/// </summary>
45+
public required ApiEnum<string, Operator> Operator
46+
{
47+
get
48+
{
49+
if (!this.Properties.TryGetValue("operator", out JsonElement element))
50+
throw new OrbInvalidDataException(
51+
"'operator' cannot be null",
52+
new ArgumentOutOfRangeException("operator", "Missing required argument")
53+
);
54+
55+
return JsonSerializer.Deserialize<ApiEnum<string, Operator>>(
56+
element,
57+
ModelBase.SerializerOptions
58+
);
59+
}
60+
set
61+
{
62+
this.Properties["operator"] = JsonSerializer.SerializeToElement(
63+
value,
64+
ModelBase.SerializerOptions
65+
);
66+
}
67+
}
68+
69+
/// <summary>
70+
/// The IDs or values that match this filter.
71+
/// </summary>
72+
public required List<string> Values
73+
{
74+
get
75+
{
76+
if (!this.Properties.TryGetValue("values", out JsonElement element))
77+
throw new OrbInvalidDataException(
78+
"'values' cannot be null",
79+
new ArgumentOutOfRangeException("values", "Missing required argument")
80+
);
81+
82+
return JsonSerializer.Deserialize<List<string>>(element, ModelBase.SerializerOptions)
83+
?? throw new OrbInvalidDataException(
84+
"'values' cannot be null",
85+
new ArgumentNullException("values")
86+
);
87+
}
88+
set
89+
{
90+
this.Properties["values"] = JsonSerializer.SerializeToElement(
91+
value,
92+
ModelBase.SerializerOptions
93+
);
94+
}
95+
}
96+
97+
public override void Validate()
98+
{
99+
this.Field.Validate();
100+
this.Operator.Validate();
101+
foreach (var item in this.Values)
102+
{
103+
_ = item;
104+
}
105+
}
106+
107+
public Filter() { }
108+
109+
#pragma warning disable CS8618
110+
[SetsRequiredMembers]
111+
Filter(Dictionary<string, JsonElement> properties)
112+
{
113+
Properties = properties;
114+
}
115+
#pragma warning restore CS8618
116+
117+
public static Filter FromRawUnchecked(Dictionary<string, JsonElement> properties)
118+
{
119+
return new(properties);
120+
}
121+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using System.Text.Json;
3+
using System.Text.Json.Serialization;
4+
using Orb.Exceptions;
5+
6+
namespace Orb.Models.Customers.Credits.CreditListByExternalIDPageResponseProperties.DataProperties.FilterProperties;
7+
8+
/// <summary>
9+
/// The property of the price to filter on.
10+
/// </summary>
11+
[JsonConverter(typeof(FieldConverter))]
12+
public enum Field
13+
{
14+
PriceID,
15+
ItemID,
16+
PriceType,
17+
Currency,
18+
PricingUnitID,
19+
}
20+
21+
sealed class FieldConverter : JsonConverter<Field>
22+
{
23+
public override Field Read(
24+
ref Utf8JsonReader reader,
25+
Type typeToConvert,
26+
JsonSerializerOptions options
27+
)
28+
{
29+
return JsonSerializer.Deserialize<string>(ref reader, options) switch
30+
{
31+
"price_id" => Field.PriceID,
32+
"item_id" => Field.ItemID,
33+
"price_type" => Field.PriceType,
34+
"currency" => Field.Currency,
35+
"pricing_unit_id" => Field.PricingUnitID,
36+
_ => (Field)(-1),
37+
};
38+
}
39+
40+
public override void Write(Utf8JsonWriter writer, Field value, JsonSerializerOptions options)
41+
{
42+
JsonSerializer.Serialize(
43+
writer,
44+
value switch
45+
{
46+
Field.PriceID => "price_id",
47+
Field.ItemID => "item_id",
48+
Field.PriceType => "price_type",
49+
Field.Currency => "currency",
50+
Field.PricingUnitID => "pricing_unit_id",
51+
_ => throw new OrbInvalidDataException(
52+
string.Format("Invalid value '{0}' in {1}", value, nameof(value))
53+
),
54+
},
55+
options
56+
);
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Text.Json;
3+
using System.Text.Json.Serialization;
4+
using Orb.Exceptions;
5+
6+
namespace Orb.Models.Customers.Credits.CreditListByExternalIDPageResponseProperties.DataProperties.FilterProperties;
7+
8+
/// <summary>
9+
/// Should prices that match the filter be included or excluded.
10+
/// </summary>
11+
[JsonConverter(typeof(OperatorConverter))]
12+
public enum Operator
13+
{
14+
Includes,
15+
Excludes,
16+
}
17+
18+
sealed class OperatorConverter : JsonConverter<Operator>
19+
{
20+
public override Operator Read(
21+
ref Utf8JsonReader reader,
22+
Type typeToConvert,
23+
JsonSerializerOptions options
24+
)
25+
{
26+
return JsonSerializer.Deserialize<string>(ref reader, options) switch
27+
{
28+
"includes" => Operator.Includes,
29+
"excludes" => Operator.Excludes,
30+
_ => (Operator)(-1),
31+
};
32+
}
33+
34+
public override void Write(Utf8JsonWriter writer, Operator value, JsonSerializerOptions options)
35+
{
36+
JsonSerializer.Serialize(
37+
writer,
38+
value switch
39+
{
40+
Operator.Includes => "includes",
41+
Operator.Excludes => "excludes",
42+
_ => throw new OrbInvalidDataException(
43+
string.Format("Invalid value '{0}' in {1}", value, nameof(value))
44+
),
45+
},
46+
options
47+
);
48+
}
49+
}

src/Orb/Models/Customers/Credits/CreditListPageResponseProperties/Data.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,31 @@ public required DateTime? ExpiryDate
9494
}
9595
}
9696

97+
public required List<Filter> Filters
98+
{
99+
get
100+
{
101+
if (!this.Properties.TryGetValue("filters", out JsonElement element))
102+
throw new OrbInvalidDataException(
103+
"'filters' cannot be null",
104+
new ArgumentOutOfRangeException("filters", "Missing required argument")
105+
);
106+
107+
return JsonSerializer.Deserialize<List<Filter>>(element, ModelBase.SerializerOptions)
108+
?? throw new OrbInvalidDataException(
109+
"'filters' cannot be null",
110+
new ArgumentNullException("filters")
111+
);
112+
}
113+
set
114+
{
115+
this.Properties["filters"] = JsonSerializer.SerializeToElement(
116+
value,
117+
ModelBase.SerializerOptions
118+
);
119+
}
120+
}
121+
97122
public required double? MaximumInitialBalance
98123
{
99124
get
@@ -160,6 +185,10 @@ public override void Validate()
160185
_ = this.Balance;
161186
_ = this.EffectiveDate;
162187
_ = this.ExpiryDate;
188+
foreach (var item in this.Filters)
189+
{
190+
item.Validate();
191+
}
163192
_ = this.MaximumInitialBalance;
164193
_ = this.PerUnitCostBasis;
165194
this.Status.Validate();

0 commit comments

Comments
 (0)