Skip to content

Commit d3e31e9

Browse files
committed
Add new billing and checkout models to API
This commit introduces several new models related to billing and checkout processes, enhancing the API's capabilities. The following models have been added: - BillingCustomer - CheckoutResponse - CheckoutStatusResponse - CreateCheckoutRequest - CreateCheckoutRequestResourceConfig - Invoice - InvoiceLineItem - InvoicesResponse - PaymentMethod - UpcomingInvoice - UpdatePaymentMethodRequest - UpdatePaymentMethodResponse These additions aim to streamline billing operations and improve the overall structure of the API.
1 parent de43e5c commit d3e31e9

23 files changed

Lines changed: 2978 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Contains endpoint functions for accessing the API"""
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
from http import HTTPStatus
2+
from typing import Any, Optional, Union
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import AuthenticatedClient, Client
8+
from ...models.graph_subscription_response import GraphSubscriptionResponse
9+
from ...models.http_validation_error import HTTPValidationError
10+
from ...types import Response
11+
12+
13+
def _get_kwargs(
14+
subscription_id: str,
15+
) -> dict[str, Any]:
16+
_kwargs: dict[str, Any] = {
17+
"method": "post",
18+
"url": f"/v1/billing/subscriptions/{subscription_id}/cancel",
19+
}
20+
21+
return _kwargs
22+
23+
24+
def _parse_response(
25+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
26+
) -> Optional[Union[GraphSubscriptionResponse, HTTPValidationError]]:
27+
if response.status_code == 200:
28+
response_200 = GraphSubscriptionResponse.from_dict(response.json())
29+
30+
return response_200
31+
32+
if response.status_code == 422:
33+
response_422 = HTTPValidationError.from_dict(response.json())
34+
35+
return response_422
36+
37+
if client.raise_on_unexpected_status:
38+
raise errors.UnexpectedStatus(response.status_code, response.content)
39+
else:
40+
return None
41+
42+
43+
def _build_response(
44+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
45+
) -> Response[Union[GraphSubscriptionResponse, HTTPValidationError]]:
46+
return Response(
47+
status_code=HTTPStatus(response.status_code),
48+
content=response.content,
49+
headers=response.headers,
50+
parsed=_parse_response(client=client, response=response),
51+
)
52+
53+
54+
def sync_detailed(
55+
subscription_id: str,
56+
*,
57+
client: AuthenticatedClient,
58+
) -> Response[Union[GraphSubscriptionResponse, HTTPValidationError]]:
59+
"""Cancel Subscription
60+
61+
Cancel a subscription.
62+
63+
The subscription will remain active until the end of the current billing period.
64+
65+
Args:
66+
subscription_id (str):
67+
68+
Raises:
69+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
70+
httpx.TimeoutException: If the request takes longer than Client.timeout.
71+
72+
Returns:
73+
Response[Union[GraphSubscriptionResponse, HTTPValidationError]]
74+
"""
75+
76+
kwargs = _get_kwargs(
77+
subscription_id=subscription_id,
78+
)
79+
80+
response = client.get_httpx_client().request(
81+
**kwargs,
82+
)
83+
84+
return _build_response(client=client, response=response)
85+
86+
87+
def sync(
88+
subscription_id: str,
89+
*,
90+
client: AuthenticatedClient,
91+
) -> Optional[Union[GraphSubscriptionResponse, HTTPValidationError]]:
92+
"""Cancel Subscription
93+
94+
Cancel a subscription.
95+
96+
The subscription will remain active until the end of the current billing period.
97+
98+
Args:
99+
subscription_id (str):
100+
101+
Raises:
102+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
103+
httpx.TimeoutException: If the request takes longer than Client.timeout.
104+
105+
Returns:
106+
Union[GraphSubscriptionResponse, HTTPValidationError]
107+
"""
108+
109+
return sync_detailed(
110+
subscription_id=subscription_id,
111+
client=client,
112+
).parsed
113+
114+
115+
async def asyncio_detailed(
116+
subscription_id: str,
117+
*,
118+
client: AuthenticatedClient,
119+
) -> Response[Union[GraphSubscriptionResponse, HTTPValidationError]]:
120+
"""Cancel Subscription
121+
122+
Cancel a subscription.
123+
124+
The subscription will remain active until the end of the current billing period.
125+
126+
Args:
127+
subscription_id (str):
128+
129+
Raises:
130+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
131+
httpx.TimeoutException: If the request takes longer than Client.timeout.
132+
133+
Returns:
134+
Response[Union[GraphSubscriptionResponse, HTTPValidationError]]
135+
"""
136+
137+
kwargs = _get_kwargs(
138+
subscription_id=subscription_id,
139+
)
140+
141+
response = await client.get_async_httpx_client().request(**kwargs)
142+
143+
return _build_response(client=client, response=response)
144+
145+
146+
async def asyncio(
147+
subscription_id: str,
148+
*,
149+
client: AuthenticatedClient,
150+
) -> Optional[Union[GraphSubscriptionResponse, HTTPValidationError]]:
151+
"""Cancel Subscription
152+
153+
Cancel a subscription.
154+
155+
The subscription will remain active until the end of the current billing period.
156+
157+
Args:
158+
subscription_id (str):
159+
160+
Raises:
161+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
162+
httpx.TimeoutException: If the request takes longer than Client.timeout.
163+
164+
Returns:
165+
Union[GraphSubscriptionResponse, HTTPValidationError]
166+
"""
167+
168+
return (
169+
await asyncio_detailed(
170+
subscription_id=subscription_id,
171+
client=client,
172+
)
173+
).parsed

0 commit comments

Comments
 (0)