Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ with Inkbox(api_key="ApiKey_...") as inkbox:
# Get a specific mailbox
mailbox = inkbox.mailboxes.get("abc-xyz@inkboxmail.com")

# Create a standalone mailbox
mailbox = inkbox.mailboxes.create(display_name="Support Inbox")
# Create a mailbox linked to an agent identity
mailbox = inkbox.mailboxes.create(agent_handle="support-agent", display_name="Support Inbox")
print(mailbox.email_address)

# Update display name or webhook URL
Expand Down Expand Up @@ -339,8 +339,8 @@ const mailboxes = await inkbox.mailboxes.list();
// Get a specific mailbox
const mailbox = await inkbox.mailboxes.get("abc-xyz@inkboxmail.com");

// Create a standalone mailbox
const mb = await inkbox.mailboxes.create({ displayName: "Support Inbox" });
// Create a mailbox linked to an agent identity
const mb = await inkbox.mailboxes.create({ agentHandle: "support-agent", displayName: "Support Inbox" });
console.log(mb.emailAddress);

// Update display name or webhook URL
Expand Down
4 changes: 2 additions & 2 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ mailboxes = inkbox.mailboxes.list()
# Get a specific mailbox
mailbox = inkbox.mailboxes.get("abc-xyz@inkboxmail.com")

# Create a standalone mailbox
mailbox = inkbox.mailboxes.create(display_name="Support Inbox")
# Create a mailbox linked to an agent identity
mailbox = inkbox.mailboxes.create(agent_handle="support-agent", display_name="Support Inbox")
print(mailbox.email_address)

# Update display name or webhook URL
Expand Down
19 changes: 13 additions & 6 deletions python/inkbox/agent_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,20 @@ def create_mailbox(self, *, display_name: str | None = None) -> IdentityMailbox:
Returns:
The newly created and linked mailbox.
"""
mailbox = self._inkbox._mailboxes.create(display_name=display_name)
data = self._inkbox._ids_resource.assign_mailbox(
self.agent_handle, mailbox_id=mailbox.id
mailbox = self._inkbox._mailboxes.create(
agent_handle=self.agent_handle,
display_name=display_name,
)
self._mailbox = data.mailbox
self._data = data
return self._mailbox # type: ignore[return-value]
linked = IdentityMailbox(
id=mailbox.id,
email_address=mailbox.email_address,
display_name=mailbox.display_name,
status=mailbox.status,
created_at=mailbox.created_at,
updated_at=mailbox.updated_at,
)
self._mailbox = linked
return linked

def assign_mailbox(self, mailbox_id: str) -> IdentityMailbox:
"""Link an existing mailbox to this identity.
Expand Down
6 changes: 4 additions & 2 deletions python/inkbox/mail/resources/mailboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ def __init__(self, http: HttpTransport) -> None:
def create(
self,
*,
agent_handle: str,
display_name: str | None = None,
) -> Mailbox:
"""Create a new mailbox.
"""Create a new mailbox and link it to an agent identity.

The email address is automatically generated by the server.

Args:
agent_handle: Handle of the agent identity to assign this mailbox to.
display_name: Optional human-readable name shown as the sender.

Returns:
The created mailbox.
"""
body: dict[str, Any] = {}
body: dict[str, Any] = {"agent_handle": agent_handle}
if display_name is not None:
body["display_name"] = display_name
data = self._http.post(_BASE, json=body)
Expand Down
8 changes: 4 additions & 4 deletions python/tests/test_mail_mailboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ def test_create_with_display_name(self):
res, http = _resource()
http.post.return_value = MAILBOX_DICT

mailbox = res.create(display_name="Agent 01")
mailbox = res.create(agent_handle="support-agent", display_name="Agent 01")

http.post.assert_called_once_with(
"/mailboxes", json={"display_name": "Agent 01"}
"/mailboxes", json={"agent_handle": "support-agent", "display_name": "Agent 01"}
)
assert mailbox.display_name == "Agent 01"

def test_create_without_display_name(self):
res, http = _resource()
http.post.return_value = {**MAILBOX_DICT, "display_name": None}

mailbox = res.create()
mailbox = res.create(agent_handle="support-agent")

http.post.assert_called_once_with("/mailboxes", json={})
http.post.assert_called_once_with("/mailboxes", json={"agent_handle": "support-agent"})
assert mailbox.display_name is None


Expand Down
4 changes: 2 additions & 2 deletions typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ const mailboxes = await inkbox.mailboxes.list();
// Get a specific mailbox
const mailbox = await inkbox.mailboxes.get("abc-xyz@inkboxmail.com");

// Create a standalone mailbox
const mb = await inkbox.mailboxes.create({ displayName: "Support Inbox" });
// Create a mailbox linked to an agent identity
const mb = await inkbox.mailboxes.create({ agentHandle: "support-agent", displayName: "Support Inbox" });
console.log(mb.emailAddress);

// Update display name or webhook URL
Expand Down
Loading