diff --git a/specs/contacts.openapi.yml b/specs/contacts.openapi.yml index ee337db..ba608b6 100644 --- a/specs/contacts.openapi.yml +++ b/specs/contacts.openapi.yml @@ -124,23 +124,25 @@ paths: - lang: php label: PHP source: | + contacts($accountId); - $contact = $client->contacts($accountId)->create([ - 'email' => 'john.smith@example.com', - 'fields' => [ - 'first_name' => 'John', - 'last_name' => 'Smith', - 'company' => 'Example Inc' - ], - 'list_ids' => [1, 2, 3] - ]); + $response = $contacts->createContact( + CreateContact::init( + 'john.smith@example.com', + ['first_name' => 'John', 'last_name' => 'Smith', 'company' => 'Example Inc'], + [1, 2, 3] // List IDs + ) + ); - echo "Contact created: {$contact['email']}\n"; + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -314,22 +316,22 @@ paths: - lang: php label: PHP source: | + contacts($accountId); - // Get by contact ID - $contact = $client->contacts($accountId)->get($contactId); + // Get contact by ID + $response = $contacts->getContactById('019706a8-0000-0000-0000-4f26816b467a'); - // Or get by email (URL encoded) - $contactByEmail = $client->contacts($accountId)->get( - urlencode('john.smith@example.com') - ); + // OR get contact by email + $response = $contacts->getContactByEmail('john.smith@example.com'); - echo "Contact: {$contact['email']}\n"; - echo "Status: {$contact['status']}\n"; + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -453,9 +455,37 @@ paths: use Mailtrap\Config; use Mailtrap\MailtrapGeneralClient; use Mailtrap\DTO\Request\Contact\UpdateContact; - $config = new Config("YOUR_API_KEY"); - $contacts = (new MailtrapGeneralClient($config))->contacts(12345); - $response = $contacts->updateContactById("contact_id", UpdateContact::init("new@example.com", ["first_name" => "John"])); + use Mailtrap\Helper\ResponseHelper; + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + // Update contact by ID + $response = $contacts->updateContactById( + '019706a8-0000-0000-0000-4f26816b467a', + UpdateContact::init( + 'john.smith@example.com', + ['first_name' => 'John', 'last_name' => 'Smith'], + [3], // List IDs to add + [1, 2], // List IDs to remove + true // Unsubscribe + ) + ); + + // OR update contact by email + $response = $contacts->updateContactByEmail( + 'john.smith@example.com', + UpdateContact::init( + 'john.smith@example.com', + ['first_name' => 'John', 'last_name' => 'Smith'], + [3], + [1, 2], + true + ) + ); + + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -553,9 +583,18 @@ paths: contacts(12345); - $response = $contacts->deleteContactById("contact_id"); + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + // Delete contact by ID + $response = $contacts->deleteContactById('019706a8-0000-0000-0000-4f26816b467a'); + + // OR delete contact by email + $response = $contacts->deleteContactByEmail('john.smith@example.com'); + + var_dump($response->getStatusCode()); - lang: python label: Python source: | @@ -625,9 +664,27 @@ paths: contacts(12345); - $response = $contacts->createEvent("contact_id", ["name" => "UserLogin", "params" => ["user_id" => 101, "is_active" => true]]); + use Mailtrap\DTO\Request\Contact\CreateContactEvent; + use Mailtrap\Helper\ResponseHelper; + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $response = $contacts->createContactEvent( + 'john.smith@example.com', // Contact identifier (email or UUID) + CreateContactEvent::init( + 'UserLogin', + [ + 'user_id' => 101, + 'user_name' => 'John Smith', + 'is_active' => true, + 'last_seen' => null + ] + ) + ); + + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -719,9 +776,22 @@ paths: contactExports(12345); - $response = $exports->create(["filters" => [["name" => "list_id", "operator" => "equal", "value" => [1, 2]]]]); + use Mailtrap\DTO\Request\Contact\ContactExportFilter; + use Mailtrap\Helper\ResponseHelper; + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $filters = [ + // Export contacts that belong to lists 1 or 2 + ContactExportFilter::init('list_id', 'equal', [1, 2]), + // Only subscribed contacts + ContactExportFilter::init('subscription_status', 'equal', 'subscribed'), + ]; + + $response = $contacts->createContactExport($filters); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -812,9 +882,16 @@ paths: contactExports(12345); - $response = $exports->get($exportId); + use Mailtrap\Helper\ResponseHelper; + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $exportId = $_ENV['MAILTRAP_EXPORT_ID']; + $response = $contacts->getContactExport($exportId); + + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -904,11 +981,30 @@ paths: contactImports(12345); - $response = $imports->create(["contacts" => [ - ["email" => "user1@example.com", "fields" => ["first_name" => "John"], "list_ids_included" => [1, 2]] - ]]); + use Mailtrap\DTO\Request\Contact\ImportContact; + use Mailtrap\Helper\ResponseHelper; + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $contactsToImport = [ + new ImportContact( + email: 'customer1@example.com', + fields: ['first_name' => 'John', 'last_name' => 'Smith', 'zip_code' => 11111], + listIdsIncluded: [1, 2], + listIdsExcluded: [4, 5] + ), + new ImportContact( + email: 'customer2@example.com', + fields: ['first_name' => 'Joe', 'last_name' => 'Doe', 'zip_code' => 22222], + listIdsIncluded: [1], + listIdsExcluded: [4] + ), + ]; + + $response = $contacts->importContacts($contactsToImport); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -1008,9 +1104,16 @@ paths: contactImports(12345); - $response = $imports->get($importId); + use Mailtrap\Helper\ResponseHelper; + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $importId = $_ENV['MAILTRAP_IMPORT_ID']; + $response = $contacts->getContactImport($importId); + + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -1089,10 +1192,19 @@ paths: source: | contactLists(12345); - $response = $lists->getAll(); + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + try { + $response = $contacts->getAllContactLists(); + var_dump(ResponseHelper::toArray($response)); + } catch (Exception $e) { + echo 'Error: ' . $e->getMessage(); + } - lang: python label: Python source: | @@ -1163,10 +1275,19 @@ paths: source: | contactLists(12345); - $response = $lists->create(["name" => "Customers"]); + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + try { + $response = $contacts->createContactList('Customers'); + var_dump(ResponseHelper::toArray($response)); + } catch (Exception $e) { + echo 'Error: ' . $e->getMessage(); + } - lang: python label: Python source: | @@ -1245,10 +1366,16 @@ paths: source: | contactLists(12345); - $response = $lists->get($listId); + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $listId = $_ENV['MAILTRAP_LIST_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $response = $contacts->getContactList($listId); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -1312,10 +1439,16 @@ paths: source: | contactLists(12345); - $response = $lists->update($listId, ["name" => "Former Customers"]); + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $listId = $_ENV['MAILTRAP_LIST_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $response = $contacts->updateContactList($listId, 'Former Customers'); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -1393,9 +1526,14 @@ paths: contactLists(12345); - $lists->delete($listId); + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $listId = $_ENV['MAILTRAP_LIST_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $response = $contacts->deleteContactList($listId); + echo $response->getStatusCode(); // Should be 204 - lang: python label: Python source: | @@ -1460,9 +1598,14 @@ paths: contactFields(12345); - $response = $fields->getAll(); + use Mailtrap\Helper\ResponseHelper; + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $response = $contacts->getAllContactFields(); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -1543,9 +1686,14 @@ paths: contactFields(12345); - $response = $fields->create(["name" => "Company", "data_type" => "text", "merge_tag" => "company"]); + use Mailtrap\Helper\ResponseHelper; + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $response = $contacts->createContactField('Company', 'text', 'company'); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -1656,9 +1804,15 @@ paths: contactFields(12345); - $response = $fields->get($fieldId); + use Mailtrap\Helper\ResponseHelper; + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $fieldId = $_ENV['MAILTRAP_FIELD_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $response = $contacts->getContactField($fieldId); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -1726,9 +1880,15 @@ paths: contactFields(12345); - $response = $fields->update($fieldId, ["name" => "Updated Name", "merge_tag" => "updated_name"]); + use Mailtrap\Helper\ResponseHelper; + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $fieldId = $_ENV['MAILTRAP_FIELD_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $response = $contacts->updateContactField($fieldId, 'Updated Name', 'updated_name'); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -1828,9 +1988,14 @@ paths: contactFields(12345); - $fields->delete($fieldId); + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $fieldId = $_ENV['MAILTRAP_FIELD_ID']; + $contacts = (new MailtrapGeneralClient($config))->contacts($accountId); + + $response = $contacts->deleteContactField($fieldId); + var_dump($response->getStatusCode()); - lang: python label: Python source: | diff --git a/specs/email-api.openapi.yml b/specs/email-api.openapi.yml index 47a26e7..9d97901 100644 --- a/specs/email-api.openapi.yml +++ b/specs/email-api.openapi.yml @@ -77,15 +77,17 @@ paths: source: | domains($accountId); $response = $sendingDomains->createSendingDomain('example.com'); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -221,17 +223,17 @@ paths: source: | domains($accountId); $response = $sendingDomains->getSendingDomains(); - $domains = ResponseHelper::toArray($response); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -338,18 +340,18 @@ paths: source: | domains($accountId); - $domainId = 12345; + $domainId = $_ENV['MAILTRAP_DOMAIN_ID']; $response = $sendingDomains->getDomainById($domainId); - $domain = ResponseHelper::toArray($response); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -459,13 +461,14 @@ paths: use Mailtrap\MailtrapSendingClient; $config = new Config($_ENV['MAILTRAP_API_KEY']); - $accountId = (int) $_ENV['MAILTRAP_ACCOUNT_ID']; + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; $sendingDomains = (new MailtrapSendingClient($config)) ->domains($accountId); - $domainId = 12345; + $domainId = $_ENV['MAILTRAP_DOMAIN_ID']; $response = $sendingDomains->deleteSendingDomain($domainId); + var_dump($response->getStatusCode()); - lang: python label: Python source: | @@ -578,18 +581,19 @@ paths: use Mailtrap\MailtrapSendingClient; $config = new Config($_ENV['MAILTRAP_API_KEY']); - $accountId = (int) $_ENV['MAILTRAP_ACCOUNT_ID']; + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; $sendingDomains = (new MailtrapSendingClient($config)) ->domains($accountId); - $domainId = 12345; + $domainId = $_ENV['MAILTRAP_DOMAIN_ID']; $email = 'devops@example.com'; $response = $sendingDomains->sendDomainSetupInstructions( $domainId, $email ); + var_dump($response->getStatusCode()); - lang: python label: Python source: | @@ -743,12 +747,13 @@ paths: label: PHP source: | suppressions($accountId); @@ -759,7 +764,7 @@ paths: // Or search for specific email $response = $suppressions->getSuppressions('suppressed@example.com'); - $data = ResponseHelper::toArray($response); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -904,13 +909,14 @@ paths: use Mailtrap\MailtrapSendingClient; $config = new Config($_ENV['MAILTRAP_API_KEY']); - $accountId = (int) $_ENV['MAILTRAP_ACCOUNT_ID']; + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; $suppressions = (new MailtrapSendingClient($config)) ->suppressions($accountId); $suppressionId = 'abc123-def456'; $response = $suppressions->deleteSuppression($suppressionId); + var_dump($response->getStatusCode()); - lang: python label: Python source: | @@ -1009,11 +1015,19 @@ paths: label: PHP source: | emailTemplates(12345); - $response = $templates->getAll(); + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + + $emailTemplates = (new MailtrapGeneralClient($config)) + ->emailTemplates($accountId); + + $response = $emailTemplates->getAllEmailTemplates(); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -1084,17 +1098,28 @@ paths: - lang: php label: PHP source: | + emailTemplates($accountId)->create([ - 'name' => 'Welcome Email', - 'subject' => 'Welcome to {{company_name}}!', - 'category' => 'onboarding', - 'body_html' => '
This is a test email for sandbox.
') - ->addTextHeader('X-MT-Category', 'test'); + ->html('This is a test email for sandbox.
'); + + $response = $mailtrap->send($email); - $response = $mailtrap->sandbox() - ->inboxes(TEST_INBOX_ID) - ->emails() - ->send($email); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -2213,10 +2217,10 @@ paths: label: PHP source: | text('Batch email content'); $recipientEmails = [ - (new MailtrapEmail())->to(new Address('recipient1@example.com')), - (new MailtrapEmail())->to(new Address('recipient2@example.com')), + (new MailtrapEmail())->to(new Address('recipient1@example.com', 'Recipient 1')), + (new MailtrapEmail())->to(new Address('recipient2@example.com', 'Recipient 2')), ]; $response = $mailtrap->batchSend($recipientEmails, $baseEmail); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python @@ -2467,17 +2472,17 @@ paths: source: | messages($accountId, $inboxId); - $messageId = 67890; + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; $response = $sandboxMessages->getById($messageId); var_dump(ResponseHelper::toArray($response)); @@ -2701,17 +2706,17 @@ paths: source: | messages($accountId, $inboxId); - $messageId = 67890; + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; $response = $sandboxMessages->markAsRead($messageId); var_dump(ResponseHelper::toArray($response)); @@ -2923,13 +2928,13 @@ paths: use Mailtrap\MailtrapSandboxClient; $config = new Config($_ENV['MAILTRAP_API_KEY']); - $accountId = (int) $_ENV['MAILTRAP_ACCOUNT_ID']; - $inboxId = (int) $_ENV['MAILTRAP_INBOX_ID']; + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; $sandboxMessages = (new MailtrapSandboxClient($config)) ->messages($accountId, $inboxId); - $messageId = 67890; + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; $response = $sandboxMessages->delete($messageId); var_dump($response->getStatusCode()); @@ -3140,20 +3145,20 @@ paths: - lang: php label: PHP source: | + messages($accountId) - ->getList($inboxId); + $sandboxMessages = (new MailtrapSandboxClient($config)) + ->messages($accountId, $inboxId); - foreach ($messages as $message) { - echo "From: {$message['from_email']}\n"; - echo "Subject: {$message['subject']}\n"; - echo "Received: {$message['created_at']}\n"; - } + $response = $sandboxMessages->getList(); + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -3326,17 +3331,17 @@ paths: source: | messages($accountId, $inboxId); - $messageId = 67890; + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; $response = $sandboxMessages->forward($messageId, 'recipient@example.com'); var_dump(ResponseHelper::toArray($response)); @@ -3509,13 +3514,19 @@ paths: source: | messages((int)$_ENV['MAILTRAP_ACCOUNT_ID'], (int)$_ENV['MAILTRAP_INBOX_ID']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; + + $sandboxMessages = (new MailtrapSandboxClient($config)) + ->messages($accountId, $inboxId); + + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; + $response = $sandboxMessages->getSpamScore($messageId); - $response = $sandboxMessages->getSpamScore(67890); var_dump(ResponseHelper::toArray($response)); - lang: python label: Python @@ -3668,13 +3679,19 @@ paths: source: | messages((int)$_ENV['MAILTRAP_ACCOUNT_ID'], (int)$_ENV['MAILTRAP_INBOX_ID']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; + + $sandboxMessages = (new MailtrapSandboxClient($config)) + ->messages($accountId, $inboxId); + + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; + $response = $sandboxMessages->getHtmlAnalysis($messageId); - $response = $sandboxMessages->getHtmlAnalysis(67890); var_dump(ResponseHelper::toArray($response)); - lang: python label: Python @@ -3776,11 +3793,21 @@ paths: source: | messages((int)$_ENV['MAILTRAP_ACCOUNT_ID'], (int)$_ENV['MAILTRAP_INBOX_ID']); - $textBody = ResponseHelper::toString($sandboxMessages->getText(67890)); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; + + $sandboxMessages = (new MailtrapSandboxClient($config)) + ->messages($accountId, $inboxId); + + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; + $textBody = ResponseHelper::toString( + $sandboxMessages->getText($messageId) + ); + var_dump($textBody); - lang: python label: Python @@ -3919,11 +3946,21 @@ paths: source: | messages((int)$_ENV['MAILTRAP_ACCOUNT_ID'], (int)$_ENV['MAILTRAP_INBOX_ID']); - $rawBody = ResponseHelper::toString($sandboxMessages->getRaw(67890)); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; + + $sandboxMessages = (new MailtrapSandboxClient($config)) + ->messages($accountId, $inboxId); + + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; + $rawBody = ResponseHelper::toString( + $sandboxMessages->getRaw($messageId) + ); + var_dump($rawBody); - lang: python label: Python @@ -4043,10 +4080,16 @@ paths: use Mailtrap\Config; use Mailtrap\MailtrapSandboxClient; use Mailtrap\Helper\ResponseHelper; + + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; $config = new Config($_ENV['MAILTRAP_API_KEY']); - $sandboxMessages = (new MailtrapSandboxClient($config))->messages((int)$_ENV['MAILTRAP_ACCOUNT_ID'], (int)$_ENV['MAILTRAP_INBOX_ID']); - $htmlSource = ResponseHelper::toString($sandboxMessages->getSource(67890)); - var_dump($htmlSource); + + $sandboxMessages = (new MailtrapSandboxClient($config))->messages($accountId, $inboxId); + + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; + $response = $sandboxMessages->getSource($messageId); + var_dump(ResponseHelper::toString($response)); - lang: python label: Python source: | @@ -4161,11 +4204,21 @@ paths: source: | messages((int)$_ENV['MAILTRAP_ACCOUNT_ID'], (int)$_ENV['MAILTRAP_INBOX_ID']); - $htmlBody = ResponseHelper::toString($sandboxMessages->getHtml(67890)); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; + + $sandboxMessages = (new MailtrapSandboxClient($config)) + ->messages($accountId, $inboxId); + + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; + $htmlBody = ResponseHelper::toString( + $sandboxMessages->getHtml($messageId) + ); + var_dump($htmlBody); - lang: python label: Python @@ -4305,11 +4358,21 @@ paths: source: | messages((int)$_ENV['MAILTRAP_ACCOUNT_ID'], (int)$_ENV['MAILTRAP_INBOX_ID']); - $emlContent = ResponseHelper::toString($sandboxMessages->getEml(67890)); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; + + $sandboxMessages = (new MailtrapSandboxClient($config)) + ->messages($accountId, $inboxId); + + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; + $emlContent = ResponseHelper::toString( + $sandboxMessages->getEml($messageId) + ); + var_dump($emlContent); - lang: python label: Python @@ -4401,11 +4464,20 @@ paths: source: | messages((int)$_ENV['MAILTRAP_ACCOUNT_ID'], (int)$_ENV['MAILTRAP_INBOX_ID']); - $mailHeaders = $sandboxMessages->getMailHeaders(67890); - var_dump($mailHeaders); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; + + $sandboxMessages = (new MailtrapSandboxClient($config)) + ->messages($accountId, $inboxId); + + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; + $mailHeaders = $sandboxMessages->getMailHeaders($messageId); + + var_dump(ResponseHelper::toArray($mailHeaders)); - lang: python label: Python source: | @@ -4532,10 +4604,20 @@ paths: source: | attachments(12345, 67890); - $response = $sandboxAttachments->getMessageAttachments(111111); + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; + + $sandboxAttachments = (new MailtrapSandboxClient($config)) + ->attachments($accountId, $inboxId); + + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; + $response = $sandboxAttachments->getMessageAttachments($messageId); + + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: | @@ -4642,10 +4724,22 @@ paths: source: | attachments(12345, 67890); - $response = $sandboxAttachments->getMessageAttachment(111111, 222222); + + $config = new Config($_ENV['MAILTRAP_API_KEY']); + $accountId = $_ENV['MAILTRAP_ACCOUNT_ID']; + $inboxId = $_ENV['MAILTRAP_INBOX_ID']; + + $sandboxAttachments = (new MailtrapSandboxClient($config)) + ->attachments($accountId, $inboxId); + + $messageId = $_ENV['MAILTRAP_MESSAGE_ID']; + $attachmentId = $_ENV['MAILTRAP_MESSAGE_ATTACHMENT_ID']; + + $response = $sandboxAttachments->getMessageAttachment($messageId, $attachmentId); + + var_dump(ResponseHelper::toArray($response)); - lang: python label: Python source: |