|
12 | 12 | """ |
13 | 13 |
|
14 | 14 | import json |
15 | | -from typing import Optional |
| 15 | +import warnings |
| 16 | +from typing import Any, Dict, List, Optional, Tuple, Union |
| 17 | +from typing_extensions import Annotated |
16 | 18 | from sendgrid.base import values |
17 | 19 | from sendgrid.exceptions import ApiException |
18 | 20 | from sendgrid.http.request import Request |
19 | 21 | from sendgrid.http.response import ApiResponse |
20 | 22 |
|
| 23 | +from pydantic import Field, StrictStr |
21 | 24 | from typing import Optional |
22 | | -from sendgrid.rest.api.account_provisioning.v3.models.create_account_params import ( |
23 | | - CreateAccountParams, |
24 | | -) |
25 | | - |
| 25 | +from typing_extensions import Annotated |
| 26 | +from sendgrid.rest.api.account_provisioning.v3.models.account_provisioning_account_id import AccountProvisioningAccountId |
| 27 | +from sendgrid.rest.api.account_provisioning.v3.models.create_account_params import CreateAccountParams |
26 | 28 |
|
27 | 29 | class CreateAccount: |
28 | 30 | def __init__(self, client) -> None: |
29 | 31 | self.client = client |
30 | | - |
| 32 | + |
31 | 33 | def send( |
32 | 34 | self, |
33 | | - t_test_account: Optional[str] = None, |
34 | | - create_account_params: Optional[CreateAccountParams] = None, |
| 35 | + t_test_account: Optional[str] = None, |
| 36 | + create_account_params: Optional[CreateAccountParams] = None, |
| 37 | + |
35 | 38 | ): |
36 | | - path = "/v3/partners/accounts" |
| 39 | + path='/v3/partners/accounts' |
37 | 40 |
|
38 | 41 | headers = values.of( |
39 | | - { |
40 | | - "T-Test-Account": t_test_account, |
41 | | - } |
42 | | - ) |
| 42 | + { |
| 43 | + 'T-Test-Account': t_test_account, |
| 44 | + }) |
43 | 45 | headers["Content-Type"] = "application/json" |
44 | 46 | data = None |
45 | 47 | if create_account_params: |
46 | 48 | data = create_account_params.to_dict() |
47 | | - request = Request(method="POST", url=path, data=data, headers=headers) |
48 | | - response = self.client.send(request) |
| 49 | + request = Request( |
| 50 | + method='POST', |
| 51 | + url=path, |
| 52 | + data=data, |
| 53 | + headers=headers |
| 54 | + ) |
| 55 | + response=self.client.send(request) |
49 | 56 | if response is None: |
50 | | - raise ApiException( |
51 | | - error="CreateAlert creation failed: Unable to connect to server" |
52 | | - ) |
| 57 | + raise ApiException(error="CreateAlert creation failed: Unable to connect to server") |
53 | 58 |
|
54 | 59 | if response.text: |
55 | 60 | text = json.loads(response.text) |
56 | 61 | else: |
57 | 62 | text = "" |
58 | 63 | if response.is_success(): |
59 | | - return ApiResponse( |
60 | | - status_code=response.status_code, model=text, headers=response.headers |
61 | | - ) |
| 64 | + return ApiResponse(status_code=response.status_code, model=text, headers=response.headers) |
62 | 65 | else: |
63 | | - raise ApiException( |
64 | | - status_code=response.status_code, error=text, headers=response.headers |
65 | | - ) |
| 66 | + raise ApiException(status_code=response.status_code, error=text, headers=response.headers) |
0 commit comments