2
2
3
3
from __future__ import annotations
4
4
5
- from typing import Any , Type , cast
5
+ from typing import Type , cast
6
6
from typing_extensions import Literal
7
7
8
8
import httpx
23
23
from ...types .accounts import subscription_create_params , subscription_update_params
24
24
from ...types .shared .subscription import Subscription
25
25
from ...types .shared_params .rate_plan import RatePlan
26
- from ...types .accounts .subscription_create_response import SubscriptionCreateResponse
27
26
from ...types .accounts .subscription_delete_response import SubscriptionDeleteResponse
28
- from ...types .accounts .subscription_update_response import SubscriptionUpdateResponse
29
27
30
28
__all__ = ["SubscriptionsResource" , "AsyncSubscriptionsResource" ]
31
29
@@ -62,7 +60,7 @@ def create(
62
60
extra_query : Query | None = None ,
63
61
extra_body : Body | None = None ,
64
62
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
65
- ) -> SubscriptionCreateResponse :
63
+ ) -> Subscription :
66
64
"""
67
65
Creates an account subscription.
68
66
@@ -83,28 +81,23 @@ def create(
83
81
"""
84
82
if not account_id :
85
83
raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
86
- return cast (
87
- SubscriptionCreateResponse ,
88
- self ._post (
89
- f"/accounts/{ account_id } /subscriptions" ,
90
- body = maybe_transform (
91
- {
92
- "frequency" : frequency ,
93
- "rate_plan" : rate_plan ,
94
- },
95
- subscription_create_params .SubscriptionCreateParams ,
96
- ),
97
- options = make_request_options (
98
- extra_headers = extra_headers ,
99
- extra_query = extra_query ,
100
- extra_body = extra_body ,
101
- timeout = timeout ,
102
- post_parser = ResultWrapper [SubscriptionCreateResponse ]._unwrapper ,
103
- ),
104
- cast_to = cast (
105
- Any , ResultWrapper [SubscriptionCreateResponse ]
106
- ), # Union types cannot be passed in as arguments in the type system
84
+ return self ._post (
85
+ f"/accounts/{ account_id } /subscriptions" ,
86
+ body = maybe_transform (
87
+ {
88
+ "frequency" : frequency ,
89
+ "rate_plan" : rate_plan ,
90
+ },
91
+ subscription_create_params .SubscriptionCreateParams ,
92
+ ),
93
+ options = make_request_options (
94
+ extra_headers = extra_headers ,
95
+ extra_query = extra_query ,
96
+ extra_body = extra_body ,
97
+ timeout = timeout ,
98
+ post_parser = ResultWrapper [Subscription ]._unwrapper ,
107
99
),
100
+ cast_to = cast (Type [Subscription ], ResultWrapper [Subscription ]),
108
101
)
109
102
110
103
def update (
@@ -120,7 +113,7 @@ def update(
120
113
extra_query : Query | None = None ,
121
114
extra_body : Body | None = None ,
122
115
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
123
- ) -> SubscriptionUpdateResponse :
116
+ ) -> Subscription :
124
117
"""
125
118
Updates an account subscription.
126
119
@@ -147,28 +140,23 @@ def update(
147
140
raise ValueError (
148
141
f"Expected a non-empty value for `subscription_identifier` but received { subscription_identifier !r} "
149
142
)
150
- return cast (
151
- SubscriptionUpdateResponse ,
152
- self ._put (
153
- f"/accounts/{ account_id } /subscriptions/{ subscription_identifier } " ,
154
- body = maybe_transform (
155
- {
156
- "frequency" : frequency ,
157
- "rate_plan" : rate_plan ,
158
- },
159
- subscription_update_params .SubscriptionUpdateParams ,
160
- ),
161
- options = make_request_options (
162
- extra_headers = extra_headers ,
163
- extra_query = extra_query ,
164
- extra_body = extra_body ,
165
- timeout = timeout ,
166
- post_parser = ResultWrapper [SubscriptionUpdateResponse ]._unwrapper ,
167
- ),
168
- cast_to = cast (
169
- Any , ResultWrapper [SubscriptionUpdateResponse ]
170
- ), # Union types cannot be passed in as arguments in the type system
143
+ return self ._put (
144
+ f"/accounts/{ account_id } /subscriptions/{ subscription_identifier } " ,
145
+ body = maybe_transform (
146
+ {
147
+ "frequency" : frequency ,
148
+ "rate_plan" : rate_plan ,
149
+ },
150
+ subscription_update_params .SubscriptionUpdateParams ,
151
+ ),
152
+ options = make_request_options (
153
+ extra_headers = extra_headers ,
154
+ extra_query = extra_query ,
155
+ extra_body = extra_body ,
156
+ timeout = timeout ,
157
+ post_parser = ResultWrapper [Subscription ]._unwrapper ,
171
158
),
159
+ cast_to = cast (Type [Subscription ], ResultWrapper [Subscription ]),
172
160
)
173
161
174
162
def delete (
@@ -286,7 +274,7 @@ async def create(
286
274
extra_query : Query | None = None ,
287
275
extra_body : Body | None = None ,
288
276
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
289
- ) -> SubscriptionCreateResponse :
277
+ ) -> Subscription :
290
278
"""
291
279
Creates an account subscription.
292
280
@@ -307,28 +295,23 @@ async def create(
307
295
"""
308
296
if not account_id :
309
297
raise ValueError (f"Expected a non-empty value for `account_id` but received { account_id !r} " )
310
- return cast (
311
- SubscriptionCreateResponse ,
312
- await self ._post (
313
- f"/accounts/{ account_id } /subscriptions" ,
314
- body = await async_maybe_transform (
315
- {
316
- "frequency" : frequency ,
317
- "rate_plan" : rate_plan ,
318
- },
319
- subscription_create_params .SubscriptionCreateParams ,
320
- ),
321
- options = make_request_options (
322
- extra_headers = extra_headers ,
323
- extra_query = extra_query ,
324
- extra_body = extra_body ,
325
- timeout = timeout ,
326
- post_parser = ResultWrapper [SubscriptionCreateResponse ]._unwrapper ,
327
- ),
328
- cast_to = cast (
329
- Any , ResultWrapper [SubscriptionCreateResponse ]
330
- ), # Union types cannot be passed in as arguments in the type system
298
+ return await self ._post (
299
+ f"/accounts/{ account_id } /subscriptions" ,
300
+ body = await async_maybe_transform (
301
+ {
302
+ "frequency" : frequency ,
303
+ "rate_plan" : rate_plan ,
304
+ },
305
+ subscription_create_params .SubscriptionCreateParams ,
306
+ ),
307
+ options = make_request_options (
308
+ extra_headers = extra_headers ,
309
+ extra_query = extra_query ,
310
+ extra_body = extra_body ,
311
+ timeout = timeout ,
312
+ post_parser = ResultWrapper [Subscription ]._unwrapper ,
331
313
),
314
+ cast_to = cast (Type [Subscription ], ResultWrapper [Subscription ]),
332
315
)
333
316
334
317
async def update (
@@ -344,7 +327,7 @@ async def update(
344
327
extra_query : Query | None = None ,
345
328
extra_body : Body | None = None ,
346
329
timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
347
- ) -> SubscriptionUpdateResponse :
330
+ ) -> Subscription :
348
331
"""
349
332
Updates an account subscription.
350
333
@@ -371,28 +354,23 @@ async def update(
371
354
raise ValueError (
372
355
f"Expected a non-empty value for `subscription_identifier` but received { subscription_identifier !r} "
373
356
)
374
- return cast (
375
- SubscriptionUpdateResponse ,
376
- await self ._put (
377
- f"/accounts/{ account_id } /subscriptions/{ subscription_identifier } " ,
378
- body = await async_maybe_transform (
379
- {
380
- "frequency" : frequency ,
381
- "rate_plan" : rate_plan ,
382
- },
383
- subscription_update_params .SubscriptionUpdateParams ,
384
- ),
385
- options = make_request_options (
386
- extra_headers = extra_headers ,
387
- extra_query = extra_query ,
388
- extra_body = extra_body ,
389
- timeout = timeout ,
390
- post_parser = ResultWrapper [SubscriptionUpdateResponse ]._unwrapper ,
391
- ),
392
- cast_to = cast (
393
- Any , ResultWrapper [SubscriptionUpdateResponse ]
394
- ), # Union types cannot be passed in as arguments in the type system
357
+ return await self ._put (
358
+ f"/accounts/{ account_id } /subscriptions/{ subscription_identifier } " ,
359
+ body = await async_maybe_transform (
360
+ {
361
+ "frequency" : frequency ,
362
+ "rate_plan" : rate_plan ,
363
+ },
364
+ subscription_update_params .SubscriptionUpdateParams ,
365
+ ),
366
+ options = make_request_options (
367
+ extra_headers = extra_headers ,
368
+ extra_query = extra_query ,
369
+ extra_body = extra_body ,
370
+ timeout = timeout ,
371
+ post_parser = ResultWrapper [Subscription ]._unwrapper ,
395
372
),
373
+ cast_to = cast (Type [Subscription ], ResultWrapper [Subscription ]),
396
374
)
397
375
398
376
async def delete (
0 commit comments