Skip to content

Commit 5820227

Browse files
feat(api): api update
1 parent e99472a commit 5820227

File tree

6 files changed

+62
-11
lines changed

6 files changed

+62
-11
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: 139
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-0186c0310e2a9f40302cc35f4248fca335b7ec8069502f684ba6f2fa37793033.yml
3-
openapi_spec_hash: 4fb1d2837ad3794864a7d59d393d6ff6
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-5bb582f84f0b4cf7bef84833fefd48a5f2734dc25805da2028fd8a6f1198da07.yml
3+
openapi_spec_hash: ced0e30dc67faa2414df511819408f12
44
config_hash: 3279841440b02d4e8303c961d6983492

src/Orb.Tests/Models/Invoices/InvoiceCreateParamsTest.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public void FieldRoundtrip_Works()
3030
UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true },
3131
},
3232
],
33+
AutoCollection = true,
3334
CustomerID = "4khy3nwzktxv7",
3435
Discount = new Models::PercentageDiscount()
3536
{
@@ -70,6 +71,7 @@ public void FieldRoundtrip_Works()
7071
UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true },
7172
},
7273
];
74+
bool expectedAutoCollection = true;
7375
string expectedCustomerID = "4khy3nwzktxv7";
7476
Models::SharedDiscount expectedDiscount = new Models::PercentageDiscount()
7577
{
@@ -101,6 +103,7 @@ public void FieldRoundtrip_Works()
101103
{
102104
Assert.Equal(expectedLineItems[i], parameters.LineItems[i]);
103105
}
106+
Assert.Equal(expectedAutoCollection, parameters.AutoCollection);
104107
Assert.Equal(expectedCustomerID, parameters.CustomerID);
105108
Assert.Equal(expectedDiscount, parameters.Discount);
106109
Assert.Equal(expectedDueDate, parameters.DueDate);
@@ -138,6 +141,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works()
138141
UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true },
139142
},
140143
],
144+
AutoCollection = true,
141145
CustomerID = "4khy3nwzktxv7",
142146
Discount = new Models::PercentageDiscount()
143147
{
@@ -186,6 +190,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works()
186190
UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true },
187191
},
188192
],
193+
AutoCollection = true,
189194
CustomerID = "4khy3nwzktxv7",
190195
Discount = new Models::PercentageDiscount()
191196
{
@@ -240,6 +245,8 @@ public void OptionalNullableParamsUnsetAreNotSet_Works()
240245
WillAutoIssue = false,
241246
};
242247

248+
Assert.Null(parameters.AutoCollection);
249+
Assert.False(parameters.RawBodyData.ContainsKey("auto_collection"));
243250
Assert.Null(parameters.CustomerID);
244251
Assert.False(parameters.RawBodyData.ContainsKey("customer_id"));
245252
Assert.Null(parameters.Discount);
@@ -278,6 +285,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works()
278285
],
279286
WillAutoIssue = false,
280287

288+
AutoCollection = null,
281289
CustomerID = null,
282290
Discount = null,
283291
DueDate = null,
@@ -287,6 +295,8 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works()
287295
NetTerms = null,
288296
};
289297

298+
Assert.Null(parameters.AutoCollection);
299+
Assert.True(parameters.RawBodyData.ContainsKey("auto_collection"));
290300
Assert.Null(parameters.CustomerID);
291301
Assert.True(parameters.RawBodyData.ContainsKey("customer_id"));
292302
Assert.Null(parameters.Discount);
@@ -350,6 +360,7 @@ public void CopyConstructor_Works()
350360
UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true },
351361
},
352362
],
363+
AutoCollection = true,
353364
CustomerID = "4khy3nwzktxv7",
354365
Discount = new Models::PercentageDiscount()
355366
{

src/Orb.Tests/Models/Invoices/InvoiceUpdateParamsTest.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@ public void FieldRoundtrip_Works()
1414
var parameters = new InvoiceUpdateParams
1515
{
1616
InvoiceID = "invoice_id",
17+
AutoCollection = true,
1718
DueDate = "2023-09-22",
1819
InvoiceDate = "2023-09-22",
1920
Metadata = new Dictionary<string, string?>() { { "foo", "string" } },
2021
NetTerms = 0,
2122
};
2223

2324
string expectedInvoiceID = "invoice_id";
25+
bool expectedAutoCollection = true;
2426
InvoiceUpdateParamsDueDate expectedDueDate = "2023-09-22";
2527
InvoiceDate expectedInvoiceDate = "2023-09-22";
2628
Dictionary<string, string?> expectedMetadata = new() { { "foo", "string" } };
2729
long expectedNetTerms = 0;
2830

2931
Assert.Equal(expectedInvoiceID, parameters.InvoiceID);
32+
Assert.Equal(expectedAutoCollection, parameters.AutoCollection);
3033
Assert.Equal(expectedDueDate, parameters.DueDate);
3134
Assert.Equal(expectedInvoiceDate, parameters.InvoiceDate);
3235
Assert.NotNull(parameters.Metadata);
@@ -45,6 +48,8 @@ public void OptionalNullableParamsUnsetAreNotSet_Works()
4548
{
4649
var parameters = new InvoiceUpdateParams { InvoiceID = "invoice_id" };
4750

51+
Assert.Null(parameters.AutoCollection);
52+
Assert.False(parameters.RawBodyData.ContainsKey("auto_collection"));
4853
Assert.Null(parameters.DueDate);
4954
Assert.False(parameters.RawBodyData.ContainsKey("due_date"));
5055
Assert.Null(parameters.InvoiceDate);
@@ -62,12 +67,15 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works()
6267
{
6368
InvoiceID = "invoice_id",
6469

70+
AutoCollection = null,
6571
DueDate = null,
6672
InvoiceDate = null,
6773
Metadata = null,
6874
NetTerms = null,
6975
};
7076

77+
Assert.Null(parameters.AutoCollection);
78+
Assert.True(parameters.RawBodyData.ContainsKey("auto_collection"));
7179
Assert.Null(parameters.DueDate);
7280
Assert.True(parameters.RawBodyData.ContainsKey("due_date"));
7381
Assert.Null(parameters.InvoiceDate);
@@ -94,6 +102,7 @@ public void CopyConstructor_Works()
94102
var parameters = new InvoiceUpdateParams
95103
{
96104
InvoiceID = "invoice_id",
105+
AutoCollection = true,
97106
DueDate = "2023-09-22",
98107
InvoiceDate = "2023-09-22",
99108
Metadata = new Dictionary<string, string?>() { { "foo", "string" } },

src/Orb/Models/Invoices/InvoiceCreateParams.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,21 @@ public required IReadOnlyList<LineItem> LineItems
7171
}
7272
}
7373

74+
/// <summary>
75+
/// Determines whether this invoice will automatically attempt to charge a saved
76+
/// payment method, if any. If not specified, the invoice inherits the customer's
77+
/// auto_collection setting.
78+
/// </summary>
79+
public bool? AutoCollection
80+
{
81+
get
82+
{
83+
this._rawBodyData.Freeze();
84+
return this._rawBodyData.GetNullableStruct<bool>("auto_collection");
85+
}
86+
init { this._rawBodyData.Set("auto_collection", value); }
87+
}
88+
7489
/// <summary>
7590
/// The id of the `Customer` to create this invoice for. One of `customer_id`
7691
/// and `external_customer_id` are required.

src/Orb/Models/Invoices/InvoiceUpdateParams.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
namespace Orb.Models.Invoices;
1313

1414
/// <summary>
15-
/// This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and
16-
/// `invoice_date` properties on an invoice. If you pass null for the metadata value,
17-
/// it will clear any existing metadata for that invoice.
15+
/// This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`,
16+
/// and `auto_collection` properties on an invoice. If you pass null for the metadata
17+
/// value, it will clear any existing metadata for that invoice.
1818
///
1919
/// <para>`metadata` can be modified regardless of invoice state. `net_terms`, `due_date`,
20-
/// and `invoice_date` can only be modified if the invoice is in a `draft` state.
21-
/// `invoice_date` can only be modified for non-subscription invoices.</para>
20+
/// `invoice_date`, and `auto_collection` can only be modified if the invoice is in
21+
/// a `draft` state. `invoice_date` can only be modified for non-subscription invoices.</para>
2222
///
2323
/// <para>NOTE: Do not inherit from this type outside the SDK unless you're okay with
2424
/// breaking changes in non-major versions. We may add new methods in the future that
@@ -34,6 +34,21 @@ public IReadOnlyDictionary<string, JsonElement> RawBodyData
3434

3535
public string? InvoiceID { get; init; }
3636

37+
/// <summary>
38+
/// Determines whether this invoice will automatically attempt to charge a saved
39+
/// payment method, if any. Can only be modified on draft invoices. If not specified,
40+
/// the invoice's existing setting is unchanged.
41+
/// </summary>
42+
public bool? AutoCollection
43+
{
44+
get
45+
{
46+
this._rawBodyData.Freeze();
47+
return this._rawBodyData.GetNullableStruct<bool>("auto_collection");
48+
}
49+
init { this._rawBodyData.Set("auto_collection", value); }
50+
}
51+
3752
/// <summary>
3853
/// An optional custom due date for the invoice. If not set, the due date will
3954
/// be calculated based on the `net_terms` value.

src/Orb/Services/IInvoiceService.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ Task<Invoice> Create(
4343

4444
/// <summary>
4545
/// This endpoint allows you to update the `metadata`, `net_terms`, `due_date`,
46-
/// and `invoice_date` properties on an invoice. If you pass null for the metadata
47-
/// value, it will clear any existing metadata for that invoice.
46+
/// `invoice_date`, and `auto_collection` properties on an invoice. If you pass
47+
/// null for the metadata value, it will clear any existing metadata for that invoice.
4848
///
4949
/// <para>`metadata` can be modified regardless of invoice state. `net_terms`,
50-
/// `due_date`, and `invoice_date` can only be modified if the invoice is in a
51-
/// `draft` state. `invoice_date` can only be modified for non-subscription invoices.</para>
50+
/// `due_date`, `invoice_date`, and `auto_collection` can only be modified if
51+
/// the invoice is in a `draft` state. `invoice_date` can only be modified for
52+
/// non-subscription invoices.</para>
5253
/// </summary>
5354
Task<Invoice> Update(
5455
InvoiceUpdateParams parameters,

0 commit comments

Comments
 (0)