Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 19 additions & 1 deletion examples/contacts/contact_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,22 @@ def delete_contact_field(contact_field_id: int) -> DeletedObject:


if __name__ == "__main__":
print(list_contact_fields())
created = create_contact_field(
name="example_field", data_type="string", merge_tag="EXAMPLE"
)
print(created)

fields = list_contact_fields()
print(fields)

field_id = fields[0].id
field = get_contact_field(contact_field_id=field_id)
print(field)

updated = update_contact_field(
contact_field_id=field_id, name=f"{field.name}-updated"
)
print(updated)

deleted = delete_contact_field(contact_field_id=field_id)
print(deleted)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
19 changes: 18 additions & 1 deletion examples/contacts/contact_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,21 @@ def delete_contact_list(contact_list_id: int) -> DeletedObject:


if __name__ == "__main__":
print(list_contact_lists())
created = create_contact_list(name="example-list")
print(created)

lists = list_contact_lists()
print(lists)

list_id = lists[0].id
contact_list = get_contact_list(contact_list_id=list_id)
print(contact_list)

updated = update_contact_list(
contact_list_id=list_id,
name=f"{contact_list.name}-updated",
)
print(updated)

deleted = delete_contact_list(contact_list_id=list_id)
print(deleted)
Comment thread
Ihor-Bilous marked this conversation as resolved.
5 changes: 5 additions & 0 deletions examples/contacts/contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def delete_contact(contact_id_or_email: str) -> DeletedObject:
},
)
print(created_contact)

updated_contact = update_contact(
created_contact.id,
fields={
Expand All @@ -68,5 +69,9 @@ def delete_contact(contact_id_or_email: str) -> DeletedObject:
},
)
print(updated_contact)

contact = get_contact(updated_contact.id)
print(contact)

deleted_contact = delete_contact(updated_contact.id)
print(deleted_contact)
26 changes: 25 additions & 1 deletion examples/email_templates/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,28 @@ def delete_template(template_id: str) -> DeletedObject:


if __name__ == "__main__":
print(list_templates())
created = create_template(
name="Example Template",
subject="Hello",
category="transactional",
body_text="Hello world",
)
print(created)

templates = list_templates()
print(templates)

template_id = templates[0].id
template = get_template(template_id=template_id)
print(template)

updated = update_template(
template_id=template_id,
name=f"{template.name}-updated",
subject=f"{template.subject}-updated",
body_text=f"{template.body_text}\nUpdated content.",
)
Comment thread
Ihor-Bilous marked this conversation as resolved.
print(updated)

deleted = delete_template(template_id=template_id)
print(deleted)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
9 changes: 8 additions & 1 deletion examples/general/account_accesses.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ def delete_account_access(account_id: int, account_access_id: int) -> DeletedObj


if __name__ == "__main__":
print(get_account_accesses(ACCOUNT_ID))
accesses = get_account_accesses(ACCOUNT_ID)
print(accesses)
if accesses:
access_id = accesses[0].id
deleted = delete_account_access(
account_id=ACCOUNT_ID, account_access_id=access_id
)
print(deleted)
3 changes: 2 additions & 1 deletion examples/general/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ def get_accounts() -> list[Account]:


if __name__ == "__main__":
print(get_accounts())
accounts = get_accounts()
print(accounts)
3 changes: 2 additions & 1 deletion examples/general/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ def get_current_billing_usage(account_id: int) -> BillingCycleUsage:


if __name__ == "__main__":
print(get_current_billing_usage(ACCOUNT_ID))
usage = get_current_billing_usage(ACCOUNT_ID)
print(usage)
14 changes: 13 additions & 1 deletion examples/general/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,16 @@ def bulk_permissions_update(


if __name__ == "__main__":
print(get_permission_resources(ACCOUNT_ID))
resources = get_permission_resources(ACCOUNT_ID)
print(resources)
if resources:
account_access_id = resources[0].id
payload = [
mt.PermissionResourceParams(resource_name=resources[0].name, permissions=[])
]
updated = bulk_permissions_update(
ACCOUNT_ID,
account_access_id,
payload,
)
print(updated)
Comment thread
Ihor-Bilous marked this conversation as resolved.
1 change: 1 addition & 0 deletions examples/sending/advanced_sending.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient:
sandbox=True,
inbox_id="<YOUR_INBOX_ID>",
)
raise ValueError(f"Invalid sending type: {type_}")


# Image should be in the same level in directory like this python file.
Expand Down
1 change: 1 addition & 0 deletions examples/sending/batch_advanced_sending.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient:
sandbox=True,
inbox_id="<YOUR_INBOX_ID>",
)
raise ValueError(f"Invalid sending type: {type_}")


# Image should be in the same level in directory like this python file.
Expand Down
1 change: 1 addition & 0 deletions examples/sending/batch_minimal_sending.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient:
return mt.MailtrapClient(
token=API_TOKEN, sandbox=True, inbox_id="<YOUR_INBOX_ID>"
)
raise ValueError(f"Invalid sending type: {type_}")


batch_mail = mt.BatchSendEmailParams(
Expand Down
1 change: 1 addition & 0 deletions examples/sending/batch_sending_with_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient:
return mt.MailtrapClient(
token=API_TOKEN, sandbox=True, inbox_id="<YOUR_INBOX_ID>"
)
raise ValueError(f"Invalid sending type: {type_}")


batch_mail = mt.BatchSendEmailParams(
Expand Down
1 change: 1 addition & 0 deletions examples/sending/minimal_sending.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient:
return mt.MailtrapClient(
token=API_TOKEN, sandbox=True, inbox_id="<YOUR_INBOX_ID>"
)
raise ValueError(f"Invalid sending type: {type_}")


mail = mt.Mail(
Expand Down
1 change: 1 addition & 0 deletions examples/sending/sending_with_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient:
return mt.MailtrapClient(
token=API_TOKEN, sandbox=True, inbox_id="<YOUR_INBOX_ID>"
)
raise ValueError(f"Invalid sending type: {type_}")


mail = mt.MailFromTemplate(
Expand Down
6 changes: 5 additions & 1 deletion examples/suppressions/suppressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ def delete_suppression(suppression_id: str) -> Suppression:


if __name__ == "__main__":
print(list_suppressions())
suppressions = list_suppressions()
print(suppressions)
if suppressions:
deleted_suppression = delete_suppression(suppressions[0].id)
print(deleted_suppression)
5 changes: 5 additions & 0 deletions examples/testing/attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,8 @@ def get_attachment(inbox_id: int, message_id: int, attachment_id: int) -> Attach
if __name__ == "__main__":
attachments = list_attachments(inbox_id=INBOX_ID, message_id=MESSAGE_ID)
print(attachments)
if attachments:
attachment = get_attachment(
inbox_id=INBOX_ID, message_id=MESSAGE_ID, attachment_id=attachments[0].id
)
print(attachment)
28 changes: 28 additions & 0 deletions examples/testing/inboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,33 @@ def delete_inbox(inbox_id: int):


if __name__ == "__main__":
created = create_inbox(project_id=1, inbox_name="example-created-inbox")
print(created)

inboxes = list_inboxes()
print(inboxes)

inbox_id = inboxes[0].id
inbox = get_inbox_by_id(inbox_id=inbox_id)
print(inbox)

updated = update_inbox(inbox_id=inbox_id, new_name=f"{inbox.name}-updated")
print(updated)

cleaned = clean_inbox(inbox_id=inbox_id)
print(cleaned)

marked = mark_inbox_as_read(inbox_id=inbox_id)
print(marked)

reset_creds = reset_inbox_credentials(inbox_id=inbox_id)
print(reset_creds)

enabled = enable_inbox_email_address(inbox_id=inbox_id)
print(enabled)

reset_username = reset_inbox_email_username(inbox_id=inbox_id)
print(reset_username)

deleted = delete_inbox(inbox_id=inbox_id)
print(deleted)
Comment thread
Ihor-Bilous marked this conversation as resolved.
38 changes: 38 additions & 0 deletions examples/testing/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,41 @@ def get_mail_headers(inbox_id: int, message_id: str) -> str:
if __name__ == "__main__":
messages = list_messages(inbox_id=INBOX_ID)
print(messages)
if messages:
msg_id = messages[0].id
message = get_message(inbox_id=INBOX_ID, message_id=msg_id)
print(message)

updated = update_message(inbox_id=INBOX_ID, message_id=msg_id, is_read=True)
print(updated)

forwarded = forward_message(
inbox_id=INBOX_ID,
message_id=msg_id,
email="example@example.com",
)
print(forwarded)

spam = get_spam_report(inbox_id=INBOX_ID, message_id=msg_id)
print(spam)

html_analysis = get_html_analysis(inbox_id=INBOX_ID, message_id=msg_id)
print(html_analysis)

text = get_text_message(inbox_id=INBOX_ID, message_id=msg_id)
print(text)

raw = get_raw_message(inbox_id=INBOX_ID, message_id=msg_id)
print(raw)

html_src = get_html_source(inbox_id=INBOX_ID, message_id=msg_id)
print(html_src)

html_msg = get_html_message(inbox_id=INBOX_ID, message_id=msg_id)
print(html_msg)

eml = get_message_as_eml(inbox_id=INBOX_ID, message_id=msg_id)
print(eml)

headers = get_mail_headers(inbox_id=INBOX_ID, message_id=msg_id)
print(headers)
14 changes: 14 additions & 0 deletions examples/testing/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,19 @@ def delete_project(project_id: int):


if __name__ == "__main__":
created = create_project(name="example-created-project")
print(created)

projects = list_projects()
print(projects)

project_id = projects[0].id

project = get_project(project_id=project_id)
print(project)

updated = update_project(project_id=created.id, new_name=f"{project.name}-updated")
print(updated)

deleted = delete_project(project_id=created.id)
print(deleted)
Comment thread
Ihor-Bilous marked this conversation as resolved.