Skip to content

Commit 84cc66c

Browse files
feat(api): api update
1 parent ab79480 commit 84cc66c

File tree

7 files changed

+236
-84
lines changed

7 files changed

+236
-84
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-b070c1d97a6e3b400f43d2bce36c22ed89d432345b26374728c55dd0a20f0afa.yml
3-
openapi_spec_hash: dba4ff52c381cda6159fc56d8b77eb32
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-15e42bc01739abea4a925894a1a7de447de40b003a3433461952e8e06919588b.yml
3+
openapi_spec_hash: 8a0bc5b6ab417f7256cbf83d70c459a3
44
config_hash: 1f73a949b649ecfe6ec68ba1bb459dc2

orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt

Lines changed: 187 additions & 78 deletions
Large diffs are not rendered by default.

orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsync.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ interface InvoiceLineItemServiceAsync {
2727
/**
2828
* This creates a one-off fixed fee invoice line item on an Invoice. This can only be done for
2929
* invoices that are in a `draft` status.
30+
*
31+
* The behavior depends on which parameters are provided:
32+
* - If `item_id` is provided without `name`: The item is looked up by ID, and the item's name
33+
* is used for the line item.
34+
* - If `name` is provided without `item_id`: An item with the given name is searched for in the
35+
* account. If found, that item is used. If not found, a new item is created with that name.
36+
* The new item's name is used for the line item.
37+
* - If both `item_id` and `name` are provided: The item is looked up by ID for association, but
38+
* the provided `name` is used for the line item (not the item's name).
3039
*/
3140
fun create(
3241
params: InvoiceLineItemCreateParams

orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceLineItemService.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ interface InvoiceLineItemService {
2727
/**
2828
* This creates a one-off fixed fee invoice line item on an Invoice. This can only be done for
2929
* invoices that are in a `draft` status.
30+
*
31+
* The behavior depends on which parameters are provided:
32+
* - If `item_id` is provided without `name`: The item is looked up by ID, and the item's name
33+
* is used for the line item.
34+
* - If `name` is provided without `item_id`: An item with the given name is searched for in the
35+
* account. If found, that item is used. If not found, a new item is created with that name.
36+
* The new item's name is used for the line item.
37+
* - If both `item_id` and `name` are provided: The item is looked up by ID for association, but
38+
* the provided `name` is used for the line item (not the item's name).
3039
*/
3140
fun create(params: InvoiceLineItemCreateParams): InvoiceLineItemCreateResponse =
3241
create(params, RequestOptions.none())

orb-java-core/src/test/kotlin/com/withorb/api/models/InvoiceLineItemCreateParamsTest.kt

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ internal class InvoiceLineItemCreateParamsTest {
1414
.amount("12.00")
1515
.endDate(LocalDate.parse("2023-09-22"))
1616
.invoiceId("4khy3nwzktxv7")
17-
.name("Item Name")
1817
.quantity(1.0)
1918
.startDate(LocalDate.parse("2023-09-22"))
19+
.itemId("4khy3nwzktxv7")
20+
.name("Item Name")
2021
.build()
2122
}
2223

@@ -27,7 +28,30 @@ internal class InvoiceLineItemCreateParamsTest {
2728
.amount("12.00")
2829
.endDate(LocalDate.parse("2023-09-22"))
2930
.invoiceId("4khy3nwzktxv7")
31+
.quantity(1.0)
32+
.startDate(LocalDate.parse("2023-09-22"))
33+
.itemId("4khy3nwzktxv7")
3034
.name("Item Name")
35+
.build()
36+
37+
val body = params._body()
38+
39+
assertThat(body.amount()).isEqualTo("12.00")
40+
assertThat(body.endDate()).isEqualTo(LocalDate.parse("2023-09-22"))
41+
assertThat(body.invoiceId()).isEqualTo("4khy3nwzktxv7")
42+
assertThat(body.quantity()).isEqualTo(1.0)
43+
assertThat(body.startDate()).isEqualTo(LocalDate.parse("2023-09-22"))
44+
assertThat(body.itemId()).contains("4khy3nwzktxv7")
45+
assertThat(body.name()).contains("Item Name")
46+
}
47+
48+
@Test
49+
fun bodyWithoutOptionalFields() {
50+
val params =
51+
InvoiceLineItemCreateParams.builder()
52+
.amount("12.00")
53+
.endDate(LocalDate.parse("2023-09-22"))
54+
.invoiceId("4khy3nwzktxv7")
3155
.quantity(1.0)
3256
.startDate(LocalDate.parse("2023-09-22"))
3357
.build()
@@ -37,7 +61,6 @@ internal class InvoiceLineItemCreateParamsTest {
3761
assertThat(body.amount()).isEqualTo("12.00")
3862
assertThat(body.endDate()).isEqualTo(LocalDate.parse("2023-09-22"))
3963
assertThat(body.invoiceId()).isEqualTo("4khy3nwzktxv7")
40-
assertThat(body.name()).isEqualTo("Item Name")
4164
assertThat(body.quantity()).isEqualTo(1.0)
4265
assertThat(body.startDate()).isEqualTo(LocalDate.parse("2023-09-22"))
4366
}

orb-java-core/src/test/kotlin/com/withorb/api/services/async/InvoiceLineItemServiceAsyncTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ internal class InvoiceLineItemServiceAsyncTest {
2727
.amount("12.00")
2828
.endDate(LocalDate.parse("2023-09-22"))
2929
.invoiceId("4khy3nwzktxv7")
30-
.name("Item Name")
3130
.quantity(1.0)
3231
.startDate(LocalDate.parse("2023-09-22"))
32+
.itemId("4khy3nwzktxv7")
33+
.name("Item Name")
3334
.build()
3435
)
3536

orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/InvoiceLineItemServiceTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ internal class InvoiceLineItemServiceTest {
2727
.amount("12.00")
2828
.endDate(LocalDate.parse("2023-09-22"))
2929
.invoiceId("4khy3nwzktxv7")
30-
.name("Item Name")
3130
.quantity(1.0)
3231
.startDate(LocalDate.parse("2023-09-22"))
32+
.itemId("4khy3nwzktxv7")
33+
.name("Item Name")
3334
.build()
3435
)
3536

0 commit comments

Comments
 (0)