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