Skip to content

Commit b73c340

Browse files
stainless-app[bot]meorphis
authored andcommitted
feat(api): api update (#430)
1 parent 208e97b commit b73c340

File tree

6 files changed

+221
-2
lines changed

6 files changed

+221
-2
lines changed

.stats.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 96
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-1345a8e288e34d5477b0e189877225f83939a59078c22fbb5367712e376c5d19.yml
1+
configured_endpoints: 97
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-bf3e71b33372f4a9307f4b6cb689ea46b3cf583ecc5d79eee9601cd0b0467c9a.yml

api.md

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ Methods:
241241
- <code title="get /invoices/upcoming">client.invoices.<a href="./src/orb/resources/invoices.py">fetch_upcoming</a>(\*\*<a href="src/orb/types/invoice_fetch_upcoming_params.py">params</a>) -> <a href="./src/orb/types/invoice_fetch_upcoming_response.py">InvoiceFetchUpcomingResponse</a></code>
242242
- <code title="post /invoices/{invoice_id}/issue">client.invoices.<a href="./src/orb/resources/invoices.py">issue</a>(invoice_id, \*\*<a href="src/orb/types/invoice_issue_params.py">params</a>) -> <a href="./src/orb/types/invoice.py">Invoice</a></code>
243243
- <code title="post /invoices/{invoice_id}/mark_paid">client.invoices.<a href="./src/orb/resources/invoices.py">mark_paid</a>(invoice_id, \*\*<a href="src/orb/types/invoice_mark_paid_params.py">params</a>) -> <a href="./src/orb/types/invoice.py">Invoice</a></code>
244+
- <code title="post /invoices/{invoice_id}/pay">client.invoices.<a href="./src/orb/resources/invoices.py">pay</a>(invoice_id) -> <a href="./src/orb/types/invoice.py">Invoice</a></code>
244245
- <code title="post /invoices/{invoice_id}/void">client.invoices.<a href="./src/orb/resources/invoices.py">void</a>(invoice_id) -> <a href="./src/orb/types/invoice.py">Invoice</a></code>
245246

246247
# Items

src/orb/resources/invoices.py

+94
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,47 @@ def mark_paid(
475475
cast_to=Invoice,
476476
)
477477

478+
def pay(
479+
self,
480+
invoice_id: str,
481+
*,
482+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
483+
# The extra values given here take precedence over values defined on the client or passed to this method.
484+
extra_headers: Headers | None = None,
485+
extra_query: Query | None = None,
486+
extra_body: Body | None = None,
487+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
488+
idempotency_key: str | None = None,
489+
) -> Invoice:
490+
"""
491+
This endpoint collects payment for an invoice using the customer's default
492+
payment method. This action can only be taken on invoices with status "issued".
493+
494+
Args:
495+
extra_headers: Send extra headers
496+
497+
extra_query: Add additional query parameters to the request
498+
499+
extra_body: Add additional JSON properties to the request
500+
501+
timeout: Override the client-level default timeout for this request, in seconds
502+
503+
idempotency_key: Specify a custom idempotency key for this request
504+
"""
505+
if not invoice_id:
506+
raise ValueError(f"Expected a non-empty value for `invoice_id` but received {invoice_id!r}")
507+
return self._post(
508+
f"/invoices/{invoice_id}/pay",
509+
options=make_request_options(
510+
extra_headers=extra_headers,
511+
extra_query=extra_query,
512+
extra_body=extra_body,
513+
timeout=timeout,
514+
idempotency_key=idempotency_key,
515+
),
516+
cast_to=Invoice,
517+
)
518+
478519
def void(
479520
self,
480521
invoice_id: str,
@@ -964,6 +1005,47 @@ async def mark_paid(
9641005
cast_to=Invoice,
9651006
)
9661007

1008+
async def pay(
1009+
self,
1010+
invoice_id: str,
1011+
*,
1012+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
1013+
# The extra values given here take precedence over values defined on the client or passed to this method.
1014+
extra_headers: Headers | None = None,
1015+
extra_query: Query | None = None,
1016+
extra_body: Body | None = None,
1017+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
1018+
idempotency_key: str | None = None,
1019+
) -> Invoice:
1020+
"""
1021+
This endpoint collects payment for an invoice using the customer's default
1022+
payment method. This action can only be taken on invoices with status "issued".
1023+
1024+
Args:
1025+
extra_headers: Send extra headers
1026+
1027+
extra_query: Add additional query parameters to the request
1028+
1029+
extra_body: Add additional JSON properties to the request
1030+
1031+
timeout: Override the client-level default timeout for this request, in seconds
1032+
1033+
idempotency_key: Specify a custom idempotency key for this request
1034+
"""
1035+
if not invoice_id:
1036+
raise ValueError(f"Expected a non-empty value for `invoice_id` but received {invoice_id!r}")
1037+
return await self._post(
1038+
f"/invoices/{invoice_id}/pay",
1039+
options=make_request_options(
1040+
extra_headers=extra_headers,
1041+
extra_query=extra_query,
1042+
extra_body=extra_body,
1043+
timeout=timeout,
1044+
idempotency_key=idempotency_key,
1045+
),
1046+
cast_to=Invoice,
1047+
)
1048+
9671049
async def void(
9681050
self,
9691051
invoice_id: str,
@@ -1037,6 +1119,9 @@ def __init__(self, invoices: Invoices) -> None:
10371119
self.mark_paid = _legacy_response.to_raw_response_wrapper(
10381120
invoices.mark_paid,
10391121
)
1122+
self.pay = _legacy_response.to_raw_response_wrapper(
1123+
invoices.pay,
1124+
)
10401125
self.void = _legacy_response.to_raw_response_wrapper(
10411126
invoices.void,
10421127
)
@@ -1067,6 +1152,9 @@ def __init__(self, invoices: AsyncInvoices) -> None:
10671152
self.mark_paid = _legacy_response.async_to_raw_response_wrapper(
10681153
invoices.mark_paid,
10691154
)
1155+
self.pay = _legacy_response.async_to_raw_response_wrapper(
1156+
invoices.pay,
1157+
)
10701158
self.void = _legacy_response.async_to_raw_response_wrapper(
10711159
invoices.void,
10721160
)
@@ -1097,6 +1185,9 @@ def __init__(self, invoices: Invoices) -> None:
10971185
self.mark_paid = to_streamed_response_wrapper(
10981186
invoices.mark_paid,
10991187
)
1188+
self.pay = to_streamed_response_wrapper(
1189+
invoices.pay,
1190+
)
11001191
self.void = to_streamed_response_wrapper(
11011192
invoices.void,
11021193
)
@@ -1127,6 +1218,9 @@ def __init__(self, invoices: AsyncInvoices) -> None:
11271218
self.mark_paid = async_to_streamed_response_wrapper(
11281219
invoices.mark_paid,
11291220
)
1221+
self.pay = async_to_streamed_response_wrapper(
1222+
invoices.pay,
1223+
)
11301224
self.void = async_to_streamed_response_wrapper(
11311225
invoices.void,
11321226
)

src/orb/types/invoice.py

+24
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"LineItemTaxAmount",
3636
"Maximum",
3737
"Minimum",
38+
"PaymentAttempt",
3839
"ShippingAddress",
3940
"Subscription",
4041
]
@@ -744,6 +745,26 @@ class Minimum(BaseModel):
744745
"""Minimum amount applied"""
745746

746747

748+
class PaymentAttempt(BaseModel):
749+
id: str
750+
"""The ID of the payment attempt."""
751+
752+
amount: str
753+
"""The amount of the payment attempt."""
754+
755+
created_at: datetime
756+
"""The time at which the payment attempt was created."""
757+
758+
payment_provider: Optional[Literal["stripe"]] = None
759+
"""The payment provider that attempted to collect the payment."""
760+
761+
payment_provider_id: Optional[str] = None
762+
"""The ID of the payment attempt in the payment provider."""
763+
764+
succeeded: bool
765+
"""Whether the payment attempt succeeded."""
766+
767+
747768
class ShippingAddress(BaseModel):
748769
city: Optional[str] = None
749770

@@ -980,6 +1001,9 @@ class Invoice(BaseModel):
9801001
was paid.
9811002
"""
9821003

1004+
payment_attempts: List[PaymentAttempt]
1005+
"""A list of payment attempts associated with the invoice"""
1006+
9831007
payment_failed_at: Optional[datetime] = None
9841008
"""
9851009
If payment was attempted on this invoice but failed, this will be the time of

src/orb/types/invoice_fetch_upcoming_response.py

+24
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"LineItemTaxAmount",
3636
"Maximum",
3737
"Minimum",
38+
"PaymentAttempt",
3839
"ShippingAddress",
3940
"Subscription",
4041
]
@@ -744,6 +745,26 @@ class Minimum(BaseModel):
744745
"""Minimum amount applied"""
745746

746747

748+
class PaymentAttempt(BaseModel):
749+
id: str
750+
"""The ID of the payment attempt."""
751+
752+
amount: str
753+
"""The amount of the payment attempt."""
754+
755+
created_at: datetime
756+
"""The time at which the payment attempt was created."""
757+
758+
payment_provider: Optional[Literal["stripe"]] = None
759+
"""The payment provider that attempted to collect the payment."""
760+
761+
payment_provider_id: Optional[str] = None
762+
"""The ID of the payment attempt in the payment provider."""
763+
764+
succeeded: bool
765+
"""Whether the payment attempt succeeded."""
766+
767+
747768
class ShippingAddress(BaseModel):
748769
city: Optional[str] = None
749770

@@ -977,6 +998,9 @@ class InvoiceFetchUpcomingResponse(BaseModel):
977998
was paid.
978999
"""
9791000

1001+
payment_attempts: List[PaymentAttempt]
1002+
"""A list of payment attempts associated with the invoice"""
1003+
9801004
payment_failed_at: Optional[datetime] = None
9811005
"""
9821006
If payment was attempted on this invoice but failed, this will be the time of

tests/api_resources/test_invoices.py

+76
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,44 @@ def test_path_params_mark_paid(self, client: Orb) -> None:
386386
payment_received_date=parse_date("2023-09-22"),
387387
)
388388

389+
@parametrize
390+
def test_method_pay(self, client: Orb) -> None:
391+
invoice = client.invoices.pay(
392+
"invoice_id",
393+
)
394+
assert_matches_type(Invoice, invoice, path=["response"])
395+
396+
@parametrize
397+
def test_raw_response_pay(self, client: Orb) -> None:
398+
response = client.invoices.with_raw_response.pay(
399+
"invoice_id",
400+
)
401+
402+
assert response.is_closed is True
403+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
404+
invoice = response.parse()
405+
assert_matches_type(Invoice, invoice, path=["response"])
406+
407+
@parametrize
408+
def test_streaming_response_pay(self, client: Orb) -> None:
409+
with client.invoices.with_streaming_response.pay(
410+
"invoice_id",
411+
) as response:
412+
assert not response.is_closed
413+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
414+
415+
invoice = response.parse()
416+
assert_matches_type(Invoice, invoice, path=["response"])
417+
418+
assert cast(Any, response.is_closed) is True
419+
420+
@parametrize
421+
def test_path_params_pay(self, client: Orb) -> None:
422+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `invoice_id` but received ''"):
423+
client.invoices.with_raw_response.pay(
424+
"",
425+
)
426+
389427
@parametrize
390428
def test_method_void(self, client: Orb) -> None:
391429
invoice = client.invoices.void(
@@ -792,6 +830,44 @@ async def test_path_params_mark_paid(self, async_client: AsyncOrb) -> None:
792830
payment_received_date=parse_date("2023-09-22"),
793831
)
794832

833+
@parametrize
834+
async def test_method_pay(self, async_client: AsyncOrb) -> None:
835+
invoice = await async_client.invoices.pay(
836+
"invoice_id",
837+
)
838+
assert_matches_type(Invoice, invoice, path=["response"])
839+
840+
@parametrize
841+
async def test_raw_response_pay(self, async_client: AsyncOrb) -> None:
842+
response = await async_client.invoices.with_raw_response.pay(
843+
"invoice_id",
844+
)
845+
846+
assert response.is_closed is True
847+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
848+
invoice = response.parse()
849+
assert_matches_type(Invoice, invoice, path=["response"])
850+
851+
@parametrize
852+
async def test_streaming_response_pay(self, async_client: AsyncOrb) -> None:
853+
async with async_client.invoices.with_streaming_response.pay(
854+
"invoice_id",
855+
) as response:
856+
assert not response.is_closed
857+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
858+
859+
invoice = await response.parse()
860+
assert_matches_type(Invoice, invoice, path=["response"])
861+
862+
assert cast(Any, response.is_closed) is True
863+
864+
@parametrize
865+
async def test_path_params_pay(self, async_client: AsyncOrb) -> None:
866+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `invoice_id` but received ''"):
867+
await async_client.invoices.with_raw_response.pay(
868+
"",
869+
)
870+
795871
@parametrize
796872
async def test_method_void(self, async_client: AsyncOrb) -> None:
797873
invoice = await async_client.invoices.void(

0 commit comments

Comments
 (0)