Skip to content

Commit 4ccd578

Browse files
feat(api): api update
1 parent 58e230c commit 4ccd578

17 files changed

+2866
-149
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-033643979990e894363554df06218fabe4493feaa569a013dbdf9a72aa21c45f.yml
3-
openapi_spec_hash: dd9d320ad178bafa06f1eac2977e2ca7
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-7936e3f73bbe1d59d27fd7a8a226985927b38fdec1c936c77577381699fb6140.yml
3+
openapi_spec_hash: 1d3f9ed5fbdb0e40d56d6acd9d1736e2
44
config_hash: e6db17547fe854b1c240407cf4c6dc9e

src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs

Lines changed: 276 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,284 @@
1+
using System.Collections.Generic;
12
using System.Text.Json;
3+
using Orb.Core;
24
using Orb.Models.Customers;
35

46
namespace Orb.Tests.Models.Customers;
57

8+
public class PaymentConfigurationTest : TestBase
9+
{
10+
[Fact]
11+
public void FieldRoundtrip_Works()
12+
{
13+
var model = new PaymentConfiguration
14+
{
15+
PaymentProviders =
16+
[
17+
new()
18+
{
19+
ProviderType = ProviderType.Stripe,
20+
ExcludedPaymentMethodTypes = ["string"],
21+
},
22+
],
23+
};
24+
25+
List<PaymentProvider> expectedPaymentProviders =
26+
[
27+
new() { ProviderType = ProviderType.Stripe, ExcludedPaymentMethodTypes = ["string"] },
28+
];
29+
30+
Assert.Equal(expectedPaymentProviders.Count, model.PaymentProviders.Count);
31+
for (int i = 0; i < expectedPaymentProviders.Count; i++)
32+
{
33+
Assert.Equal(expectedPaymentProviders[i], model.PaymentProviders[i]);
34+
}
35+
}
36+
37+
[Fact]
38+
public void SerializationRoundtrip_Works()
39+
{
40+
var model = new PaymentConfiguration
41+
{
42+
PaymentProviders =
43+
[
44+
new()
45+
{
46+
ProviderType = ProviderType.Stripe,
47+
ExcludedPaymentMethodTypes = ["string"],
48+
},
49+
],
50+
};
51+
52+
string json = JsonSerializer.Serialize(model);
53+
var deserialized = JsonSerializer.Deserialize<PaymentConfiguration>(json);
54+
55+
Assert.Equal(model, deserialized);
56+
}
57+
58+
[Fact]
59+
public void FieldRoundtripThroughSerialization_Works()
60+
{
61+
var model = new PaymentConfiguration
62+
{
63+
PaymentProviders =
64+
[
65+
new()
66+
{
67+
ProviderType = ProviderType.Stripe,
68+
ExcludedPaymentMethodTypes = ["string"],
69+
},
70+
],
71+
};
72+
73+
string json = JsonSerializer.Serialize(model);
74+
var deserialized = JsonSerializer.Deserialize<PaymentConfiguration>(json);
75+
Assert.NotNull(deserialized);
76+
77+
List<PaymentProvider> expectedPaymentProviders =
78+
[
79+
new() { ProviderType = ProviderType.Stripe, ExcludedPaymentMethodTypes = ["string"] },
80+
];
81+
82+
Assert.Equal(expectedPaymentProviders.Count, deserialized.PaymentProviders.Count);
83+
for (int i = 0; i < expectedPaymentProviders.Count; i++)
84+
{
85+
Assert.Equal(expectedPaymentProviders[i], deserialized.PaymentProviders[i]);
86+
}
87+
}
88+
89+
[Fact]
90+
public void Validation_Works()
91+
{
92+
var model = new PaymentConfiguration
93+
{
94+
PaymentProviders =
95+
[
96+
new()
97+
{
98+
ProviderType = ProviderType.Stripe,
99+
ExcludedPaymentMethodTypes = ["string"],
100+
},
101+
],
102+
};
103+
104+
model.Validate();
105+
}
106+
107+
[Fact]
108+
public void OptionalNonNullablePropertiesUnsetAreNotSet_Works()
109+
{
110+
var model = new PaymentConfiguration { };
111+
112+
Assert.Null(model.PaymentProviders);
113+
Assert.False(model.RawData.ContainsKey("payment_providers"));
114+
}
115+
116+
[Fact]
117+
public void OptionalNonNullablePropertiesUnsetValidation_Works()
118+
{
119+
var model = new PaymentConfiguration { };
120+
121+
model.Validate();
122+
}
123+
124+
[Fact]
125+
public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works()
126+
{
127+
var model = new PaymentConfiguration
128+
{
129+
// Null should be interpreted as omitted for these properties
130+
PaymentProviders = null,
131+
};
132+
133+
Assert.Null(model.PaymentProviders);
134+
Assert.False(model.RawData.ContainsKey("payment_providers"));
135+
}
136+
137+
[Fact]
138+
public void OptionalNonNullablePropertiesSetToNullValidation_Works()
139+
{
140+
var model = new PaymentConfiguration
141+
{
142+
// Null should be interpreted as omitted for these properties
143+
PaymentProviders = null,
144+
};
145+
146+
model.Validate();
147+
}
148+
}
149+
150+
public class PaymentProviderTest : TestBase
151+
{
152+
[Fact]
153+
public void FieldRoundtrip_Works()
154+
{
155+
var model = new PaymentProvider
156+
{
157+
ProviderType = ProviderType.Stripe,
158+
ExcludedPaymentMethodTypes = ["string"],
159+
};
160+
161+
ApiEnum<string, ProviderType> expectedProviderType = ProviderType.Stripe;
162+
List<string> expectedExcludedPaymentMethodTypes = ["string"];
163+
164+
Assert.Equal(expectedProviderType, model.ProviderType);
165+
Assert.Equal(
166+
expectedExcludedPaymentMethodTypes.Count,
167+
model.ExcludedPaymentMethodTypes.Count
168+
);
169+
for (int i = 0; i < expectedExcludedPaymentMethodTypes.Count; i++)
170+
{
171+
Assert.Equal(
172+
expectedExcludedPaymentMethodTypes[i],
173+
model.ExcludedPaymentMethodTypes[i]
174+
);
175+
}
176+
}
177+
178+
[Fact]
179+
public void SerializationRoundtrip_Works()
180+
{
181+
var model = new PaymentProvider
182+
{
183+
ProviderType = ProviderType.Stripe,
184+
ExcludedPaymentMethodTypes = ["string"],
185+
};
186+
187+
string json = JsonSerializer.Serialize(model);
188+
var deserialized = JsonSerializer.Deserialize<PaymentProvider>(json);
189+
190+
Assert.Equal(model, deserialized);
191+
}
192+
193+
[Fact]
194+
public void FieldRoundtripThroughSerialization_Works()
195+
{
196+
var model = new PaymentProvider
197+
{
198+
ProviderType = ProviderType.Stripe,
199+
ExcludedPaymentMethodTypes = ["string"],
200+
};
201+
202+
string json = JsonSerializer.Serialize(model);
203+
var deserialized = JsonSerializer.Deserialize<PaymentProvider>(json);
204+
Assert.NotNull(deserialized);
205+
206+
ApiEnum<string, ProviderType> expectedProviderType = ProviderType.Stripe;
207+
List<string> expectedExcludedPaymentMethodTypes = ["string"];
208+
209+
Assert.Equal(expectedProviderType, deserialized.ProviderType);
210+
Assert.Equal(
211+
expectedExcludedPaymentMethodTypes.Count,
212+
deserialized.ExcludedPaymentMethodTypes.Count
213+
);
214+
for (int i = 0; i < expectedExcludedPaymentMethodTypes.Count; i++)
215+
{
216+
Assert.Equal(
217+
expectedExcludedPaymentMethodTypes[i],
218+
deserialized.ExcludedPaymentMethodTypes[i]
219+
);
220+
}
221+
}
222+
223+
[Fact]
224+
public void Validation_Works()
225+
{
226+
var model = new PaymentProvider
227+
{
228+
ProviderType = ProviderType.Stripe,
229+
ExcludedPaymentMethodTypes = ["string"],
230+
};
231+
232+
model.Validate();
233+
}
234+
235+
[Fact]
236+
public void OptionalNonNullablePropertiesUnsetAreNotSet_Works()
237+
{
238+
var model = new PaymentProvider { ProviderType = ProviderType.Stripe };
239+
240+
Assert.Null(model.ExcludedPaymentMethodTypes);
241+
Assert.False(model.RawData.ContainsKey("excluded_payment_method_types"));
242+
}
243+
244+
[Fact]
245+
public void OptionalNonNullablePropertiesUnsetValidation_Works()
246+
{
247+
var model = new PaymentProvider { ProviderType = ProviderType.Stripe };
248+
249+
model.Validate();
250+
}
251+
252+
[Fact]
253+
public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works()
254+
{
255+
var model = new PaymentProvider
256+
{
257+
ProviderType = ProviderType.Stripe,
258+
259+
// Null should be interpreted as omitted for these properties
260+
ExcludedPaymentMethodTypes = null,
261+
};
262+
263+
Assert.Null(model.ExcludedPaymentMethodTypes);
264+
Assert.False(model.RawData.ContainsKey("excluded_payment_method_types"));
265+
}
266+
267+
[Fact]
268+
public void OptionalNonNullablePropertiesSetToNullValidation_Works()
269+
{
270+
var model = new PaymentProvider
271+
{
272+
ProviderType = ProviderType.Stripe,
273+
274+
// Null should be interpreted as omitted for these properties
275+
ExcludedPaymentMethodTypes = null,
276+
};
277+
278+
model.Validate();
279+
}
280+
}
281+
6282
public class NumeralTest : TestBase
7283
{
8284
[Fact]

0 commit comments

Comments
 (0)