Skip to content

Commit 65c7fc9

Browse files
feat(client): support passing httpx.Timeout to method timeout argument (#35)
1 parent 019e5a3 commit 65c7fc9

22 files changed

+235
-193
lines changed

src/orb/_base_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ def make_request_options(
15371537
extra_query: Query | None = None,
15381538
extra_body: Body | None = None,
15391539
idempotency_key: str | None = None,
1540-
timeout: float | None | NotGiven = NOT_GIVEN,
1540+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
15411541
post_parser: PostParser | NotGiven = NOT_GIVEN,
15421542
) -> RequestOptions:
15431543
"""Create a dict of type RequestOptions without keys of NotGiven values."""

src/orb/resources/coupons/coupons.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from typing import TYPE_CHECKING, Optional
66

7+
import httpx
8+
79
from ...types import Coupon, coupon_list_params, coupon_create_params
810
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
911
from ..._utils import maybe_transform
@@ -45,7 +47,7 @@ def create(
4547
extra_headers: Headers | None = None,
4648
extra_query: Query | None = None,
4749
extra_body: Body | None = None,
48-
timeout: float | None | NotGiven = NOT_GIVEN,
50+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
4951
idempotency_key: str | None = None,
5052
) -> Coupon:
5153
"""
@@ -104,7 +106,7 @@ def list(
104106
extra_headers: Headers | None = None,
105107
extra_query: Query | None = None,
106108
extra_body: Body | None = None,
107-
timeout: float | None | NotGiven = NOT_GIVEN,
109+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
108110
) -> SyncPage[Coupon]:
109111
"""
110112
This endpoint returns a list of all coupons for an account in a list format.
@@ -163,7 +165,7 @@ def archive(
163165
extra_headers: Headers | None = None,
164166
extra_query: Query | None = None,
165167
extra_body: Body | None = None,
166-
timeout: float | None | NotGiven = NOT_GIVEN,
168+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
167169
idempotency_key: str | None = None,
168170
) -> Coupon:
169171
"""This endpoint allows a coupon to be archived.
@@ -204,7 +206,7 @@ def fetch(
204206
extra_headers: Headers | None = None,
205207
extra_query: Query | None = None,
206208
extra_body: Body | None = None,
207-
timeout: float | None | NotGiven = NOT_GIVEN,
209+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
208210
) -> Coupon:
209211
"""This endpoint retrieves a coupon by its ID.
210212
@@ -251,7 +253,7 @@ async def create(
251253
extra_headers: Headers | None = None,
252254
extra_query: Query | None = None,
253255
extra_body: Body | None = None,
254-
timeout: float | None | NotGiven = NOT_GIVEN,
256+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
255257
idempotency_key: str | None = None,
256258
) -> Coupon:
257259
"""
@@ -310,7 +312,7 @@ def list(
310312
extra_headers: Headers | None = None,
311313
extra_query: Query | None = None,
312314
extra_body: Body | None = None,
313-
timeout: float | None | NotGiven = NOT_GIVEN,
315+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
314316
) -> AsyncPaginator[Coupon, AsyncPage[Coupon]]:
315317
"""
316318
This endpoint returns a list of all coupons for an account in a list format.
@@ -369,7 +371,7 @@ async def archive(
369371
extra_headers: Headers | None = None,
370372
extra_query: Query | None = None,
371373
extra_body: Body | None = None,
372-
timeout: float | None | NotGiven = NOT_GIVEN,
374+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
373375
idempotency_key: str | None = None,
374376
) -> Coupon:
375377
"""This endpoint allows a coupon to be archived.
@@ -410,7 +412,7 @@ async def fetch(
410412
extra_headers: Headers | None = None,
411413
extra_query: Query | None = None,
412414
extra_body: Body | None = None,
413-
timeout: float | None | NotGiven = NOT_GIVEN,
415+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
414416
) -> Coupon:
415417
"""This endpoint retrieves a coupon by its ID.
416418

src/orb/resources/coupons/subscriptions.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from typing import TYPE_CHECKING, Optional
66

7+
import httpx
8+
79
from ...types import Subscription
810
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
911
from ..._utils import maybe_transform
@@ -37,7 +39,7 @@ def list(
3739
extra_headers: Headers | None = None,
3840
extra_query: Query | None = None,
3941
extra_body: Body | None = None,
40-
timeout: float | None | NotGiven = NOT_GIVEN,
42+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
4143
) -> SyncPage[Subscription]:
4244
"""
4345
This endpoint returns a list of all subscriptions that have redeemed a given
@@ -97,7 +99,7 @@ def list(
9799
extra_headers: Headers | None = None,
98100
extra_query: Query | None = None,
99101
extra_body: Body | None = None,
100-
timeout: float | None | NotGiven = NOT_GIVEN,
102+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
101103
) -> AsyncPaginator[Subscription, AsyncPage[Subscription]]:
102104
"""
103105
This endpoint returns a list of all subscriptions that have redeemed a given

src/orb/resources/credit_notes.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from typing import TYPE_CHECKING, Optional
66

7+
import httpx
8+
79
from ..types import CreditNote, credit_note_list_params
810
from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven
911
from .._utils import maybe_transform
@@ -35,7 +37,7 @@ def list(
3537
extra_headers: Headers | None = None,
3638
extra_query: Query | None = None,
3739
extra_body: Body | None = None,
38-
timeout: float | None | NotGiven = NOT_GIVEN,
40+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
3941
) -> SyncPage[CreditNote]:
4042
"""Get a paginated list of CreditNotes.
4143
@@ -85,7 +87,7 @@ def fetch(
8587
extra_headers: Headers | None = None,
8688
extra_query: Query | None = None,
8789
extra_body: Body | None = None,
88-
timeout: float | None | NotGiven = NOT_GIVEN,
90+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
8991
) -> CreditNote:
9092
"""
9193
This endpoint is used to fetch a single
@@ -126,7 +128,7 @@ def list(
126128
extra_headers: Headers | None = None,
127129
extra_query: Query | None = None,
128130
extra_body: Body | None = None,
129-
timeout: float | None | NotGiven = NOT_GIVEN,
131+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
130132
) -> AsyncPaginator[CreditNote, AsyncPage[CreditNote]]:
131133
"""Get a paginated list of CreditNotes.
132134
@@ -176,7 +178,7 @@ async def fetch(
176178
extra_headers: Headers | None = None,
177179
extra_query: Query | None = None,
178180
extra_body: Body | None = None,
179-
timeout: float | None | NotGiven = NOT_GIVEN,
181+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
180182
) -> CreditNote:
181183
"""
182184
This endpoint is used to fetch a single

src/orb/resources/customers/balance_transactions.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from datetime import datetime
77
from typing_extensions import Literal
88

9+
import httpx
10+
911
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1012
from ..._utils import maybe_transform
1113
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -44,7 +46,7 @@ def create(
4446
extra_headers: Headers | None = None,
4547
extra_query: Query | None = None,
4648
extra_body: Body | None = None,
47-
timeout: float | None | NotGiven = NOT_GIVEN,
49+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
4850
idempotency_key: str | None = None,
4951
) -> BalanceTransactionCreateResponse:
5052
"""
@@ -99,7 +101,7 @@ def list(
99101
extra_headers: Headers | None = None,
100102
extra_query: Query | None = None,
101103
extra_body: Body | None = None,
102-
timeout: float | None | NotGiven = NOT_GIVEN,
104+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
103105
) -> SyncPage[BalanceTransactionListResponse]:
104106
"""
105107
## The customer balance
@@ -188,7 +190,7 @@ async def create(
188190
extra_headers: Headers | None = None,
189191
extra_query: Query | None = None,
190192
extra_body: Body | None = None,
191-
timeout: float | None | NotGiven = NOT_GIVEN,
193+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
192194
idempotency_key: str | None = None,
193195
) -> BalanceTransactionCreateResponse:
194196
"""
@@ -243,7 +245,7 @@ def list(
243245
extra_headers: Headers | None = None,
244246
extra_query: Query | None = None,
245247
extra_body: Body | None = None,
246-
timeout: float | None | NotGiven = NOT_GIVEN,
248+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
247249
) -> AsyncPaginator[BalanceTransactionListResponse, AsyncPage[BalanceTransactionListResponse]]:
248250
"""
249251
## The customer balance

src/orb/resources/customers/costs.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from datetime import datetime
77
from typing_extensions import Literal
88

9+
import httpx
10+
911
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1012
from ..._utils import maybe_transform
1113
from ..._resource import SyncAPIResource, AsyncAPIResource
@@ -44,7 +46,7 @@ def list(
4446
extra_headers: Headers | None = None,
4547
extra_query: Query | None = None,
4648
extra_body: Body | None = None,
47-
timeout: float | None | NotGiven = NOT_GIVEN,
49+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
4850
) -> CostListResponse:
4951
"""
5052
This endpoint is used to fetch a day-by-day snapshot of a customer's costs in
@@ -235,7 +237,7 @@ def list_by_external_id(
235237
extra_headers: Headers | None = None,
236238
extra_query: Query | None = None,
237239
extra_body: Body | None = None,
238-
timeout: float | None | NotGiven = NOT_GIVEN,
240+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
239241
) -> CostListByExternalIDResponse:
240242
"""
241243
This endpoint is used to fetch a day-by-day snapshot of a customer's costs in
@@ -434,7 +436,7 @@ async def list(
434436
extra_headers: Headers | None = None,
435437
extra_query: Query | None = None,
436438
extra_body: Body | None = None,
437-
timeout: float | None | NotGiven = NOT_GIVEN,
439+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
438440
) -> CostListResponse:
439441
"""
440442
This endpoint is used to fetch a day-by-day snapshot of a customer's costs in
@@ -625,7 +627,7 @@ async def list_by_external_id(
625627
extra_headers: Headers | None = None,
626628
extra_query: Query | None = None,
627629
extra_body: Body | None = None,
628-
timeout: float | None | NotGiven = NOT_GIVEN,
630+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
629631
) -> CostListByExternalIDResponse:
630632
"""
631633
This endpoint is used to fetch a day-by-day snapshot of a customer's costs in

src/orb/resources/customers/credits/credits.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
from typing import TYPE_CHECKING, Optional
66

7+
import httpx
8+
79
from .ledger import (
810
Ledger,
911
AsyncLedger,
@@ -49,7 +51,7 @@ def list(
4951
extra_headers: Headers | None = None,
5052
extra_query: Query | None = None,
5153
extra_body: Body | None = None,
52-
timeout: float | None | NotGiven = NOT_GIVEN,
54+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
5355
) -> SyncPage[CreditListResponse]:
5456
"""
5557
Returns a paginated list of unexpired, non-zero credit blocks for a customer.
@@ -98,7 +100,7 @@ def list_by_external_id(
98100
extra_headers: Headers | None = None,
99101
extra_query: Query | None = None,
100102
extra_body: Body | None = None,
101-
timeout: float | None | NotGiven = NOT_GIVEN,
103+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
102104
) -> SyncPage[CreditListByExternalIDResponse]:
103105
"""
104106
Returns a paginated list of unexpired, non-zero credit blocks for a customer.
@@ -157,7 +159,7 @@ def list(
157159
extra_headers: Headers | None = None,
158160
extra_query: Query | None = None,
159161
extra_body: Body | None = None,
160-
timeout: float | None | NotGiven = NOT_GIVEN,
162+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
161163
) -> AsyncPaginator[CreditListResponse, AsyncPage[CreditListResponse]]:
162164
"""
163165
Returns a paginated list of unexpired, non-zero credit blocks for a customer.
@@ -206,7 +208,7 @@ def list_by_external_id(
206208
extra_headers: Headers | None = None,
207209
extra_query: Query | None = None,
208210
extra_body: Body | None = None,
209-
timeout: float | None | NotGiven = NOT_GIVEN,
211+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
210212
) -> AsyncPaginator[CreditListByExternalIDResponse, AsyncPage[CreditListByExternalIDResponse]]:
211213
"""
212214
Returns a paginated list of unexpired, non-zero credit blocks for a customer.

0 commit comments

Comments
 (0)