|
6 | 6 | from pydantic import TypeAdapter |
7 | 7 |
|
8 | 8 | from mailtrap.api.contacts import ContactsBaseApi |
| 9 | +from mailtrap.api.email_logs import EmailLogsBaseApi |
9 | 10 | from mailtrap.api.general import GeneralApi |
10 | 11 | from mailtrap.api.sending import SendingApi |
11 | 12 | from mailtrap.api.sending_domains import SendingDomainsBaseApi |
@@ -72,36 +73,44 @@ def testing_api(self) -> TestingApi: |
72 | 73 |
|
73 | 74 | @property |
74 | 75 | def email_templates_api(self) -> EmailTemplatesApi: |
75 | | - self._validate_account_id() |
| 76 | + self._validate_account_id("Email Templates API") |
76 | 77 | return EmailTemplatesApi( |
77 | 78 | account_id=cast(str, self.account_id), |
78 | 79 | client=HttpClient(host=GENERAL_HOST, headers=self.headers), |
79 | 80 | ) |
80 | 81 |
|
81 | 82 | @property |
82 | 83 | def contacts_api(self) -> ContactsBaseApi: |
83 | | - self._validate_account_id() |
| 84 | + self._validate_account_id("Contacts API") |
84 | 85 | return ContactsBaseApi( |
85 | 86 | account_id=cast(str, self.account_id), |
86 | 87 | client=HttpClient(host=GENERAL_HOST, headers=self.headers), |
87 | 88 | ) |
88 | 89 |
|
89 | 90 | @property |
90 | 91 | def suppressions_api(self) -> SuppressionsBaseApi: |
91 | | - self._validate_account_id() |
| 92 | + self._validate_account_id("Suppressions API") |
92 | 93 | return SuppressionsBaseApi( |
93 | 94 | account_id=cast(str, self.account_id), |
94 | 95 | client=HttpClient(host=GENERAL_HOST, headers=self.headers), |
95 | 96 | ) |
96 | 97 |
|
97 | 98 | @property |
98 | 99 | def sending_domains_api(self) -> SendingDomainsBaseApi: |
99 | | - self._validate_account_id() |
| 100 | + self._validate_account_id("Sending Domains API") |
100 | 101 | return SendingDomainsBaseApi( |
101 | 102 | account_id=cast(str, self.account_id), |
102 | 103 | client=HttpClient(host=GENERAL_HOST, headers=self.headers), |
103 | 104 | ) |
104 | 105 |
|
| 106 | + @property |
| 107 | + def email_logs_api(self) -> EmailLogsBaseApi: |
| 108 | + self._validate_account_id("Email Logs API") |
| 109 | + return EmailLogsBaseApi( |
| 110 | + account_id=cast(str, self.account_id), |
| 111 | + client=HttpClient(host=GENERAL_HOST, headers=self.headers), |
| 112 | + ) |
| 113 | + |
105 | 114 | @property |
106 | 115 | def sending_api(self) -> SendingApi: |
107 | 116 | http_client = HttpClient(host=self._sending_api_host, headers=self.headers) |
@@ -162,9 +171,9 @@ def _sending_api_host(self) -> str: |
162 | 171 | return BULK_HOST |
163 | 172 | return SENDING_HOST |
164 | 173 |
|
165 | | - def _validate_account_id(self) -> None: |
| 174 | + def _validate_account_id(self, api_name: str = "Testing API") -> None: |
166 | 175 | if not self.account_id: |
167 | | - raise ClientConfigurationError("`account_id` is required for Testing API") |
| 176 | + raise ClientConfigurationError(f"`account_id` is required for {api_name}") |
168 | 177 |
|
169 | 178 | def _validate_itself(self) -> None: |
170 | 179 | if self.sandbox and not self.inbox_id: |
|
0 commit comments