22
33from __future__ import annotations
44
5- from typing import Union
5+ from typing import Union , Optional
66from datetime import date
77
88import httpx
99
1010from .. import _legacy_response
1111from ..types import invoice_line_item_create_params
12- from .._types import Body , Query , Headers , NotGiven , not_given
12+ from .._types import Body , Omit , Query , Headers , NotGiven , omit , not_given
1313from .._utils import maybe_transform , async_maybe_transform
1414from .._compat import cached_property
1515from .._resource import SyncAPIResource , AsyncAPIResource
@@ -46,9 +46,10 @@ def create(
4646 amount : str ,
4747 end_date : Union [str , date ],
4848 invoice_id : str ,
49- name : str ,
5049 quantity : float ,
5150 start_date : Union [str , date ],
51+ item_id : Optional [str ] | Omit = omit ,
52+ name : Optional [str ] | Omit = omit ,
5253 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
5354 # The extra values given here take precedence over values defined on the client or passed to this method.
5455 extra_headers : Headers | None = None ,
@@ -62,20 +63,40 @@ def create(
6263 This can only
6364 be done for invoices that are in a `draft` status.
6465
66+ The behavior depends on which parameters are provided:
67+
68+ - If `item_id` is provided without `name`: The item is looked up by ID, and the
69+ item's name is used for the line item.
70+ - If `name` is provided without `item_id`: An item with the given name is
71+ searched for in the account. If found, that item is used. If not found, a new
72+ item is created with that name. The new item's name is used for the line item.
73+ - If both `item_id` and `name` are provided: The item is looked up by ID for
74+ association, but the provided `name` is used for the line item (not the item's
75+ name).
76+
6577 Args:
6678 amount: The total amount in the invoice's currency to add to the line item.
6779
6880 end_date: A date string to specify the line item's end date in the customer's timezone.
6981
7082 invoice_id: The id of the Invoice to add this line item.
7183
72- name: The item name associated with this line item. If an item with the same name
73- exists in Orb, that item will be associated with the line item.
74-
7584 quantity: The number of units on the line item
7685
7786 start_date: A date string to specify the line item's start date in the customer's timezone.
7887
88+ item_id: The id of the item to associate with this line item. If provided without `name`,
89+ the item's name will be used for the price/line item. If provided with `name`,
90+ the item will be associated but `name` will be used for the line item. At least
91+ one of `name` or `item_id` must be provided.
92+
93+ name: The name to use for the line item. If `item_id` is not provided, Orb will search
94+ for an item with this name. If found, that item will be associated with the line
95+ item. If not found, a new item will be created with this name. If `item_id` is
96+ provided, this name will be used for the line item, but the item association
97+ will be based on `item_id`. At least one of `name` or `item_id` must be
98+ provided.
99+
79100 extra_headers: Send extra headers
80101
81102 extra_query: Add additional query parameters to the request
@@ -93,9 +114,10 @@ def create(
93114 "amount" : amount ,
94115 "end_date" : end_date ,
95116 "invoice_id" : invoice_id ,
96- "name" : name ,
97117 "quantity" : quantity ,
98118 "start_date" : start_date ,
119+ "item_id" : item_id ,
120+ "name" : name ,
99121 },
100122 invoice_line_item_create_params .InvoiceLineItemCreateParams ,
101123 ),
@@ -136,9 +158,10 @@ async def create(
136158 amount : str ,
137159 end_date : Union [str , date ],
138160 invoice_id : str ,
139- name : str ,
140161 quantity : float ,
141162 start_date : Union [str , date ],
163+ item_id : Optional [str ] | Omit = omit ,
164+ name : Optional [str ] | Omit = omit ,
142165 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
143166 # The extra values given here take precedence over values defined on the client or passed to this method.
144167 extra_headers : Headers | None = None ,
@@ -152,20 +175,40 @@ async def create(
152175 This can only
153176 be done for invoices that are in a `draft` status.
154177
178+ The behavior depends on which parameters are provided:
179+
180+ - If `item_id` is provided without `name`: The item is looked up by ID, and the
181+ item's name is used for the line item.
182+ - If `name` is provided without `item_id`: An item with the given name is
183+ searched for in the account. If found, that item is used. If not found, a new
184+ item is created with that name. The new item's name is used for the line item.
185+ - If both `item_id` and `name` are provided: The item is looked up by ID for
186+ association, but the provided `name` is used for the line item (not the item's
187+ name).
188+
155189 Args:
156190 amount: The total amount in the invoice's currency to add to the line item.
157191
158192 end_date: A date string to specify the line item's end date in the customer's timezone.
159193
160194 invoice_id: The id of the Invoice to add this line item.
161195
162- name: The item name associated with this line item. If an item with the same name
163- exists in Orb, that item will be associated with the line item.
164-
165196 quantity: The number of units on the line item
166197
167198 start_date: A date string to specify the line item's start date in the customer's timezone.
168199
200+ item_id: The id of the item to associate with this line item. If provided without `name`,
201+ the item's name will be used for the price/line item. If provided with `name`,
202+ the item will be associated but `name` will be used for the line item. At least
203+ one of `name` or `item_id` must be provided.
204+
205+ name: The name to use for the line item. If `item_id` is not provided, Orb will search
206+ for an item with this name. If found, that item will be associated with the line
207+ item. If not found, a new item will be created with this name. If `item_id` is
208+ provided, this name will be used for the line item, but the item association
209+ will be based on `item_id`. At least one of `name` or `item_id` must be
210+ provided.
211+
169212 extra_headers: Send extra headers
170213
171214 extra_query: Add additional query parameters to the request
@@ -183,9 +226,10 @@ async def create(
183226 "amount" : amount ,
184227 "end_date" : end_date ,
185228 "invoice_id" : invoice_id ,
186- "name" : name ,
187229 "quantity" : quantity ,
188230 "start_date" : start_date ,
231+ "item_id" : item_id ,
232+ "name" : name ,
189233 },
190234 invoice_line_item_create_params .InvoiceLineItemCreateParams ,
191235 ),
0 commit comments