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