diff --git a/examples/contacts/contact_fields.py b/examples/contacts/contact_fields.py index cc2332d..9415d52 100644 --- a/examples/contacts/contact_fields.py +++ b/examples/contacts/contact_fields.py @@ -46,4 +46,21 @@ 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 = get_contact_field(contact_field_id=created.id) + print(field) + + updated = update_contact_field( + contact_field_id=created.id, name=f"{field.name}-updated" + ) + print(updated) + + deleted = delete_contact_field(contact_field_id=created.id) + print(deleted) diff --git a/examples/contacts/contact_lists.py b/examples/contacts/contact_lists.py index e73ee60..4623d23 100644 --- a/examples/contacts/contact_lists.py +++ b/examples/contacts/contact_lists.py @@ -32,4 +32,20 @@ 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) + + contact_list = get_contact_list(contact_list_id=created.id) + print(contact_list) + + updated = update_contact_list( + contact_list_id=created.id, + name=f"{contact_list.name}-updated", + ) + print(updated) + + deleted = delete_contact_list(contact_list_id=created.id) + print(deleted) diff --git a/examples/contacts/contacts.py b/examples/contacts/contacts.py index e0ab57a..dc2a850 100644 --- a/examples/contacts/contacts.py +++ b/examples/contacts/contacts.py @@ -60,6 +60,7 @@ def delete_contact(contact_id_or_email: str) -> DeletedObject: }, ) print(created_contact) + updated_contact = update_contact( created_contact.id, fields={ @@ -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) diff --git a/examples/email_templates/templates.py b/examples/email_templates/templates.py index 90b2d7b..32f5dee 100644 --- a/examples/email_templates/templates.py +++ b/examples/email_templates/templates.py @@ -32,12 +32,12 @@ def create_template( return templates_api.create(params) -def get_template(template_id: str) -> EmailTemplate: +def get_template(template_id: int) -> EmailTemplate: return templates_api.get_by_id(template_id) def update_template( - template_id: str, + template_id: int, name: Optional[str] = None, subject: Optional[str] = None, category: Optional[str] = None, @@ -54,9 +54,32 @@ def update_template( return templates_api.update(template_id, params) -def delete_template(template_id: str) -> DeletedObject: +def delete_template(template_id: int) -> DeletedObject: return templates_api.delete(template_id) 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 = get_template(template_id=created.id) + print(template) + + updated = update_template( + template_id=created.id, + name=f"{template.name}-updated", + subject=f"{template.subject}-updated", + body_text=f"{template.body_text}\nUpdated content.", + ) + print(updated) + + deleted = delete_template(template_id=created.id) + print(deleted) diff --git a/examples/general/account_accesses.py b/examples/general/account_accesses.py index 893c089..75c276c 100644 --- a/examples/general/account_accesses.py +++ b/examples/general/account_accesses.py @@ -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) diff --git a/examples/general/accounts.py b/examples/general/accounts.py index 6e3ee24..5c03f7d 100644 --- a/examples/general/accounts.py +++ b/examples/general/accounts.py @@ -12,4 +12,5 @@ def get_accounts() -> list[Account]: if __name__ == "__main__": - print(get_accounts()) + accounts = get_accounts() + print(accounts) diff --git a/examples/general/billing.py b/examples/general/billing.py index cfade7b..a6babe3 100644 --- a/examples/general/billing.py +++ b/examples/general/billing.py @@ -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) diff --git a/examples/general/permissions.py b/examples/general/permissions.py index 8c04db1..7e9a727 100644 --- a/examples/general/permissions.py +++ b/examples/general/permissions.py @@ -26,4 +26,20 @@ 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 + permissions = [ + mt.PermissionResourceParams( + resource_id=resources[0].id, + resource_type=resources[0].type, + access_level="viewer", + ) + ] + updated = bulk_permissions_update( + ACCOUNT_ID, + account_access_id, + permissions, + ) + print(updated) diff --git a/examples/sending/advanced_sending.py b/examples/sending/advanced_sending.py index 4155e70..13c5c94 100644 --- a/examples/sending/advanced_sending.py +++ b/examples/sending/advanced_sending.py @@ -23,6 +23,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient: sandbox=True, inbox_id="", ) + raise ValueError(f"Invalid sending type: {type_}") # Image should be in the same level in directory like this python file. diff --git a/examples/sending/batch_advanced_sending.py b/examples/sending/batch_advanced_sending.py index 7923133..2b37c9f 100644 --- a/examples/sending/batch_advanced_sending.py +++ b/examples/sending/batch_advanced_sending.py @@ -23,6 +23,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient: sandbox=True, inbox_id="", ) + raise ValueError(f"Invalid sending type: {type_}") # Image should be in the same level in directory like this python file. diff --git a/examples/sending/batch_minimal_sending.py b/examples/sending/batch_minimal_sending.py index 06365d5..b3d8b6b 100644 --- a/examples/sending/batch_minimal_sending.py +++ b/examples/sending/batch_minimal_sending.py @@ -19,6 +19,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient: return mt.MailtrapClient( token=API_TOKEN, sandbox=True, inbox_id="" ) + raise ValueError(f"Invalid sending type: {type_}") batch_mail = mt.BatchSendEmailParams( diff --git a/examples/sending/batch_sending_with_template.py b/examples/sending/batch_sending_with_template.py index 6996c33..7a1acdf 100644 --- a/examples/sending/batch_sending_with_template.py +++ b/examples/sending/batch_sending_with_template.py @@ -18,6 +18,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient: return mt.MailtrapClient( token=API_TOKEN, sandbox=True, inbox_id="" ) + raise ValueError(f"Invalid sending type: {type_}") batch_mail = mt.BatchSendEmailParams( diff --git a/examples/sending/minimal_sending.py b/examples/sending/minimal_sending.py index 17a5e8f..c203c79 100644 --- a/examples/sending/minimal_sending.py +++ b/examples/sending/minimal_sending.py @@ -19,6 +19,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient: return mt.MailtrapClient( token=API_TOKEN, sandbox=True, inbox_id="" ) + raise ValueError(f"Invalid sending type: {type_}") mail = mt.Mail( diff --git a/examples/sending/sending_with_template.py b/examples/sending/sending_with_template.py index 795d872..59145b1 100644 --- a/examples/sending/sending_with_template.py +++ b/examples/sending/sending_with_template.py @@ -18,6 +18,7 @@ def get_client(type_: SendingType) -> mt.MailtrapClient: return mt.MailtrapClient( token=API_TOKEN, sandbox=True, inbox_id="" ) + raise ValueError(f"Invalid sending type: {type_}") mail = mt.MailFromTemplate( diff --git a/examples/suppressions/suppressions.py b/examples/suppressions/suppressions.py index a88850d..001a7e4 100644 --- a/examples/suppressions/suppressions.py +++ b/examples/suppressions/suppressions.py @@ -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) diff --git a/examples/testing/attachments.py b/examples/testing/attachments.py index d038971..9bc5a05 100644 --- a/examples/testing/attachments.py +++ b/examples/testing/attachments.py @@ -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) diff --git a/examples/testing/inboxes.py b/examples/testing/inboxes.py index a0a698a..f7d89aa 100644 --- a/examples/testing/inboxes.py +++ b/examples/testing/inboxes.py @@ -61,3 +61,31 @@ def delete_inbox(inbox_id: int): if __name__ == "__main__": inboxes = list_inboxes() print(inboxes) + + created = create_inbox(project_id=1, inbox_name="example-created-inbox") + print(created) + + inbox_id = created.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) diff --git a/examples/testing/messages.py b/examples/testing/messages.py index 5863039..f80ca44 100644 --- a/examples/testing/messages.py +++ b/examples/testing/messages.py @@ -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) diff --git a/examples/testing/projects.py b/examples/testing/projects.py index 8a02629..f3bcf4b 100644 --- a/examples/testing/projects.py +++ b/examples/testing/projects.py @@ -31,3 +31,15 @@ def delete_project(project_id: int): if __name__ == "__main__": projects = list_projects() print(projects) + + created = create_project(name="example-created-project") + print(created) + + project = get_project(project_id=created.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)