173:class GmailClient:
174-    """Authenticated Gmail client for one account (API or XOAUTH2 SMTP)."""
175-
176-    def __init__(self, account_email: str, access_token: str, refresh_token: str,
177-                 client_config: dict, sending_method: str = "api", token_expiry=None):
178-        self.account_email = account_email
179-        self.client_config = client_config
180-        self.method = sending_method if sending_method in ("api", "smtp") else "api"
181-        creds = gcred.Credentials(
182-            token=access_token,
183-            refresh_token=refresh_token or None,
184-            token_uri=GOOGLE_TOKEN_URL,
185-            client_id=client_config["client_id"],
186-            client_secret=client_config["client_secret"],
187-            scopes=GMAIL_SCOPES,
188-        )
189-        self._creds = creds
190-        self._service = None
191-        self.token_expiry = token_expiry
192-
193-    def _ensure_valid(self):
194-        request = google.auth.transport.requests.Request()
195-        if not self._creds.valid:
180:        self.method = sending_method if sending_method in ("api", "smtp") else "api"
