(mailbox) allow to activate mailbox

We send a request to dimail API and change mailbox status to enabled.
This commit is contained in:
Sabrina Demagny
2024-11-26 12:26:54 +01:00
parent a6f409f6ed
commit 02c6048d2c
4 changed files with 132 additions and 0 deletions

View File

@@ -291,3 +291,22 @@ class DimailAPIClient:
)
return response
return self.raise_exception_for_unexpected_response(response)
def enable_mailbox(self, mailbox, user_sub=None):
"""Send a request to enable a mailbox to dimail API"""
response = session.patch(
f"{self.API_URL}/domains/{mailbox.domain.name}/mailboxes/{mailbox.local_part}",
json={"active": "yes"},
headers=self.get_headers(user_sub),
verify=True,
timeout=10,
)
if response.status_code == status.HTTP_200_OK:
logger.info(
"Mailbox %s successfully enabled on domain %s by user %s",
str(mailbox),
str(mailbox.domain),
user_sub,
)
return response
return self.raise_exception_for_unexpected_response(response)