From a163c98994e303253b61a03b96b37a5ec048ea44 Mon Sep 17 00:00:00 2001 From: yehuda Date: Thu, 16 May 2019 17:31:26 +0300 Subject: add sendgrid-php-client --- Postman/Postman-Mail/sendgrid/.gitignore | 8 +- .../php-http-client/.github/PULL_REQUEST_TEMPLATE | 24 + .../vendor/sendgrid/php-http-client/Dockerfile | 13 + .../sendgrid/.github/PULL_REQUEST_TEMPLATE | 26 + .../vendor/sendgrid/sendgrid/docker/Dockerfile | 22 + .../sendgrid/sendgrid/lib/contacts/Recipient.php | 92 + .../sendgrid/lib/contacts/RecipientForm.php | 55 + .../vendor/sendgrid/sendgrid/lib/mail/Asm.php | 150 ++ .../sendgrid/sendgrid/lib/mail/Attachment.php | 235 +++ .../vendor/sendgrid/sendgrid/lib/mail/BatchId.php | 75 + .../vendor/sendgrid/sendgrid/lib/mail/Bcc.php | 24 + .../sendgrid/sendgrid/lib/mail/BccSettings.php | 118 ++ .../sendgrid/lib/mail/BypassListManagement.php | 87 + .../vendor/sendgrid/sendgrid/lib/mail/Category.php | 77 + .../vendor/sendgrid/sendgrid/lib/mail/Cc.php | 24 + .../sendgrid/sendgrid/lib/mail/ClickTracking.php | 114 ++ .../vendor/sendgrid/sendgrid/lib/mail/Content.php | 118 ++ .../sendgrid/sendgrid/lib/mail/CustomArg.php | 119 ++ .../sendgrid/sendgrid/lib/mail/EmailAddress.php | 222 +++ .../vendor/sendgrid/sendgrid/lib/mail/Footer.php | 144 ++ .../vendor/sendgrid/sendgrid/lib/mail/From.php | 24 + .../sendgrid/sendgrid/lib/mail/Ganalytics.php | 251 +++ .../vendor/sendgrid/sendgrid/lib/mail/GroupId.php | 73 + .../sendgrid/sendgrid/lib/mail/GroupsToDisplay.php | 87 + .../vendor/sendgrid/sendgrid/lib/mail/Header.php | 116 ++ .../sendgrid/sendgrid/lib/mail/HtmlContent.php | 33 + .../sendgrid/sendgrid/lib/mail/IpPoolName.php | 77 + .../vendor/sendgrid/sendgrid/lib/mail/Mail.php | 1911 ++++++++++++++++++++ .../sendgrid/sendgrid/lib/mail/MailSettings.php | 274 +++ .../vendor/sendgrid/sendgrid/lib/mail/MimeType.php | 26 + .../sendgrid/sendgrid/lib/mail/OpenTracking.php | 124 ++ .../sendgrid/sendgrid/lib/mail/Personalization.php | 312 ++++ .../sendgrid/lib/mail/PlainTextContent.php | 33 + .../vendor/sendgrid/sendgrid/lib/mail/ReplyTo.php | 24 + .../sendgrid/sendgrid/lib/mail/SandBoxMode.php | 80 + .../vendor/sendgrid/sendgrid/lib/mail/Section.php | 115 ++ .../vendor/sendgrid/sendgrid/lib/mail/SendAt.php | 102 ++ .../sendgrid/sendgrid/lib/mail/SpamCheck.php | 161 ++ .../vendor/sendgrid/sendgrid/lib/mail/Subject.php | 74 + .../sendgrid/lib/mail/SubscriptionTracking.php | 228 +++ .../sendgrid/sendgrid/lib/mail/Substitution.php | 120 ++ .../sendgrid/sendgrid/lib/mail/TemplateId.php | 86 + .../vendor/sendgrid/sendgrid/lib/mail/To.php | 24 + .../sendgrid/lib/mail/TrackingSettings.php | 252 +++ .../sendgrid/sendgrid/lib/mail/TypeException.php | 7 + .../vendor/sendgrid/sendgrid/lib/stats/Stats.php | 269 +++ .../sendgrid/vendor/sendgrid/sendgrid/phpcs.xml | 196 ++ 47 files changed, 6822 insertions(+), 4 deletions(-) create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.github/PULL_REQUEST_TEMPLATE create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/Dockerfile create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.github/PULL_REQUEST_TEMPLATE create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/docker/Dockerfile create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/Recipient.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/RecipientForm.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Asm.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Attachment.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BatchId.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Bcc.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BccSettings.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BypassListManagement.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Category.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Cc.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/ClickTracking.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Content.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/CustomArg.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/EmailAddress.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Footer.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/From.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Ganalytics.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/GroupId.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/GroupsToDisplay.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Header.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/HtmlContent.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/IpPoolName.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Mail.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/MailSettings.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/MimeType.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/OpenTracking.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Personalization.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/PlainTextContent.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/ReplyTo.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SandBoxMode.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Section.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SendAt.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SpamCheck.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Subject.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SubscriptionTracking.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Substitution.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TemplateId.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/To.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TrackingSettings.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TypeException.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/stats/Stats.php create mode 100644 Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/phpcs.xml diff --git a/Postman/Postman-Mail/sendgrid/.gitignore b/Postman/Postman-Mail/sendgrid/.gitignore index 6df0272..4903138 100644 --- a/Postman/Postman-Mail/sendgrid/.gitignore +++ b/Postman/Postman-Mail/sendgrid/.gitignore @@ -1,7 +1,7 @@ test/coverage/* examples/* -dist/ -composer.lock -vendor +vendor/**/test/* +vendor/**/*.md +vendor/**/*.sh +vendor/**/*.yml .env* -sendgrid-php.php diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.github/PULL_REQUEST_TEMPLATE b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.github/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000..7ad590b --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.github/PULL_REQUEST_TEMPLATE @@ -0,0 +1,24 @@ + +# Fixes # + +### Checklist +- [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) +- [ ] I have read the [Contribution Guide] and my PR follows them. +- [ ] I updated my branch with the master branch. +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] I have added necessary documentation about the functionality in the appropriate .md file +- [ ] I have added in line documentation to the code I modified + +### Short description of what this PR does: +- +- + +If you have questions, please send an email to [Sendgrid](mailto:dx@sendgrid.com), or file a Github Issue in this repository. diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/Dockerfile b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/Dockerfile new file mode 100644 index 0000000..da1ef10 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/Dockerfile @@ -0,0 +1,13 @@ +FROM php:7.1-apache + +ARG sendgrid_apikey +ENV SENDGRID_API_KEY=$sendgrid_apikey + +COPY . /var/www/client +WORKDIR /var/www/client + +RUN apt-get update && \ + apt-get install -y git zip zlib1g-dev && docker-php-ext-install zip +RUN curl --silent --show-error https://getcomposer.org/installer | php + +RUN php composer.phar install diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.github/PULL_REQUEST_TEMPLATE b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.github/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000..d1e0450 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.github/PULL_REQUEST_TEMPLATE @@ -0,0 +1,26 @@ + +# Fixes # + +### Checklist +- [ ] I acknowledge that all my contributions will be made under the project's license +- [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) +- [ ] I have read the [Contribution Guide] and my PR follows them. +- [ ] I updated my branch with the development branch. +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] I have added necessary documentation about the functionality in the appropriate .md file +- [ ] I have added in line documentation to the code I modified + +### Short description of what this PR does: +- +- + +If you have questions, please send an email to [Twilio Sendgrid](mailto:dx@sendgrid.com), or file a Github Issue in this repository. diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/docker/Dockerfile b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/docker/Dockerfile new file mode 100644 index 0000000..125579e --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/docker/Dockerfile @@ -0,0 +1,22 @@ +FROM php:7.1-cli + +ENV OAI_SPEC_URL="https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json" +ENV SENDGRID_API_KEY $SENDGRID_API_KEY + +# install Prism +WORKDIR /root + +# install Prism +ADD https://raw.githubusercontent.com/stoplightio/prism/master/install.sh install.sh +RUN chmod +x ./install.sh && sync && \ + ./install.sh && \ + rm ./install.sh + +# set up default Twilio SendGrid env +WORKDIR /root + +RUN mkdir sendgrid-php +COPY entrypoint.sh entrypoint.sh +RUN chmod +x entrypoint.sh +ENTRYPOINT ["./entrypoint.sh"] +CMD ["--mock"] diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/Recipient.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/Recipient.php new file mode 100644 index 0000000..7eb00be --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/Recipient.php @@ -0,0 +1,92 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Contacts; +/** + * This class is used to construct a recipient for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Recipient implements \JsonSerializable +{ + /** @var $firstName string First name of the email recipient */ + private $firstName; + /** @var $lastName string Last name of the email recipient */ + private $lastName; + /** @var $email string Email address of the recipient */ + private $email; + + /** + * Create a recipient for the /mail/send API call + * + * @param string $firstName First name of the email recipient + * @param string $lastName Last name of the email recipient + * @param string $email Email address of the recipient + */ + public function __construct($firstName, $lastName, $email) + { + $this->firstName = $firstName; + $this->lastName = $lastName; + $this->email = $email; + } + + /** + * Retrieve the first name of the recipient + * + * @return string + */ + public function getFirstName() + { + return $this->firstName; + } + + /** + * Retrieve the last name of the recipient + * + * @return string + */ + public function getLastName() + { + return $this->lastName; + } + + /** + * Retrieve the email address of the recipient + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * Return an array representing a recipient object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'email' => $this->getEmail(), + 'first_name' => $this->getFirstName(), + 'last_name' => $this->getLastName() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/RecipientForm.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/RecipientForm.php new file mode 100644 index 0000000..18bbc53 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/RecipientForm.php @@ -0,0 +1,55 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Contacts; + +/** + * This class is used to build a html form and provides a submission + * endpoint for the form that makes a /contactdb/recipients API call. + * + * @package SendGrid\Contacts + */ +class RecipientForm +{ + /** @var $html string HTML content for the form */ + private $html; + + /** + * Form constructor + * + * @param string $url The url the form should submit to + */ + public function __construct($url) + { + $html = '
+ First Name:
+ Last Name:
+ E-mail:
+ +
'; + $this->html = $html; + } + + /** + * Return the HTML form + * + * @return string + */ + public function __toString() + { + return $this->html; + } + +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Asm.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Asm.php new file mode 100644 index 0000000..c5f3643 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Asm.php @@ -0,0 +1,150 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Asm object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Asm implements \JsonSerializable +{ + /** @var $group_id int The unsubscribe group to associate with this email */ + private $group_id; + /** + * @var $groups_to_display int[] An array containing the unsubscribe groups that you + * would like to be displayed on the unsubscribe preferences page. + */ + private $groups_to_display; + + /** + * Optional constructor + * + * @param int|GroupId|null $group_id A GroupId object or the + * unsubscribe group to + * associate with this email + * @param int[]|GroupsToDisplay|null $groups_to_display A GroupsToDisplay + * object or an array + * containing the + * unsubscribe groups + * that you would like + * to be displayed + * on the unsubscribe + * preferences page. + */ + public function __construct( + $group_id = null, + $groups_to_display = null + ) { + if (isset($group_id)) { + $this->setGroupId($group_id); + } + if (isset($groups_to_display)) { + $this->setGroupsToDisplay($groups_to_display); + } + } + + /** + * Add the group id to a Asm object + * + * @param int|GroupId $group_id The unsubscribe group to associate with this + * email + * + * @throws TypeException + */ + public function setGroupId($group_id) + { + if ($group_id instanceof GroupId) { + $this->group_id = $group_id->getGroupId(); + } else { + if (!is_int($group_id)) { + throw new TypeException( + '$group_id must be an instance of Twilio SendGrid\Mail\GroupId or of type int.' + ); + } + $this->group_id = new GroupId($group_id); + } + return; + } + + /** + * Retrieve the GroupId object from a Asm object + * + * The unsubscribe group to associate with this email + * + * @return int + */ + public function getGroupId() + { + return $this->group_id; + } + + /** + * Add the groups to display id(s) to a Asm object + * + * @param int[]|GroupsToDisplay $groups_to_display A GroupsToDisplay + * object or an array + * containing the + * unsubscribe groups + * that you would like + * to be displayed + * on the unsubscribe + * preferences page. + * + * @throws TypeException + */ + public function setGroupsToDisplay($groups_to_display) + { + if ($groups_to_display instanceof GroupsToDisplay) { + $this->groups_to_display = $groups_to_display->getGroupsToDisplay(); + } else { + if (!is_array($groups_to_display)) { + throw new TypeException( + '$groups_to_display must be an instance of Twilio SendGrid\Mail\GroupsToDisplay or of type array.' + ); + } + $this->groups_to_display = new GroupsToDisplay($groups_to_display); + } + return; + } + + /** + * Retrieve the groups to display id(s) from a Asm object + * + * @return int[] + */ + public function getGroupsToDisplay() + { + return $this->groups_to_display; + } + + /** + * Return an array representing a Asm object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'group_id' => $this->getGroupId(), + 'groups_to_display' => $this->getGroupsToDisplay() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Attachment.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Attachment.php new file mode 100644 index 0000000..632781c --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Attachment.php @@ -0,0 +1,235 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Attachment object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Attachment implements \JsonSerializable +{ + /** @var $content string Base64 encoded content */ + private $content; + /** @var $type string Mime type of the attachment */ + private $type; + /** @var $filename string File name of the attachment */ + private $filename; + /** @var $disposition string How the attachment should be displayed: inline or attachment, default is attachment */ + private $disposition; + /** @var $content_id string Used when disposition is inline to diplay the file within the body of the email */ + private $content_id; + + /** + * Optional constructor + * + * @param string $content Base64 encoded content + * @param string $type Mime type of the attachment + * @param string $filename File name of the attachment + * @param string $disposition How the attachment should be displayed: inline + * or attachment, default is attachment + * @param string $content_id Used when disposition is inline to diplay the + * file within the body of the email + */ + public function __construct( + $content = null, + $type = null, + $filename = null, + $disposition = null, + $content_id = null + ) { + if (isset($content)) { + $this->setContent($content); + } + if (isset($type)) { + $this->setType($type); + } + if (isset($filename)) { + $this->setFilename($filename); + } + if (isset($disposition)) { + $this->setDisposition($disposition); + } + if (isset($content_id)) { + $this->setContentID($content_id); + } + } + + /** + * Add the content to a Attachment object + * + * @param string $content Base64 encoded content + * + * @throws TypeException + */ + public function setContent($content) + { + if (!is_string($content)) { + throw new TypeException('$content must be of type string.'); + } + if (!$this->isBase64($content)) { + $this->content = base64_encode($content); + } else { + $this->content = $content; + } + } + + /** + * Retrieve the content from a Attachment object + * + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * Add the mime type to a Attachment object + * + * @param string $type Mime type of the attachment + * + * @throws TypeException + */ + public function setType($type) + { + if (!is_string($type)) { + throw new TypeException('$type must be of type string.'); + } + $this->type = $type; + } + + /** + * Retrieve the mime type from a Attachment object + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Add the file name to a Attachment object + * + * @param string $filename File name of the attachment + * + * @throws TypeException + */ + public function setFilename($filename) + { + if (!is_string($filename)) { + throw new TypeException('$filename must be of type string'); + } + $this->filename = $filename; + } + + /** + * Retrieve the file name from a Attachment object + * + * @return string + */ + public function getFilename() + { + return $this->filename; + } + + /** + * Add the disposition to a Attachment object + * + * @param string $disposition How the attachment should be displayed: + * inline or attachment, default is attachment + * + * @throws TypeException + */ + public function setDisposition($disposition) + { + if (!is_string($disposition)) { + throw new TypeException('$disposition must be of type string.'); + } + $this->disposition = $disposition; + } + + /** + * Retrieve the disposition from a Attachment object + * + * @return string + */ + public function getDisposition() + { + return $this->disposition; + } + + /** + * Add the content id to a Attachment object + * + * @param string $content_id Used when disposition is inline to diplay + * the file within the body of the email + */ + public function setContentID($content_id) + { + if (!is_string($content_id)) { + throw new TypeException('$content_id must be of type string.'); + } + $this->content_id = $content_id; + } + + /** + * Retrieve the content id from a Attachment object + * + * @return string + */ + public function getContentID() + { + return $this->content_id; + } + + /** + * Verifies whether or not the provided string is a valid base64 string + * + * @param $string string The string that has to be checked + * @return bool + */ + private function isBase64($string) + { + $decoded_data = base64_decode($string, true); + $encoded_data = base64_encode($decoded_data); + if ($encoded_data != $string) { + return false; + } + return true; + } + + /** + * Return an array representing a Attachment object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'content' => $this->getContent(), + 'type' => $this->getType(), + 'filename' => $this->getFilename(), + 'disposition' => $this->getDisposition(), + 'content_id' => $this->getContentID() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BatchId.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BatchId.php new file mode 100644 index 0000000..508e60c --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BatchId.php @@ -0,0 +1,75 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a BatchId object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class BatchId implements \JsonSerializable +{ + /** @var $batch_id string This ID represents a batch of emails to be sent at the same time */ + private $batch_id; + + /** + * Optional constructor + * + * @param string|null $batch_id This ID represents a batch of emails to + * be sent at the same time + */ + public function __construct($batch_id = null) + { + if (isset($batch_id)) { + $this->setBatchId($batch_id); + } + } + + /** + * Add the batch id to a BatchId object + * + * @param string $batch_id This ID represents a batch of emails to be sent + * at the same time + * + * @throws TypeException + */ + public function setBatchId($batch_id) + { + if (!is_string($batch_id)) { + throw new TypeException('$batch_id must be of type string.'); + } + $this->batch_id = $batch_id; + } + + /** + * Return the batch id from a BatchId object + * + * @return string + */ + public function getBatchId() + { + return $this->batch_id; + } + + /** + * Return an array representing a BatchId object for the Twilio SendGrid API + * + * @return null|string + */ + public function jsonSerialize() + { + return $this->getBatchId(); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Bcc.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Bcc.php new file mode 100644 index 0000000..88a588c --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Bcc.php @@ -0,0 +1,24 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Bcc object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Bcc extends EmailAddress implements \JsonSerializable +{ +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BccSettings.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BccSettings.php new file mode 100644 index 0000000..1841f01 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BccSettings.php @@ -0,0 +1,118 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a BccSettings object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class BccSettings implements \JsonSerializable +{ + /** @var $enable bool Indicates if this setting is enabled */ + private $enable; + /** @var $email string The email address that you would like to receive the BCC */ + private $email; + + /** + * Optional constructor + * + * @param bool|null $enable Indicates if this setting is enabled + * @param string|null $email The email address that you would like + * to receive the BCC + */ + public function __construct($enable = null, $email = null) + { + if (isset($enable)) { + $this->setEnable($enable); + } + if (isset($email)) { + $this->setEmail($email); + } + } + + /** + * Update the enable setting on a BccSettings object + * + * @param bool $enable Indicates if this setting is enabled + * + * @throws TypeException + */ + public function setEnable($enable) + { + if (!is_bool($enable)) { + throw new TypeException('$enable must be of type bool.'); + } + $this->enable = $enable; + } + + /** + * Retrieve the enable setting on a BccSettings object + * + * @return bool + */ + public function getEnable() + { + return $this->enable; + } + + /** + * Add the email setting on a BccSettings object + * + * @param string $email The email address that you would like + * to receive the BCC + * + * @throws TypeException + */ + public function setEmail($email) + { + if (!is_string($email) && + filter_var($email, FILTER_VALIDATE_EMAIL) + ) { + throw new TypeException( + '$email must valid and be of type string.' + ); + } + $this->email = $email; + } + + /** + * Retrieve the email setting on a BccSettings object + * + * @return string + */ + public function getEmail() + { + return $this->email; + } + + /** + * Return an array representing a BccSettings object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'enable' => $this->getEnable(), + 'email' => $this->getEmail() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BypassListManagement.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BypassListManagement.php new file mode 100644 index 0000000..9b6762d --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/BypassListManagement.php @@ -0,0 +1,87 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a BypassListManagement object for + * the /mail/send API call + * + * Allows you to bypass all unsubscribe groups and suppressions to + * ensure that the email is delivered to every single recipient. This + * should only be used in emergencies when it is absolutely necessary + * that every recipient receives your email + * + * @package SendGrid\Mail + */ +class BypassListManagement implements \JsonSerializable +{ + /** @var $enable bool Indicates if this setting is enabled */ + private $enable; + + /** + * Optional constructor + * + * @param bool|null $enable Indicates if this setting is enabled + */ + public function __construct($enable = null) + { + if (isset($enable)) { + $this->setEnable($enable); + } + } + + /** + * Update the enable setting on a BypassListManagement object + * + * @param bool $enable Indicates if this setting is enabled + * + * @throws TypeException + */ + public function setEnable($enable) + { + if (!is_bool($enable)) { + throw new TypeException('$enable must be of type bool.'); + } + $this->enable = $enable; + } + + /** + * Retrieve the enable setting on a BypassListManagement object + * + * @return bool + */ + public function getEnable() + { + return $this->enable; + } + + /** + * Return an array representing a BypassListManagement object for + * the SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'enable' => $this->getEnable() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Category.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Category.php new file mode 100644 index 0000000..ce94ddc --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Category.php @@ -0,0 +1,77 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Category object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Category implements \JsonSerializable +{ + /** @var $category string A category name for an email message. Each category name may not exceed 255 characters */ + private $category; + + /** + * Optional constructor + * + * @param string|null $category A category name for an email message. + * Each category name may not exceed 255 + * characters + */ + public function __construct($category = null) + { + if (isset($category)) { + $this->setCategory($category); + } + } + + /** + * Add a category to a Category object + * + * @param string $category A category name for an email message. + * Each category name may not exceed 255 + * characters + * + * @throws TypeException + */ + public function setCategory($category) + { + if (!is_string($category)) { + throw new TypeException('$category must be of type string.'); + } + $this->category = $category; + } + + /** + * Retrieve a category from a Category object + * + * @return string + */ + public function getCategory() + { + return $this->category; + } + + /** + * Return an array representing a Category object for the Twilio SendGrid API + * + * @return string + */ + public function jsonSerialize() + { + return $this->getCategory(); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Cc.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Cc.php new file mode 100644 index 0000000..70485ee --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Cc.php @@ -0,0 +1,24 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Cc object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Cc extends EmailAddress implements \JsonSerializable +{ +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/ClickTracking.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/ClickTracking.php new file mode 100644 index 0000000..abce412 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/ClickTracking.php @@ -0,0 +1,114 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a ClickTracking object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class ClickTracking implements \JsonSerializable +{ + /** @var $enable bool Indicates if this setting is enabled */ + private $enable; + /* @var $enable_text bool Indicates if this setting should be included in the text/plain portion of your email */ + private $enable_text; + + /** + * Optional constructor + * + * @param bool|null $enable Indicates if this setting is enabled + * @param bool|null $enable_text Indicates if this setting should be + * included in the text/plain portion of + * your email + */ + public function __construct($enable = null, $enable_text = null) + { + if (isset($enable)) { + $this->setEnable($enable); + } + if (isset($enable_text)) { + $this->setEnableText($enable_text); + } + } + + /** + * Update the enable setting on a ClickTracking object + * + * @param bool $enable Indicates if this setting is enabled + * + * @throws TypeException + */ + public function setEnable($enable) + { + if (!is_bool($enable)) { + throw new TypeException('$enable must be of type bool.'); + } + $this->enable = $enable; + } + + /** + * Retrieve the enable setting on a ClickTracking object + * + * @return bool + */ + public function getEnable() + { + return $this->enable; + } + + /** + * Update the enable text setting on a ClickTracking object + * + * @param bool $enable_text Indicates if this setting is enabled + * + * @throws TypeException + */ + public function setEnableText($enable_text) + { + if (!is_bool($enable_text)) { + throw new TypeException('$enable_text must be of type bool'); + } + $this->enable_text = $enable_text; + } + + /** + * Retrieve the enable_text setting on a ClickTracking object + * + * @return bool + */ + public function getEnableText() + { + return $this->enable_text; + } + + /** + * Return an array representing a ClickTracking object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'enable' => $this->getEnable(), + 'enable_text' => $this->getEnableText() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Content.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Content.php new file mode 100644 index 0000000..62417d5 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Content.php @@ -0,0 +1,118 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Content object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Content implements \JsonSerializable +{ + /** @var $type string The mime type of the content you are including in your email. For example, “text/plain” or “text/html” */ + private $type; + /** @var $value string The actual content of the specified mime type that you are including in your email */ + private $value; + + /** + * Optional constructor + * + * @param string|null $type The mime type of the content you are including + * in your email. For example, “text/plain” or + * “text/html” + * @param string|null $value The actual content of the specified mime type + * that you are including in your email + */ + public function __construct($type = null, $value = null) + { + if (isset($type)) { + $this->setType($type); + } + if (isset($value)) { + $this->setValue($value); + } + } + + /** + * Add the mime type on a Content object + * + * @param string $type The mime type of the content you are including + * in your email. For example, “text/plain” or + * “text/html” + * + * @throws TypeException + */ + public function setType($type) + { + if (!is_string($type)) { + throw new TypeException('$type must be of type string.'); + } + $this->type = $type; + } + + /** + * Retrieve the mime type on a Content object + * + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Add the content value to a Content object + * + * @param string $value The actual content of the specified mime type + * that you are including in your email + * + * @throws TypeException + */ + public function setValue($value) + { + if (!is_string($value)) { + throw new TypeException('$value must be of type string'); + } + $this->value = mb_convert_encoding($value, 'UTF-8', 'UTF-8'); + } + + /** + * Retrieve the content value to a Content object + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Return an array representing a Contact object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'type' => $this->getType(), + 'value' => $this->getValue() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/CustomArg.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/CustomArg.php new file mode 100644 index 0000000..031f035 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/CustomArg.php @@ -0,0 +1,119 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a CustomArg object for the /mail/send API call + * + * Values that are specific to the entire send that will be carried along with the + * email and its activity data. Substitutions will not be made on custom arguments, + * so any string that is entered into this parameter will be assumed to be the + * custom argument that you would like to be used. This parameter is overridden by + * personalizations[x].custom_args if that parameter has been defined. Total custom + * args size may not exceed 10,000 bytes. + * + * @package SendGrid\Mail + */ +class CustomArg implements \JsonSerializable +{ + /** @var $key string Custom arg key */ + private $key; + /** @var $value string Custom arg value */ + private $value; + + /** + * Optional constructor + * + * @param string|null $key Custom arg key + * @param string|null $value Custom arg value + */ + public function __construct($key = null, $value = null) + { + if (isset($key)) { + $this->setKey($key); + } + if (isset($value)) { + $this->setValue($value); + } + } + + /** + * Add a custom arg key on a CustomArg object + * + * @param string $key Custom arg key + * + * @throws TypeException + */ + public function setKey($key) + { + if (!is_string($key)) { + throw new TypeException('$key must be of type string'); + } + $this->key = (string) $key; + } + + /** + * Retrieve a custom arg key on a CustomArg object + * + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Add a custom arg value on a CustomArg object + * + * @param string $value Custom arg value + * + * @throws TypeException + */ + public function setValue($value) + { + if (!is_string($value)) { + throw new TypeException('$value must be of type string.'); + } + $this->value = (string) $value; + } + + /** + * Retrieve a custom arg key on a CustomArg object + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Return an array representing a CustomArg object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'key' => $this->getKey(), + 'value' => $this->getValue() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/EmailAddress.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/EmailAddress.php new file mode 100644 index 0000000..fff2347 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/EmailAddress.php @@ -0,0 +1,222 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a EmailAddress object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class EmailAddress implements \JsonSerializable +{ + /** @var $name string The name of the person associated with the email */ + private $name; + /** @var $email string The email address */ + private $email; + /** @var $substitutions Substitution[] An array of key/value substitutions to be be applied to the text and html content of the email body */ + private $substitutions; + /** @var $subject Subject The personalized subject of the email */ + private $subject; + + /** + * Optional constructor + * + * @param string|null $emailAddress The email address + * @param string|null $name The name of the person associated with + * the email + * @param array|null $substitutions An array of key/value substitutions to + * be be applied to the text and html content + * of the email body + * @param string|null $subject The personalized subject of the email + */ + public function __construct( + $emailAddress = null, + $name = null, + $substitutions = null, + $subject = null + ) { + if (isset($emailAddress)) { + $this->setEmailAddress($emailAddress); + } + if (isset($name) && $name !== null) { + $this->setName($name); + } + if (isset($substitutions)) { + $this->setSubstitutions($substitutions); + } + if (isset($subject)) { + $this->setSubject($subject); + } + } + + /** + * Add the email address to a EmailAddress object + * + * @param string $emailAddress The email address + * + * @throws TypeException + */ + public function setEmailAddress($emailAddress) + { + if (!(is_string($emailAddress) && + filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) + ) { + throw new TypeException( + "$emailAddress must be valid and of type string." + ); + } + $this->email = $emailAddress; + } + + /** + * Retrieve the email address from a EmailAddress object + * + * @return string + */ + public function getEmailAddress() + { + return $this->email; + } + + /** + * Retrieve the email address from a EmailAddress object + * + * @return string + */ + public function getEmail() + { + return $this->getEmailAddress(); + } + + /** + * Add a name to a EmailAddress object + * + * @param string $name The name of the person associated with the email + * + * @throws TypeException + */ + public function setName($name) + { + if (!is_string($name)) { + throw new TypeException('$name must be of type string.'); + } + + /* + Issue #368 + ========== + If the name is not wrapped in double quotes and contains a comma or + semicolon, the API fails to parse it correctly. + When wrapped in double quotes, commas, semicolons and unescaped single + quotes are supported. + Escaped double quotes are supported as well but will appear unescaped in + the mail (e.g. "O\'Keefe"). + Double quotes will be shown in some email clients, so the name should + only be wrapped when necessary. + */ + // Only wrapp in double quote if comma or semicolon are found + if (false !== strpos($name, ',') || false !== strpos($name, ';')) { + // Unescape quotes + $name = stripslashes(html_entity_decode($name, ENT_QUOTES)); + // Escape only double quotes + $name = str_replace('"', '\\"', $name); + // Wrapp in double quotes + $name = '"' . $name . '"'; + } + $this->name = (!empty($name)) ? $name : null; + } + + /** + * Retrieve the name from a EmailAddress object + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Add substitutions to a EmailAddress object + * + * @param array $substitutions An array of key/value substitutions to + * be be applied to the text and html content + * of the email body + * + * @throws TypeException + */ + public function setSubstitutions($substitutions) + { + if (!is_array($substitutions)) { + throw new TypeException('$substitutions must be an array.'); + } + + $this->substitutions = $substitutions; + } + + /** + * Retrieve substitutions from a EmailAddress object + */ + public function getSubstitutions() + { + return $this->substitutions; + } + + /** + * Add a subject to a EmailAddress object + * + * @param string $subject The personalized subject of the email + * + * @throws TypeException + */ + public function setSubject($subject) + { + if (!is_string($subject)) { + throw new TypeException('$subject must be of type string.'); + } + if (!($subject instanceof Subject)) { + $this->subject = new Subject($subject); + } else { + $this->subject = $subject; + } + } + + /** + * Retrieve a subject from a EmailAddress object + * + * @return Subject + */ + public function getSubject() + { + return $this->subject; + } + + /** + * Return an array representing a EmailAddress object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'name' => $this->getName(), + 'email' => $this->getEmail() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Footer.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Footer.php new file mode 100644 index 0000000..92d2f4b --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Footer.php @@ -0,0 +1,144 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Footer object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Footer implements \JsonSerializable +{ + /** @var $enable bool Indicates if this setting is enabled */ + private $enable; + /** @var $text string The plain text content of your footer */ + private $text; + /** @var $html string The HTML content of your footer */ + private $html; + + /** + * Optional constructor + * + * @param bool|null $enable Indicates if this setting is enabled + * @param string|null $text The plain text content of your footer + * @param string|null $html The HTML content of your footer + */ + public function __construct($enable = null, $text = null, $html = null) + { + if (isset($enable)) { + $this->setEnable($enable); + } + if (isset($text)) { + $this->setText($text); + } + if (isset($html)) { + $this->setHtml($html); + } + } + + /** + * Update the enable setting on a Footer object + * + * @param bool $enable Indicates if this setting is enabled + * + * @throws TypeException + */ + public function setEnable($enable) + { + if (!is_bool($enable)) { + throw new TypeException('$enable must be of type bool'); + } + $this->enable = $enable; + } + + /** + * Retrieve the enable setting on a Footer object + * + * @return bool + */ + public function getEnable() + { + return $this->enable; + } + + /** + * Add text to a Footer object + * + * @param string $text The plain text content of your footer + * + * @throws TypeException + */ + public function setText($text) + { + if (!is_string($text)) { + throw new TypeException('$text must be of type string.'); + } + $this->text = $text; + } + + /** + * Retrieve text to a Footer object + * + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Add html to a Footer object + * + * @param string $html The HTML content of your footer + * + * @throws TypeException + */ + public function setHtml($html) + { + if (!is_string($html)) { + throw new TypeException('$html must be of type string.'); + } + $this->html = $html; + } + + /** + * Retrieve html from a Footer object + * + * @return string + */ + public function getHtml() + { + return $this->html; + } + + /** + * Return an array representing a Footer object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'enable' => $this->getEnable(), + 'text' => $this->getText(), + 'html' => $this->getHtml() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/From.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/From.php new file mode 100644 index 0000000..602000a --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/From.php @@ -0,0 +1,24 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a From object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class From extends EmailAddress implements \JsonSerializable +{ +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Ganalytics.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Ganalytics.php new file mode 100644 index 0000000..2d51188 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Ganalytics.php @@ -0,0 +1,251 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Ganalytics object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Ganalytics implements \JsonSerializable +{ + /** @var $enable bool Indicates if this setting is enabled */ + private $enable; + /** @var $utm_source string Name of the referrer source. (e.g. Google, SomeDomain.com, or Marketing Email) */ + private $utm_source; + /** @var $utm_medium string Name of the marketing medium. (e.g. Email) */ + private $utm_medium; + /** @var $utm_term string Used to identify any paid keywords */ + private $utm_term; + /** @var $utm_content string Used to differentiate your campaign from advertisements */ + private $utm_content; + /** @var $utm_campaign string The name of the campaign */ + private $utm_campaign; + + /** + * Optional constructor + * + * @param bool|null $enable Indicates if this setting is enabled + * @param string|null $utm_source Name of the referrer source. (e.g. + * Google, SomeDomain.com, or Marketing Email) + * @param string|null $utm_medium Name of the marketing medium. (e.g. Email) + * @param string|null $utm_term Used to identify any paid keywords + * @param string|null $utm_content Used to differentiate your campaign from + * advertisements + * @param string|null $utm_campaign The name of the campaign + */ + public function __construct( + $enable = null, + $utm_source = null, + $utm_medium = null, + $utm_term = null, + $utm_content = null, + $utm_campaign = null + ) + { + if (isset($enable)) { + $this->setEnable($enable); + } + if (isset($utm_source)) { + $this->setCampaignSource($utm_source); + } + if (isset($utm_medium)) { + $this->setCampaignMedium($utm_medium); + } + if (isset($utm_term)) { + $this->setCampaignTerm($utm_term); + } + if (isset($utm_content)) { + $this->setCampaignContent($utm_content); + } + if (isset($utm_campaign)) { + $this->setCampaignName($utm_campaign); + } + } + + /** + * Update the enable setting on a Ganalytics object + * + * @param bool $enable Indicates if this setting is enabled + * + * @throws TypeException + */ + public function setEnable($enable) + { + if (!is_bool($enable)) { + throw new TypeException('$enable must be of type bool.'); + } + $this->enable = $enable; + } + + /** + * Retrieve the enable setting on a Ganalytics object + * + * @return bool + */ + public function getEnable() + { + return $this->enable; + } + + /** + * Add the campaign source to a Ganalytics object + * + * @param string $utm_source Name of the referrer source. (e.g. + * Google, SomeDomain.com, or Marketing Email) + * + * @throws TypeException + */ + public function setCampaignSource($utm_source) + { + if (!is_string($utm_source)) { + throw new TypeException('$utm_source must be of type string.'); + } + $this->utm_source = $utm_source; + } + + /** + * Return the campaign source from a Ganalytics object + * + * @return string + */ + public function getCampaignSource() + { + return $this->utm_source; + } + + /** + * Add the campaign medium to a Ganalytics object + * + * @param string $utm_medium Name of the marketing medium. (e.g. Email) + * + * @throws TypeException + */ + public function setCampaignMedium($utm_medium) + { + if (!is_string($utm_medium)) { + throw new TypeException('$utm_medium must be of type string.'); + } + $this->utm_medium = $utm_medium; + } + + /** + * Return the campaign medium from a Ganalytics object + * + * @return string + */ + public function getCampaignMedium() + { + return $this->utm_medium; + } + + /** + * Add the campaign term to a Ganalytics object + * + * @param string $utm_term Used to identify any paid keywords + * + * @throws TypeException + */ + public function setCampaignTerm($utm_term) + { + if (!is_string($utm_term)) { + throw new TypeException('$utm_term must be of type string'); + } + $this->utm_term = $utm_term; + } + + /** + * Return the campaign term from a Ganalytics object + * + * @return string + */ + public function getCampaignTerm() + { + return $this->utm_term; + } + + /** + * Add the campaign content to a Ganalytics object + * + * @param string $utm_content Used to differentiate your campaign from + * advertisements + * + * @throws TypeException + */ + public function setCampaignContent($utm_content) + { + if (!is_string($utm_content)) { + throw new TypeException('$utm_content must be of type string.'); + } + $this->utm_content = $utm_content; + } + + /** + * Return the campaign content from a Ganalytics object + * + * @return string + */ + public function getCampaignContent() + { + return $this->utm_content; + } + + /** + * Add the campaign name to a Ganalytics object + * + * @param string $utm_campaign The name of the campaign + * + * @throws TypeException + */ + public function setCampaignName($utm_campaign) + { + if (!is_string($utm_campaign)) { + throw new TypeException('$utm_campaign must be of type string.'); + } + $this->utm_campaign = $utm_campaign; + } + + /** + * Return the campaign name from a Ganalytics object + * + * @return string + */ + public function getCampaignName() + { + return $this->utm_campaign; + } + + /** + * Return an array representing a Ganalytics object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'enable' => $this->getEnable(), + 'utm_source' => $this->getCampaignSource(), + 'utm_medium' => $this->getCampaignMedium(), + 'utm_term' => $this->getCampaignTerm(), + 'utm_content' => $this->getCampaignContent(), + 'utm_campaign' => $this->getCampaignName() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/GroupId.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/GroupId.php new file mode 100644 index 0000000..64c52a7 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/GroupId.php @@ -0,0 +1,73 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a GroupId object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class GroupId implements \JsonSerializable +{ + /** @var $group_id int The unsubscribe group to associate with this email */ + private $group_id; + + /** + * Optional constructor + * + * @param int|null $group_id The unsubscribe group to associate with this email + */ + public function __construct($group_id = null) + { + if (isset($group_id)) { + $this->setGroupId($group_id); + } + } + + /** + * Add the group id to a GroupId object + * + * @param int $group_id The unsubscribe group to associate with this email + * + * @throws TypeException + */ + public function setGroupId($group_id) + { + if (!is_int($group_id)) { + throw new TypeException('$group_id must be of type int.'); + } + $this->group_id = $group_id; + } + + /** + * Retrieve the group id from a GroupId object + * + * @return int + */ + public function getGroupId() + { + return $this->group_id; + } + + /** + * Return an array representing a GroupId object for the Twilio SendGrid API + * + * @return int + */ + public function jsonSerialize() + { + return $this->getGroupId(); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/GroupsToDisplay.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/GroupsToDisplay.php new file mode 100644 index 0000000..7ed1120 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/GroupsToDisplay.php @@ -0,0 +1,87 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a GroupsToDisplay object for + * the /mail/send API call + * + * @package SendGrid\Mail + */ +class GroupsToDisplay implements \JsonSerializable +{ + /** @var $groups_to_display int[] An array containing the unsubscribe groups that you would like to be displayed on the unsubscribe preferences page. Maximum of 25 */ + private $groups_to_display; + + /** + * Optional constructor + * + * @param int[]|int|null $groups_to_display An array containing + * the unsubscribe groups + * that you would like to + * be displayed on the + * unsubscribe preferences + * page. Maximum of 25 + */ + public function __construct($groups_to_display = null) + { + if (isset($groups_to_display)) { + $this->setGroupsToDisplay($groups_to_display); + } + } + + /** + * Add a group to display on a GroupsToDisplay object + * + * @param int|int[] $groups_to_display The unsubscribe group(s) + * that you would like to be + * displayed on the unsubscribe + * preferences page + * + * @throws TypeException + * @return null + */ + public function setGroupsToDisplay($groups_to_display) + { + if (!is_array($groups_to_display)) { + throw new TypeException('$groups_to_display must be an array.'); + } + if (is_array($groups_to_display)) { + $this->groups_to_display = $groups_to_display; + } else { + $this->groups_to_display[] = $groups_to_display; + } + } + + /** + * Return the group(s) to display on a GroupsToDisplay object + * + * @return int[] + */ + public function getGroupsToDisplay() + { + return $this->groups_to_display; + } + + /** + * Return an array representing a GroupsToDisplay object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return $this->getGroupsToDisplay(); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Header.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Header.php new file mode 100644 index 0000000..aa901cf --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Header.php @@ -0,0 +1,116 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Header object for the /mail/send API call + * + * An object containing key/value pairs of header names and the value to substitute + * for them. You must ensure these are properly encoded if they contain unicode + * characters. Must not be one of the reserved headers + * + * @package SendGrid\Mail + */ +class Header implements \JsonSerializable +{ + /** @var $key string Header key */ + private $key; + /** @var $value string Header value */ + private $value; + + /** + * Optional constructor + * + * @param string|null $key Header key + * @param string|null $value Header value + */ + public function __construct($key = null, $value = null) + { + if (isset($key)) { + $this->setKey($key); + } + if (isset($value)) { + $this->setValue($value); + } + } + + /** + * Add the key on a Header object + * + * @param string $key Header key + * + * @throws TypeException + */ + public function setKey($key) + { + if (!is_string($key)) { + throw new TypeException('$key must be of type string.'); + } + $this->key = $key; + } + + /** + * Retrieve the key from a Header object + * + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Add the value on a Header object + * + * @param string $value Header value + * + * @throws TypeException + */ + public function setValue($value) + { + if (!is_string($value)) { + throw new TypeException('$value must be of type string.'); + } + $this->value = $value; + } + + /** + * Retrieve the value from a Header object + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Return an array representing a Header object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'key' => $this->getKey(), + 'value' => $this->getValue() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/HtmlContent.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/HtmlContent.php new file mode 100644 index 0000000..b8d6e9b --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/HtmlContent.php @@ -0,0 +1,33 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Content object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class HtmlContent extends Content +{ + /** + * Create a Content object with a HTML mime type + * + * @param string $value HTML formatted content + */ + public function __construct($value) + { + parent::__construct(MimeType::HTML, $value); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/IpPoolName.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/IpPoolName.php new file mode 100644 index 0000000..5e0cdeb --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/IpPoolName.php @@ -0,0 +1,77 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a IpPoolName object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class IpPoolName implements \JsonSerializable +{ + /** @var $ip_pool_name string The IP Pool that you would like to send this email from. Minimum length: 2, Maximum Length: 64 */ + private $ip_pool_name; + + /** + * Optional constructor + * + * @param string|null $ip_pool_name The IP Pool that you would like to + * send this email from. Minimum length: + * 2, Maximum Length: 64 + */ + public function __construct($ip_pool_name = null) + { + if (isset($ip_pool_name)) { + $this->setIpPoolName($ip_pool_name); + } + } + + /** + * Set the ip pool name on a IpPoolName object + * + * @param string $ip_pool_name The IP Pool that you would like to + * send this email from. Minimum length: + * 2, Maximum Length: 64 + * + * @throws TypeException + */ + public function setIpPoolName($ip_pool_name) + { + if (!is_string($ip_pool_name)) { + throw new TypeException('$ip_pool_name must be of type string.'); + } + $this->ip_pool_name = $ip_pool_name; + } + + /** + * Retrieve the ip pool name from a IpPoolName object + * + * @return string + */ + public function getIpPoolName() + { + return $this->ip_pool_name; + } + + /** + * Return an array representing a IpPoolName object for the Twilio SendGrid API + * + * @return string + */ + public function jsonSerialize() + { + return $this->getIpPoolName(); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Mail.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Mail.php new file mode 100644 index 0000000..86a5128 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Mail.php @@ -0,0 +1,1911 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a request body for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Mail implements \JsonSerializable +{ + /** @var $from From Email address of the sender */ + private $from; + + /** @var $subject Subject Subject of the email */ + private $subject; + + /** @var $contents Content[] Content(s) of the email */ + private $contents; + + /** @var $attachments Attachment[] Email attachments */ + private $attachments; + + /** @var $template_id TemplateId Id of a template that you would like to use */ + private $template_id; + + /** @var $sections Section[] Key/value pairs that define block sections of code to be used as substitutions */ + private $sections; + + /** @var $headers Header[] Header names and the value to substitute for them */ + private $headers; + + /** @var $categories Category[] Category names for this message */ + private $categories; + + /** @var $custom_args CustomArg[] Values that are specific to the entire send that will be carried along with the email and its activity data */ + private $custom_args; + + /** @var $substitutions Substitution[] Substitutions that will apply to the text and html content of the body of your email, in addition to the subject and reply-to parameters */ + private $substitutions; + + /** @var $send_at SendAt A unix timestamp allowing you to specify when you want your email to be delivered */ + private $send_at; + + /** @var $batch_id BatchId This ID represents a batch of emails to be sent at the same time */ + private $batch_id; + + /** @var $asm ASM Specifies how to handle unsubscribes */ + private $asm; + + /** @var $ip_pool_name IpPoolName The IP Pool that you would like to send this email from */ + private $ip_pool_name; + + /** @var $mail_settings MailSettings A collection of different mail settings that you can use to specify how you would like this email to be handled */ + private $mail_settings; + + /** @var $tracking_settings TrackingSettings Settings to determine how you would like to track the metrics of how your recipients interact with your email */ + private $tracking_settings; + + /** @var $reply_to ReplyTo Email to be use when replied to */ + private $reply_to; + + /** @var $personalization Personalization[] Messages and their metadata */ + private $personalization; + + const VERSION = "7.0.0"; + + /** + * If passing parameters into this constructor include + * $from, $to, $subject, $plainTextContent and + * $htmlContent at a minimum. In that case, a Personalization + * object will be created for you. + * + * @param From|null $from Email address of the sender + * @param To|To[]|null $to Recipient(s) email + * address(es) + * @param Subject|Subject[]|null $subject Subject(s) + * @param PlainTextContent|null $plainTextContent Plain text version of + * content + * @param HtmlContent|null $htmlContent Html version of content + * @param Substitution[]|null $globalSubstitutions Substitutions for entire + * email + */ + public function __construct( + $from = null, + $to = null, + $subject = null, + $plainTextContent = null, + $htmlContent = null, + array $globalSubstitutions = null + ) { + if (!isset($from) + && !isset($to) + && !isset($subject) + && !isset($plainTextContent) + && !isset($htmlContent) + && !isset($globalSubstitutions) + ) { + $this->personalization[] = new Personalization(); + return; + } + if (isset($from)) { + $this->setFrom($from); + } + if (isset($to)) { + if (!is_array($to)) { + $to = [$to]; + } + $subjectCount = 0; + $personalization = new Personalization(); + foreach ($to as $email) { + if ($subs = $email->getSubstitutions()) { + $personalization = new Personalization(); + } + $personalization->addTo($email); + if ($subs = $email->getSubstitutions()) { + foreach ($subs as $key => $value) { + $personalization->addSubstitution($key, $value); + } + } + if ($email->getSubject()) { + $personalization->setSubject($email->getSubject()); + } + if (is_array($subject)) { + if ($subjectCount < sizeof($subject)) { + $personalization->setSubject($subject[$subjectCount]); + } + $subjectCount++; + } + if (is_array($globalSubstitutions)) { + foreach ($globalSubstitutions as $key => $value) { + $personalization->addSubstitution($key, $value); + } + } + if ($subs = $email->getSubstitutions()) { + $this->addPersonalization($personalization); + } + } + if (!$subs = $email->getSubstitutions()) { + $this->addPersonalization($personalization); + } + } + if (isset($subject)) { + if (!is_array($subject)) { + $this->setSubject($subject); + } + } + if (isset($plainTextContent)) { + $this->addContent($plainTextContent); + } + if (isset($htmlContent)) { + $this->addContent($htmlContent); + } + } + + /** + * Adds a To, Cc or Bcc object to a Personalization object + * + * @param string $emailType Object type name: + * To, Cc or Bcc + * @param string $email Recipient email + * address + * @param string|null $name Recipient name + * @param Substitution[]|array|null $substitutions Personalized + * substitutions + * @param int|null $personalizationIndex Index into an array + * of existing + * Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + * + * @return null + */ + private function addRecipientEmail( + $emailType, + $email, + $name = null, + $substitutions = null, + $personalizationIndex = null, + $personalization = null + ) { + $personalizationFunctionCall = "add" . $emailType; + $emailType = "\SendGrid\Mail\\" . $emailType; + if (!($email instanceof $emailType)) { + $email = new $emailType( + $email, + $name, + $substitutions + ); + } + if ($personalization != null) { + $personalization->$personalizationFunctionCall($email); + if ($subs = $email->getSubstitutions()) { + foreach ($subs as $key => $value) { + $personalization->addSubstitution($key, $value); + } + } + $this->addPersonalization($personalization); + return; + } else { + if (isset($personalizationIndex) + && !isset($this->personalization[$personalizationIndex]) + ) { + // TODO: We should only do this if there exists an index + // previous. For example, if given an index 3 and there is + // no index 2, we should throw an error. + $this->personalization[$personalizationIndex] + = new Personalization(); + } + if ($this->personalization[0] != null && $personalizationIndex == 0) { + $this->personalization[0]->$personalizationFunctionCall($email); + if ($subs = $email->getSubstitutions()) { + foreach ($subs as $key => $value) { + $this->personalization[0]->addSubstitution($key, $value); + } + } + return; + } else if ($this->personalization[$personalizationIndex] != null) { + $this->personalization[$personalizationIndex]->$personalizationFunctionCall($email); + if ($subs = $email->getSubstitutions()) { + foreach ($subs as $key => $value) { + $this->personalization[$personalizationIndex]->addSubstitution( + $key, + $value + ); + } + } + return; + } else { + $personalization = new Personalization(); + $personalization->$personalizationFunctionCall($email); + if ($subs = $email->getSubstitutions()) { + foreach ($subs as $key => $value) { + $personalization->addSubstitution($key, $value); + } + } + if (($personalizationIndex != 0) + && ($this->getPersonalizationCount() <= $personalizationIndex) + ) { + $this->personalization[$personalizationIndex] = $personalization; + } else { + $this->addPersonalization($personalization); + } + return; + } + } + } + + /** + * Adds an array of To, Cc or Bcc objects to a Personalization object + * + * @param string $emailType Object type name: To, Cc + * or Bcc + * @param To[]|Cc[]|Bcc[] $emails Array of email recipients + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A Personalization object + */ + private function addRecipientEmails( + $emailType, + $emails, + $personalizationIndex = null, + $personalization = null + ) { + $emailFunctionCall = "add" . $emailType; + + if (current($emails) instanceof EmailAddress) { + foreach ($emails as $email) { + $this->$emailFunctionCall( + $email, + $name = null, + $personalizationIndex, + $personalization + ); + } + } else { + foreach ($emails as $email => $name) { + $this->$emailFunctionCall( + $email, + $name, + $personalizationIndex, + $personalization + ); + } + } + } + + /** + * Add a Personalization object to the Mail object + * + * @param Personalization $personalization A Personalization object + */ + public function addPersonalization($personalization) + { + $this->personalization[] = $personalization; + } + + /** + * Retrieve a Personalization object from the Mail object + * + * @return Personalization[] + */ + public function getPersonalizations() + { + return $this->personalization; + } + + /** + * Retrieve the number of Personalization objects associated with the Mail object + * + * @return int + */ + public function getPersonalizationCount() + { + return count($this->personalization); + } + + /** + * Adds an email recipient to a Personalization object + * + * @param string|To $to Email address or To object + * @param string $name Recipient name + * @param array|Substitution[] $substitutions Personalized substitutions + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addTo( + $to, + $name = null, + $substitutions = null, + $personalizationIndex = null, + $personalization = null + ) { + if ($to instanceof To) { + $name = $to->getName(); + $substitutions = $to->getSubstitutions(); + $to = $to->getEmailAddress(); + } + $this->addRecipientEmail( + "To", + $to, + $name, + $substitutions, + $personalizationIndex, + $personalization + ); + } + + /** + * Adds multiple email recipients to a Personalization object + * + * @param To[]|array $toEmails Array of To objects or + * key/value pairs of email + * address/recipient names + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addTos( + $toEmails, + $personalizationIndex = null, + $personalization = null + ) { + $this->addRecipientEmails( + "To", + $toEmails, + $personalizationIndex, + $personalization + ); + } + + /** + * Adds an email cc recipient to a Personalization object + * + * @param string|Cc $cc Email address or Cc object + * @param string $name Recipient name + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addCc( + $cc, + $name = null, + $personalizationIndex = null, + $personalization = null + ) { + if ($cc instanceof Cc) { + $name = $cc->getName(); + $cc = $cc->getEmailAddress(); + } + $this->addRecipientEmail( + "Cc", + $cc, + $name, + $personalizationIndex, + $personalization + ); + } + + /** + * Adds multiple email cc recipients to a Personalization object + * + * @param Cc[]|array $ccEmails Array of Cc objects or + * key/value pairs of email + * address/recipient names + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addCcs( + $ccEmails, + $personalizationIndex = null, + $personalization = null + ) { + $this->addRecipientEmails( + "Cc", + $ccEmails, + $personalizationIndex, + $personalization + ); + } + + /** + * Adds an email bcc recipient to a Personalization object + * + * @param string|Bcc $bcc Email address or Bcc object + * @param string $name Recipient name + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addBcc( + $bcc, + $name = null, + $personalizationIndex = null, + $personalization = null + ) { + if ($bcc instanceof Bcc) { + $name = $bcc->getName(); + $bcc = $bcc->getEmailAddress(); + } + $this->addRecipientEmail( + "Bcc", + $bcc, + $name, + $personalizationIndex, + $personalization + ); + } + + /** + * Adds multiple email bcc recipients to a Personalization object + * + * @param Bcc[]|array $bccEmails Array of Bcc objects or + * key/value pairs of email + * address/recipient names + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addBccs( + $bccEmails, + $personalizationIndex = null, + $personalization = null + ) { + $this->addRecipientEmails( + "Bcc", + $bccEmails, + $personalizationIndex, + $personalization + ); + } + + /** + * Add a subject to a Personalization or Mail object + * + * If you don't provide a Personalization object or index, the + * subject will be global to entire message. Note that + * subjects added to Personalization objects override + * global subjects. + * + * @param string|Subject $subject Email subject + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function setSubject( + $subject, + $personalizationIndex = null, + $personalization = null + ) { + if (!($subject instanceof Subject)) { + $subject = new Subject($subject); + } + + if ($personalization != null) { + $personalization->setSubject($subject); + $this->addPersonalization($personalization); + return; + } + if ($personalizationIndex != null) { + $this->personalization[$personalizationIndex]->setSubject($subject); + return; + } + $this->setGlobalSubject($subject); + return; + } + + /** + * Retrieve a subject attached to a Personalization object + * + * @param int|0 $personalizationIndex Index into an array of + * existing Personalization + * objects + * + * @return Subject + */ + public function getSubject($personalizationIndex = 0) + { + return $this->personalization[$personalizationIndex]->getSubject(); + } + + /** + * Add a header to a Personalization or Mail object + * + * If you don't provide a Personalization object or index, the + * header will be global to entire message. Note that + * headers added to Personalization objects override + * global headers. + * + * @param string|Header $key Key or Header object + * @param string|null $value Value + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addHeader( + $key, + $value = null, + $personalizationIndex = null, + $personalization = null + ) { + $header = null; + if ($key instanceof Header) { + $h = $key; + $header = new Header($h->getKey(), $h->getValue()); + } else { + $header = new Header($key, $value); + } + if ($personalization != null) { + $personalization->addHeader($header); + $this->addPersonalization($personalization); + return; + } else { + if ($this->personalization[0] != null) { + $this->personalization[0]->addHeader($header); + } else if ($this->personalization[$personalizationIndex] != null) { + $this->personalization[$personalizationIndex]->addHeader($header); + } else { + $personalization = new Personalization(); + $personalization->addHeader($header); + if (($personalizationIndex != 0) + && ($this->getPersonalizationCount() <= $personalizationIndex) + ) { + $this->personalization[$personalizationIndex] = $personalization; + } else { + $this->addPersonalization($personalization); + } + } + return; + } + } + + /** + * Adds multiple headers to a Personalization or Mail object + * + * If you don't provide a Personalization object or index, the + * header will be global to entire message. Note that + * headers added to Personalization objects override + * global headers. + * + * @param array|Header[] $headers Array of Header objects + * or key values + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addHeaders( + $headers, + $personalizationIndex = null, + $personalization = null + ) { + if (current($headers) instanceof Header) { + foreach ($headers as $header) { + $this->addHeader($header); + } + } else { + foreach ($headers as $key => $value) { + $this->addHeader( + $key, + $value, + $personalizationIndex, + $personalization + ); + } + } + } + + /** + * Retrieve the headers attached to a Personalization object + * + * @param int|0 $personalizationIndex Index into an array of + * existing Personalization + * objects + * + * @return Header[] + */ + public function getHeaders($personalizationIndex = 0) + { + return $this->personalization[$personalizationIndex]->getHeaders(); + } + + /** + * Add a DynamicTemplateData object or key/value to a Personalization object + * + * @param DynamicTemplateData|string $data DynamicTemplateData object or the key of a + * dynamic data + * @param string|null $value Value + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addDynamicTemplateData( + $key, + $value = null, + $personalizationIndex = null, + $personalization = null + ) { + $this->addSubstitution($key, $value, $personalizationIndex, $personalization); + } + + /** + * Add a DynamicTemplateData object or key/value to a Personalization object + * + * @param array|DynamicTemplateData[] $data Array of DynamicTemplateData objects or key/values + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addDynamicTemplateDatas( + $datas, + $personalizationIndex = null, + $personalization = null + ) { + $this->addSubstitutions($datas); + } + + /** + * Retrieve dynamic template data key/value pairs from a Personalization object + * + * @param int|0 $personalizationIndex Index into an array of + * existing Personalization + * objects + * + * @return array + */ + public function getDynamicTemplateDatas($personalizationIndex = 0) + { + return $this->getSubstitutions($personalizationIndex); + } + + /** + * Add a substitution to a Personalization or Mail object + * + * If you don't provide a Personalization object or index, the + * substitution will be global to entire message. Note that + * substitutions added to Personalization objects override + * global substitutions. + * + * @param string|Substitution $key Key or Substitution object + * @param string|null $value Value + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + * + * @return null + */ + public function addSubstitution( + $key, + $value = null, + $personalizationIndex = null, + $personalization = null + ) { + $substitution = null; + if ($key instanceof Substitution) { + $s = $key; + $substitution = new Substitution($s->getKey(), $s->getValue()); + } else { + $substitution = new Substitution($key, $value); + } + if ($personalization != null) { + $personalization->addSubstitution($substitution); + $this->addPersonalization($personalization); + return; + } else { + if ($this->personalization[0] != null) { + $this->personalization[0]->addSubstitution($substitution); + } else if ($this->personalization[$personalizationIndex] != null) { + $this->personalization[$personalizationIndex]->addSubstitution($substitution); + } else { + $personalization = new Personalization(); + $personalization->addSubstitution($substitution); + if (($personalizationIndex != 0) + && ($this->getPersonalizationCount() <= $personalizationIndex) + ) { + $this->personalization[$personalizationIndex] = $personalization; + } else { + $this->addPersonalization($personalization); + } + } + return; + } + } + + /** + * Adds multiple substitutions to a Personalization or Mail object + * + * If you don't provide a Personalization object or index, the + * substitution will be global to entire message. Note that + * substitutions added to Personalization objects override + * global headers. + * + * @param array|Substitution[] $substitutions Array of Substitution + * objects or key/values + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * ersonalization object + */ + public function addSubstitutions( + $substitutions, + $personalizationIndex = null, + $personalization = null + ) { + if (current($substitutions) instanceof Substitution) { + foreach ($substitutions as $substitution) { + $this->addSubstitution($substitution); + } + } else { + foreach ($substitutions as $key => $value) { + $this->addSubstitution( + $key, + $value, + $personalizationIndex, + $personalization + ); + } + } + } + + /** + * Retrieve the substitutions attached to a Personalization object + * + * @param int|0 $personalizationIndex Index into an array of + * existing Personalization + * objects + * + * @return Substitution[] + */ + public function getSubstitutions($personalizationIndex = 0) + { + return $this->personalization[$personalizationIndex]->getSubstitutions(); + } + + /** + * Add a custom arg to a Personalization or Mail object + * + * Note that custom args added to Personalization objects + * override global custom args. + * + * @param string|CustomArg $key Key or CustomArg object + * @param string|null $value Value + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addCustomArg( + $key, + $value = null, + $personalizationIndex = null, + $personalization = null + ) { + $custom_arg = null; + if ($key instanceof CustomArg) { + $ca = $key; + $custom_arg = new CustomArg($ca->getKey(), $ca->getValue()); + } else { + $custom_arg = new CustomArg($key, $value); + } + if ($personalization != null) { + $personalization->addCustomArg($custom_arg); + $this->addPersonalization($personalization); + return; + } else { + if ($this->personalization[0] != null) { + $this->personalization[0]->addCustomArg($custom_arg); + } else if ($this->personalization[$personalizationIndex] != null) { + $this->personalization[$personalizationIndex]->addCustomArg( + $custom_arg + ); + } else { + $personalization = new Personalization(); + $personalization->addCustomArg($custom_arg); + if (($personalizationIndex != 0) + && ($this->getPersonalizationCount() <= $personalizationIndex) + ) { + $this->personalization[$personalizationIndex] = $personalization; + } else { + $this->addPersonalization($personalization); + } + } + return; + } + } + + /** + * Adds multiple custom args to a Personalization or Mail object + * + * If you don't provide a Personalization object or index, the + * custom arg will be global to entire message. Note that + * custom args added to Personalization objects override + * global custom args. + * + * @param array|CustomArg[] $custom_args Array of CustomArg objects + * or key/values + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function addCustomArgs( + $custom_args, + $personalizationIndex = null, + $personalization = null + ) { + if (current($custom_args) instanceof CustomArg) { + foreach ($custom_args as $custom_arg) { + $this->addCustomArg($custom_arg); + } + } else { + foreach ($custom_args as $key => $value) { + $this->addCustomArg( + $key, + $value, + $personalizationIndex, + $personalization + ); + } + } + } + + /** + * Retrieve the custom args attached to a Personalization object + * + * @param int|0 $personalizationIndex Index into an array of + * existing Personalization + * objects + * + * @return CustomArg[] + */ + public function getCustomArgs($personalizationIndex = 0) + { + return $this->personalization[$personalizationIndex]->getCustomArgs(); + } + + /** + * Add a unix timestamp allowing you to specify when you want your + * email to be delivered to a Personalization or Mail object + * + * If you don't provide a Personalization object or index, the + * send at timestamp will be global to entire message. Note that + * timestamps added to Personalization objects override + * global timestamps. + * + * @param int|SendAt $send_at A unix timestamp + * @param int|null $personalizationIndex Index into an array of + * existing Personalization + * objects + * @param Personalization|null $personalization A pre-created + * Personalization object + */ + public function setSendAt( + $send_at, + $personalizationIndex = null, + $personalization = null + ) { + if (!($send_at instanceof SendAt)) { + $send_at = new SendAt($send_at); + } + if ($personalization != null) { + $personalization->setSendAt($send_at); + $this->addPersonalization($personalization); + return; + } else { + if ($this->personalization[0] != null) { + $this->personalization[0]->setSendAt($send_at); + return; + } else if ($this->personalization[$personalizationIndex] != null) { + $this->personalization[$personalizationIndex]->setSendAt($send_at); + return; + } else { + $personalization = new Personalization(); + $personalization->setSendAt($send_at); + if (($personalizationIndex != 0) + && ($this->getPersonalizationCount() <= $personalizationIndex) + ) { + $this->personalization[$personalizationIndex] = $personalization; + } else { + $this->addPersonalization($personalization); + } + return; + } + } + } + + /** + * Retrieve the unix timestamp attached to a Personalization object + * + * @param int|0 $personalizationIndex Index into an array of + * existing Personalization + * objects + * + * @return SendAt + */ + public function getSendAt($personalizationIndex = 0) + { + return $this->personalization[$personalizationIndex]->getSendAt(); + } + + /** + * Add the sender email address to a Mail object + * + * @param string|From $email Email address or From object + * @param string|null $name Sender name + * + * @throws TypeException + */ + public function setFrom($email, $name = null) + { + if ($email instanceof From) { + $this->from = $email; + } else { + + if ( + is_string($email) && filter_var($email, FILTER_VALIDATE_EMAIL) + ) { + $this->from = new From($email, $name); + } else { + throw new TypeException( + '$email must be valid and of type string.' + ); + } + + } + return; + } + + /** + * Retrieve the sender attached to a Mail object + * + * @return From + */ + public function getFrom() + { + return $this->from; + } + + /** + * Add the reply to email address to a Mail object + * + * @param string|ReplyTo $email Email address or From object + * @param string|null $name Reply to name + */ + public function setReplyTo($email, $name = null) + { + if ($email instanceof ReplyTo) { + $this->reply_to = $email; + } else { + $this->reply_to = new ReplyTo($email, $name); + } + } + + /** + * Retrieve the reply to information attached to a Mail object + * + * @return ReplyTo + */ + public function getReplyTo() + { + return $this->reply_to; + } + + + /** + * Add a subject to a Mail object + * + * Note that + * subjects added to Personalization objects override + * global subjects. + * + * @param string|Subject $subject Email subject + */ + public function setGlobalSubject($subject) + { + if (!($subject instanceof Subject)) { + $subject = new Subject($subject); + } + $this->subject = $subject; + } + + /** + * Retrieve a subject attached to a Mail object + * + * @return Subject + */ + public function getGlobalSubject() + { + return $this->subject; + } + + /** + * Add content to a Mail object + * + * For a list of pre-configured mime types, please see + * MimeType.php + * + * @param string|Content $type Mime type or Content object + * @param string|null $value Contents (e.g. text or html) + */ + public function addContent($type, $value = null) + { + if ($type instanceof Content) { + $content = $type; + } else { + $content = new Content($type, $value); + } + $this->contents[] = $content; + } + + /** + * Adds multiple Content objects to a Mail object + * + * @param array|Content[] $contents Array of Content objects + * or key value pairs + */ + public function addContents($contents) + { + if (current($contents) instanceof Content) { + foreach ($contents as $content) { + $this->addContent($content); + } + } else { + foreach ($contents as $key => $value) { + $this->addContent($key, $value); + } + } + } + + /** + * Retrieve the contents attached to a Mail object + * + * Will return array of Content Objects with text/plain MimeType first + * Array re-ordered before return where this is not already the case + * + * @return Content[] + */ + public function getContents() + { + if ($this->contents) { + if ($this->contents[0]->getType() !== 'text/plain' + && count($this->contents) > 1 + ) { + foreach ($this->contents as $key => $value) { + if ($value->getType() == 'text/plain') { + $plain_content = $value; + unset($this->contents[$key]); + break; + } + } + array_unshift($this->contents, $plain_content); + } + } + + return $this->contents; + } + + /** + * Add an attachment to a Mail object + * + * @param string|Attachment $attachment Attachment object or + * Base64 encoded content + * @param string|null $type Mime type of the attachment + * @param string|null $filename File name of the attachment + * @param string|null $disposition How the attachment should be + * displayed: inline or attachment + * default is attachment + * @param string|null $content_id Used when disposition is inline + * to diplay the file within the + * body of the email + */ + public function addAttachment( + $attachment, + $type = null, + $filename = null, + $disposition = null, + $content_id = null + ) { + if (is_array($attachment)) { + $attachment = new Attachment( + $attachment[0], + $attachment[1], + $attachment[2], + $attachment[3], + $attachment[4] + ); + } else if (!($attachment instanceof Attachment)) { + $attachment = new Attachment( + $attachment, + $type, + $filename, + $disposition, + $content_id + ); + } + $this->attachments[] = $attachment; + } + + /** + * Adds multiple attachments to a Mail object + * + * @param array|Attachment[] $attachments Array of Attachment objects + * or arrays + */ + public function addAttachments($attachments) + { + foreach ($attachments as $attachment) { + $this->addAttachment($attachment); + } + } + + /** + * Retrieve the attachments attached to a Mail object + * + * @return Attachment[] + */ + public function getAttachments() + { + return $this->attachments; + } + + /** + * Add a template id to a Mail object + * + * @param string $template_id The id of the template to be + * appied to this email + */ + public function setTemplateId($template_id) + { + if (!($template_id instanceof TemplateId)) { + $template_id = new TemplateId($template_id); + } + + $this->template_id = $template_id; + } + + /** + * Retrieve a template id attached to a Mail object + * + * @return TemplateId + */ + public function getTemplateId() + { + return $this->template_id; + } + + /** + * Add a section to a Mail object + * + * @param string|Section $key Key or Section object + * @param string|null $value Value + */ + public function addSection($key, $value = null) + { + if ($key instanceof Section) { + $section = $key; + $this->sections[$section->getKey()] + = $section->getValue(); + return; + } + $this->sections[$key] = (string)$value; + } + + /** + * Adds multiple sections to a Mail object + * + * @param array|Section[] $sections Array of CustomArg objects + * or key/values + */ + public function addSections($sections) + { + if (current($sections) instanceof Section) { + foreach ($sections as $section) { + $this->addSection($section); + } + } else { + foreach ($sections as $key => $value) { + $this->addSection($key, $value); + } + } + } + + /** + * Retrieve the section(s) attached to a Mail object + * + * @return Section[] + */ + public function getSections() + { + return $this->sections; + } + + /** + * Add a header to a Mail object + * + * Note that headers added to Personalization objects override + * global headers. + * + * @param string|Header $key Key or Header object + * @param string|null $value Value + */ + public function addGlobalHeader($key, $value = null) + { + if ($key instanceof Header) { + $header = $key; + $this->headers[$header->getKey()] + = $header->getValue(); + return; + } + $this->headers[$key] = (string)$value; + } + + /** + * Adds multiple headers to a Mail object + * + * Note that headers added to Personalization objects override + * global headers. + * + * @param array|Header[] $headers Array of Header objects + * or key values + */ + public function addGlobalHeaders($headers) + { + if (current($headers) instanceof Header) { + foreach ($headers as $header) { + $this->addGlobalHeader($header); + } + } else { + foreach ($headers as $key => $value) { + $this->addGlobalHeader($key, $value); + } + } + } + + /** + * Retrieve the headers attached to a Mail object + * + * @return Header[] + */ + public function getGlobalHeaders() + { + return $this->headers; + } + + /** + * Add a substitution to a Mail object + * + * Note that substitutions added to Personalization objects override + * global substitutions. + * + * @param string|Substitution $key Key or Substitution object + * @param string|null $value Value + */ + public function addGlobalSubstitution($key, $value = null) + { + if ($key instanceof Substitution) { + $substitution = $key; + $this->substitutions[$substitution->getKey()] + = $substitution->getValue(); + return; + } + $this->substitutions[$key] = $value; + } + + /** + * Adds multiple substitutions to a Mail object + * + * Note that substitutions added to Personalization objects override + * global headers. + * + * @param array|Substitution[] $substitutions Array of Substitution + * objects or key/values + */ + public function addGlobalSubstitutions($substitutions) + { + if (current($substitutions) instanceof Substitution) { + foreach ($substitutions as $substitution) { + $this->addGlobalSubstitution($substitution); + } + } else { + foreach ($substitutions as $key => $value) { + $this->addGlobalSubstitution($key, $value); + } + } + } + + /** + * Retrieve the substitutions attached to a Mail object + * + * @return Substitution[] + */ + public function getGlobalSubstitutions() + { + return $this->substitutions; + } + + /** + * Add a category to a Mail object + * + * @param string|Category $category Category object or category name + */ + public function addCategory($category) + { + if (!($category instanceof Category)) { + $category = new Category($category); + } + $this->categories[] = $category; + } + + /** + * Adds multiple categories to a Mail object + * + * @param array|Category[] $categories Array of Category objects + * or arrays + */ + public function addCategories($categories) + { + foreach ($categories as $category) { + $this->addCategory($category); + } + return; + } + + /** + * Retrieve the categories attached to a Mail object + * + * @return Category[] + */ + public function getCategories() + { + return $this->categories; + } + + /** + * Add a custom arg to a Mail object + * + * Note that custom args added to Personalization objects override + * global custom args. + * + * @param string|CustomArg $key Key or CustomArg object + * @param string|null $value Value + */ + public function addGlobalCustomArg($key, $value = null) + { + if ($key instanceof CustomArg) { + $custom_arg = $key; + $this->custom_args[$custom_arg->getKey()] + = $custom_arg->getValue(); + return; + } + $this->custom_args[$key] = (string)$value; + } + + /** + * Adds multiple custom args to a Mail object + * + * Note that custom args added to Personalization objects override + * global custom args. + * + * @param array|CustomArg[] $custom_args Array of CustomArg objects + * or key/values + */ + public function addGlobalCustomArgs($custom_args) + { + if (current($custom_args) instanceof CustomArg) { + foreach ($custom_args as $custom_arg) { + $this->addGlobalCustomArg($custom_arg); + } + } else { + foreach ($custom_args as $key => $value) { + $this->addGlobalCustomArg($key, $value); + } + } + } + + /** + * Retrieve the custom args attached to a Mail object + * + * @return CustomArg[] + */ + public function getGlobalCustomArgs() + { + return $this->custom_args; + } + + /** + * Add a unix timestamp allowing you to specify when you want your + * email to be delivered to a Mail object + * + * Note that timestamps added to Personalization objects override + * global timestamps. + * + * @param int|SendAt $send_at A unix timestamp + */ + public function setGlobalSendAt($send_at) + { + if (!($send_at instanceof SendAt)) { + $send_at = new SendAt($send_at); + } + $this->send_at = $send_at; + } + + /** + * Retrieve the unix timestamp attached to a Mail object + * + * @return SendAt + */ + public function getGlobalSendAt() + { + return $this->send_at; + } + + /** + * Add a batch id to a Mail object + * + * @param string|BatchId $batch_id Id for a batch of emails + * to be sent at the same time + */ + public function setBatchId($batch_id) + { + if (!($batch_id instanceof BatchId)) { + $batch_id = new BatchId($batch_id); + } + $this->batch_id = $batch_id; + } + + /** + * Retrieve the batch id attached to a Mail object + * + * @return BatchId + */ + public function getBatchId() + { + return $this->batch_id; + } + + /** + * Add a Asm describing how to handle unsubscribes to a Mail object + * + * @param int|Asm $group_id Asm object or unsubscribe group id + * to associate this email with + * @param array $groups_to_display Array of integer ids of unsubscribe + * groups to be displayed on the + * unsubscribe preferences page + */ + public function setAsm($group_id, $groups_to_display = null) + { + if ($group_id instanceof Asm) { + $asm = $group_id; + $this->asm = $asm; + } else { + $this->asm = new Asm($group_id, $groups_to_display); + } + } + + /** + * Retrieve the Asm object describing how to handle unsubscribes attached + * to a Mail object + * + * @return Asm + */ + public function getAsm() + { + return $this->asm; + } + + /** + * Add the IP pool name to a Mail object + * + * @param string|IpPoolName $ip_pool_name The IP Pool that you would + * like to send this email from + */ + public function setIpPoolName($ip_pool_name) + { + if ($ip_pool_name instanceof IpPoolName) { + $this->ip_pool_name = $ip_pool_name->getIpPoolName(); + } else { + $this->ip_pool_name = new IpPoolName($ip_pool_name); + } + + } + + /** + * Retrieve the IP pool name attached to a Mail object + * + * @return IpPoolName + */ + public function getIpPoolName() + { + return $this->ip_pool_name; + } + + /** + * Add a MailSettings object to a Mail object + * + * @param MailSettings $mail_settings A collection of different + * mail settings that you can + * use to specify how you would + * like this email to be handled + * @throws TypeException + */ + public function setMailSettings($mail_settings) + { + if (!($mail_settings instanceof MailSettings)) { + throw new TypeException( + '$mail_settings must be an instance of SendGrid\Mail\MailSettings' + ); + } + $this->mail_settings = $mail_settings; + } + + /** + * Retrieve the MailSettings object attached to a Mail object + * + * @return MailSettings + */ + public function getMailSettings() + { + return $this->mail_settings; + } + + /** + * Set the Bcc settings on a MailSettings object + * + * @param bool|BccSettings $enable A BccSettings object or a boolean + * to determine if this setting is active + * @param string|null $email The email address to be bcc'ed + */ + public function setBccSettings($enable, $email = null) + { + if (!($this->mail_settings instanceof MailSettings)) { + $this->mail_settings = new MailSettings(); + } + $this->mail_settings->setBccSettings($enable, $email); + } + + /** + * Enable bypass list management on a MailSettings object + * + * Allows you to bypass all unsubscribe groups and suppressions to ensure + * that the email is delivered to every single recipient. This should only + * be used in emergencies when it is absolutely necessary that every + * recipient receives your email. + */ + public function enableBypassListManagement() + { + if (!$this->mail_settings instanceof MailSettings) { + $this->mail_settings = new MailSettings(); + } + $this->mail_settings->setBypassListManagement(true); + } + + /** + * Disable bypass list management on a MailSettings object + * + * Allows you to bypass all unsubscribe groups and suppressions to ensure + * that the email is delivered to every single recipient. This should only + * be used in emergencies when it is absolutely necessary that every + * recipient receives your email. + */ + public function disableBypassListManagement() + { + if (!($this->mail_settings instanceof MailSettings)) { + $this->mail_settings = new MailSettings(); + } + $this->mail_settings->setBypassListManagement(false); + } + + /** + * Set the Footer settings on a MailSettings object + * + * @param bool|Footer $enable A Footer object or a boolean + * to determine if this setting is active + * @param string|null $text The plain text content of the footer + * @param string|null $html The HTML content of the footer + */ + public function setFooter($enable = null, $text = null, $html = null) + { + if (!$this->mail_settings instanceof MailSettings) { + $this->mail_settings = new MailSettings(); + } + $this->mail_settings->setFooter($enable, $text, $html); + } + + /** + * Enable sandbox mode on a MailSettings object + * + * This allows you to send a test email to ensure that your request + * body is valid and formatted correctly. + */ + public function enableSandBoxMode() + { + if (!($this->mail_settings instanceof MailSettings)) { + $this->mail_settings = new MailSettings(); + } + $this->mail_settings->setSandBoxMode(true); + } + + /** + * Disable sandbox mode on a MailSettings object + * + * This allows you to send a test email to ensure that your request + * body is valid and formatted correctly. + */ + public function disableSandBoxMode() + { + if (!($this->mail_settings instanceof MailSettings)) { + $this->mail_settings = new MailSettings(); + } + $this->mail_settings->setSandBoxMode(false); + } + + /** + * Set the spam check settings on a MailSettings object + * + * @param bool|SpamCheck $enable A SpamCheck object or a boolean + * to determine if this setting is active + * @param int|null $threshold The threshold used to determine if your + * content qualifies as spam on a scale from + * 1 to 10, with 10 being most strict, or + * most likely to be considered as spam + * @param string|null $post_to_url An Inbound Parse URL that you would like + * a copy of your email along with the spam + * report to be sent to + */ + public function setSpamCheck($enable = null, $threshold = null, $post_to_url = null) + { + if (!$this->mail_settings instanceof MailSettings) { + $this->mail_settings = new MailSettings(); + } + $this->mail_settings->setSpamCheck($enable, $threshold, $post_to_url); + } + + /** + * Add a TrackingSettings object to a Mail object + * + * @param TrackingSettings $tracking_settings Settings to determine how you + * would like to track the metrics + * of how your recipients interact + * with your email + * @throws TypeException + */ + public function setTrackingSettings($tracking_settings) + { + if (!($tracking_settings instanceof TrackingSettings)) { + throw new TypeException( + '$tracking_settings must be an instance of SendGrid\Mail\TrackingSettings' + ); + } + $this->tracking_settings = $tracking_settings; + } + + /** + * Retrieve the TrackingSettings object attached to a Mail object + * + * @return TrackingSettings + */ + public function getTrackingSettings() + { + return $this->tracking_settings; + } + + /** + * Set the click tracking settings on a TrackingSettings object + * + * @param bool|ClickTracking $enable A ClickTracking object or a boolean + * to determine if this setting is active + * @param bool|null $enable_text Indicates if this setting should be + * included in the text/plain portion of + * your email + */ + public function setClickTracking($enable = null, $enable_text = null) + { + if (!($this->tracking_settings instanceof TrackingSettings)) { + $this->tracking_settings = new TrackingSettings(); + } + $this->tracking_settings->setClickTracking($enable, $enable_text); + } + + /** + * Set the open tracking settings on a TrackingSettings object + * + * @param bool|OpenTracking $enable A OpenTracking object or a boolean + * to determine if this setting is + * active + * @param string|null $substitution_tag Allows you to specify a + * substitution tag that you can + * insert in the body of your email + * at a location that you desire. + * This tag will be replaced by the + * open tracking pixel + */ + public function setOpenTracking($enable = null, $substitution_tag = null) + { + if (!($this->tracking_settings instanceof TrackingSettings)) { + $this->tracking_settings = new TrackingSettings(); + } + $this->tracking_settings->setOpenTracking($enable, $substitution_tag); + } + + /** + * Set the subscription tracking settings on a TrackingSettings object + * + * @param bool|SubscriptionTracking $enable A SubscriptionTracking + * object or a boolean to + * determine if this setting + * is active + * @param string|null $text Text to be appended to the + * email, with the + * subscription tracking + * link. You may control + * where the link is by using + * the tag <% %> + * @param string|null $html HTML to be appended to the + * email, with the + * subscription tracking + * link. You may control + * where the link is by using + * the tag <% %> + * @param string|null $substitution_tag A tag that will be + * replaced with the + * unsubscribe URL. for + * example: + * [unsubscribe_url]. If this + * parameter is used, it will + * override both the text and + * html parameters. The URL + * of the link will be placed + * at the substitution tag’s + * location, with no + * additional formatting + */ + public function setSubscriptionTracking( + $enable = null, + $text = null, + $html = null, + $substitution_tag = null + ) { + if (!($this->tracking_settings instanceof TrackingSettings)) { + $this->tracking_settings = new TrackingSettings(); + } + $this->tracking_settings->setSubscriptionTracking( + $enable, + $text, + $html, + $substitution_tag + ); + } + + /** + * Set the Google anatlyics settings on a TrackingSettings object + * + * @param bool|Ganalytics $enable A Ganalytics object or a boolean to + * determine if this setting + * is active + * @param string|null $utm_source Name of the referrer source. (e.g. + * Google, SomeDomain.com, or + * Marketing Email) + * @param string|null $utm_medium Name of the marketing medium. + * (e.g. Email) + * @param string|null $utm_term Used to identify any paid keywords. + * @param string|null $utm_content Used to differentiate your campaign + * from advertisements + * @param string|null $utm_campaign The name of the campaign + */ + public function setGanalytics( + $enable = null, + $utm_source = null, + $utm_medium = null, + $utm_term = null, + $utm_content = null, + $utm_campaign = null + ) { + if (!($this->tracking_settings instanceof TrackingSettings)) { + $this->tracking_settings = new TrackingSettings(); + } + $this->tracking_settings->setGanalytics( + $enable, + $utm_source, + $utm_medium, + $utm_term, + $utm_content, + $utm_campaign + ); + } + + /** + * Return an array representing a request object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + // Detect if we are using the new dynamic templates + $template_id = $this->getTemplateId(); + if ($template_id != null) { + if (substr((string) $template_id->getTemplateId(), 0, 2) == "d-") { + foreach ($this->personalization as $personalization) { + $personalization->setHasDynamicTemplate(true); + } + } + } + return array_filter( + [ + 'personalizations' => $this->getPersonalizations(), + 'from' => $this->getFrom(), + 'reply_to' => $this->getReplyTo(), + 'subject' => $this->getGlobalSubject(), + 'content' => $this->getContents(), + 'attachments' => $this->getAttachments(), + 'template_id' => $this->getTemplateId(), + 'sections' => $this->getSections(), + 'headers' => $this->getGlobalHeaders(), + 'categories' => $this->getCategories(), + 'custom_args' => $this->getGlobalCustomArgs(), + 'send_at' => $this->getGlobalSendAt(), + 'batch_id' => $this->getBatchId(), + 'asm' => $this->getASM(), + 'ip_pool_name' => $this->getIpPoolName(), + 'substitutions' => $this->getGlobalSubstitutions(), + 'mail_settings' => $this->getMailSettings(), + 'tracking_settings' => $this->getTrackingSettings() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/MailSettings.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/MailSettings.php new file mode 100644 index 0000000..8ee56ea --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/MailSettings.php @@ -0,0 +1,274 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a MailSettings object for the /mail/send API call + * + * A collection of different mail settings that you can use to specify how you would + * like this email to be handled + * + * @package SendGrid\Mail + */ +class MailSettings implements \JsonSerializable +{ + /** @var $bcc Bcc object */ + private $bcc; + /** @var $bypass_list_management BypassListManagement object */ + private $bypass_list_management; + /** @var $footer Footer object */ + private $footer; + /** @var $sandbox_mode SandBoxMode object */ + private $sandbox_mode; + /** @var $spam_check SpamCheck object */ + private $spam_check; + + /** + * Optional constructor + * + * @param BccSettings|null $bcc_settings BccSettings object + * @param BypassListManagement|null $bypass_list_management BypassListManagement + * object + * @param Footer|null $footer Footer object + * @param SandBoxMode|null $sandbox_mode SandBoxMode object + * @param SpamCheck|null $spam_check SpamCheck object + */ + public function __construct( + $bcc_settings = null, + $bypass_list_management = null, + $footer = null, + $sandbox_mode = null, + $spam_check = null + ) { + if (isset($bcc_settings)) { + $this->setBccSettings($bcc_settings); + } + if (isset($bypass_list_management)) { + $this->setBypassListManagement($bypass_list_management); + } + if (isset($footer)) { + $this->setFooter($footer); + } + if (isset($sandbox_mode)) { + $this->setSandboxMode($sandbox_mode); + } + if (isset($spam_check)) { + $this->setSpamCheck($spam_check); + } + } + + /** + * Set the bcc settings on a MailSettings object + * + * @param BccSettings|bool $enable The BccSettings object or an indication + * if the setting is enabled + * @param string|null $email The email address that you would like + * to receive the BCC + * + * @throws TypeException + */ + public function setBccSettings($enable, $email = null) + { + if ($enable instanceof BccSettings) { + $bcc = $enable; + $this->bcc = $bcc; + return; + } + if (!is_bool($enable)) { + throw new TypeException( + '$enable must be an instance of SendGrid\Mail\BccSettings or of type bool.' + ); + } + $this->bcc = new BccSettings($enable, $email); + } + + /** + * Retrieve the bcc settings from a MailSettings object + * + * @return Bcc + */ + public function getBccSettings() + { + return $this->bcc; + } + + /** + * Set bypass list management settings on a MailSettings object + * + * @param BypassListManagement|bool $enable The BypassListManagement + * object or an indication + * if the setting is enabled + * + * @throws TypeException + */ + public function setBypassListManagement($enable) + { + if ($enable instanceof BypassListManagement) { + $bypass_list_management = $enable; + $this->bypass_list_management = $bypass_list_management; + return; + } + if (!is_bool($enable)) { + throw new TypeException( + '$enable must be an instance of SendGrid\Mail\BypassListManagement or of type bool.' + ); + } + $this->bypass_list_management = new BypassListManagement($enable); + return; + } + + /** + * Retrieve bypass list management settings from a MailSettings object + * + * @return BypassListManagement + */ + public function getBypassListManagement() + { + return $this->bypass_list_management; + } + + /** + * Set the footer settings on a MailSettings object + * + * @param Footer|bool $enable The Footer object or an indication + * if the setting is enabled + * @param string|null $text The plain text content of your footer + * @param string|null $html The HTML content of your footer + * + * @return null + */ + public function setFooter($enable, $text = null, $html = null) + { + if ($enable instanceof Footer) { + $footer = $enable; + $this->footer = $footer; + return; + } + $this->footer = new Footer($enable, $text, $html); + return; + } + + /** + * Retrieve the footer settings from a MailSettings object + * + * @return Footer + */ + public function getFooter() + { + return $this->footer; + } + + /** + * Set sandbox mode settings on a MailSettings object + * + * @param SandBoxMode|bool $enable The SandBoxMode object or an + * indication if the setting is enabled + * + * @return null + */ + public function setSandboxMode($enable) + { + if ($enable instanceof SandBoxMode) { + $sandbox_mode = $enable; + $this->sandbox_mode = $sandbox_mode; + return; + } + $this->sandbox_mode = new SandBoxMode($enable); + return; + } + + /** + * Retrieve sandbox mode settings on a MailSettings object + * + * @return SandBoxMode + */ + public function getSandboxMode() + { + return $this->sandbox_mode; + } + + /** + * Enable sandbox mode on a MailSettings object + */ + public function enableSandboxMode() + { + $this->setSandboxMode(true); + } + + /** + * Disable sandbox mode on a MailSettings object + */ + public function disableSandboxMode() + { + $this->setSandboxMode(false); + } + + /** + * Set spam check settings on a MailSettings object + * + * @param SpamCheck|bool $enable The SpamCheck object or an + * indication if the setting is enabled + * @param int $threshold The threshold used to determine if your + * content qualifies as spam on a scale + * from 1 to 10, with 10 being most strict, + * or most + * @param string $post_to_url An Inbound Parse URL that you would like + * a copy of your email along with the spam + * report to be sent to + * + * @return null + */ + public function setSpamCheck($enable, $threshold = null, $post_to_url = null) + { + if ($enable instanceof SpamCheck) { + $spam_check = $enable; + $this->spam_check = $spam_check; + return; + } + $this->spam_check = new SpamCheck($enable, $threshold, $post_to_url); + return; + } + + /** + * Retrieve spam check settings from a MailSettings object + * + * @return SpamCheck + */ + public function getSpamCheck() + { + return $this->spam_check; + } + + /** + * Return an array representing a MailSettings object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'bcc' => $this->getBccSettings(), + 'bypass_list_management' => $this->getBypassListManagement(), + 'footer' => $this->getFooter(), + 'sandbox_mode' => $this->getSandboxMode(), + 'spam_check' => $this->getSpamCheck() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/MimeType.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/MimeType.php new file mode 100644 index 0000000..6d33872 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/MimeType.php @@ -0,0 +1,26 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to define the content mime types for the /mail/send API call + * + * @package SendGrid\Mail + */ +abstract class MimeType +{ + const HTML = "text/html"; + const TEXT = "text/plain"; +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/OpenTracking.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/OpenTracking.php new file mode 100644 index 0000000..f3204fe --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/OpenTracking.php @@ -0,0 +1,124 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a OpenTracking object for the /mail/send API call + * + * Allows you to track whether the email was opened or not, but including a single + * pixel image in the body of the content. When the pixel is loaded, we can log that + * the email was opened + * + * @package SendGrid\Mail + */ +class OpenTracking implements \JsonSerializable +{ + /** @var $enable bool Indicates if this setting is enabled */ + private $enable; + /** @var $substitution_tag string Allows you to specify a substitution tag that you can insert in the body of your email at a location that you desire. This tag will be replaced by the open tracking pixel */ + private $substitution_tag; + + /** + * Optional constructor + * + * @param bool|null $enable Indicates if this setting is enabled + * @param string|null $substitution_tag Allows you to specify a substitution + * tag that you can insert in the body + * of your email at a location that you + * desire. This tag will be replaced by + * the open tracking pixel + */ + public function __construct($enable = null, $substitution_tag = null) + { + if (isset($enable)) { + $this->setEnable($enable); + } + if (isset($substitution_tag)) { + $this->setSubstitutionTag($substitution_tag); + } + } + + /** + * Update the enable setting on a OpenTracking object + * + * @param bool $enable Indicates if this setting is enabled + * + * @throws TypeException + */ + public function setEnable($enable) + { + if (!is_bool($enable)) { + throw new TypeException('$enable must be of type bool'); + } + $this->enable = $enable; + } + + /** + * Retrieve the enable setting on a OpenTracking object + * + * @return bool + */ + public function getEnable() + { + return $this->enable; + } + + /** + * Set the substitution tag on a OpenTracking object + * + * @param string $substitution_tag Allows you to specify a substitution + * tag that you can insert in the body + * of your email at a location that you + * desire. This tag will be replaced by + * the open tracking pixel + * + * @throws TypeException + */ + public function setSubstitutionTag($substitution_tag) + { + if (!is_string($substitution_tag)) { + throw new TypeException('$substitution_tag must be of type string.'); + } + $this->substitution_tag = $substitution_tag; + } + + /** + * Retrieve the substitution tag from a OpenTracking object + * + * @return string + */ + public function getSubstitutionTag() + { + return $this->substitution_tag; + } + + /** + * Return an array representing a OpenTracking object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'enable' => $this->getEnable(), + 'substitution_tag' => $this->getSubstitutionTag() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Personalization.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Personalization.php new file mode 100644 index 0000000..711a824 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Personalization.php @@ -0,0 +1,312 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Personalization object for + * the /mail/send API call + * + * Each Personalization can be thought of as an envelope - it defines + * who should receive an individual message and how that message should be handled + * + * @package SendGrid\Mail + */ +class Personalization implements \JsonSerializable +{ + /** @var $tos To[] objects */ + private $tos; + /** @var $ccs Cc[] objects */ + private $ccs; + /** @var $bccs Bcc[] objects */ + private $bccs; + /** @var $subject Subject object */ + private $subject; + /** @var $headers Header[] array of header key values */ + private $headers; + /** @var $substitutions Substitution[] array of substitution key values, used for legacy templates */ + private $substitutions; + /** @var array of dynamic template data key values */ + private $dynamic_template_data; + /** @var bool if we are using dynamic templates this will be true */ + private $has_dynamic_template = false; + /** @var $custom_args CustomArg[] array of custom arg key values */ + private $custom_args; + /** @var $send_at SendAt object */ + private $send_at; + + /** + * Add a To object to a Personalization object + * + * @param To $email To object + */ + public function addTo($email) + { + $this->tos[] = $email; + } + + /** + * Retrieve To object(s) from a Personalization object + * + * @return To[] + */ + public function getTos() + { + return $this->tos; + } + + /** + * Add a Cc object to a Personalization object + * + * @param Cc $email Cc object + */ + public function addCc($email) + { + $this->ccs[] = $email; + } + + /** + * Retrieve Cc object(s) from a Personalization object + * + * @return Cc[] + */ + public function getCcs() + { + return $this->ccs; + } + + /** + * Add a Bcc object to a Personalization object + * + * @param Bcc $email Bcc object + */ + public function addBcc($email) + { + $this->bccs[] = $email; + } + + /** + * Retrieve Bcc object(s) from a Personalization object + * + * @return Bcc[] + */ + public function getBccs() + { + return $this->bccs; + } + + /** + * Add a subject object to a Personalization object + * + * @param Subject $subject Subject object + * + * @throws TypeException + */ + public function setSubject($subject) + { + if (!($subject instanceof Subject)) { + throw new TypeException( + '$subject must be an instance of SendGrid\Mail\Subject' + ); + } + $this->subject = $subject; + } + + /** + * Retrieve a Subject object from a Personalization object + * + * @return Subject + */ + public function getSubject() + { + return $this->subject; + } + + /** + * Add a Header object to a Personalization object + * + * @param Header $header Header object + */ + public function addHeader($header) + { + $this->headers[$header->getKey()] = $header->getValue(); + } + + /** + * Retrieve header key/value pairs from a Personalization object + * + * @return array + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * Add a Substitution object or key/value to a Personalization object + * + * @param Substitution|string $data DynamicTemplateData object or the key of a + * dynamic data + * @param string|null $value The value of dynmic data + * + * @return null + */ + public function addDynamicTemplateData($data, $value = null) + { + $this->addSubstitution($data, $value); + } + + /** + * Retrieve dynamic template data key/value pairs from a Personalization object + * + * @return array + */ + public function getDynamicTemplateData() + { + return $this->getSubstitutions(); + } + + /** + * Add a Substitution object or key/value to a Personalization object + * + * @param Substitution|string $substitution Substitution object or the key of a + * substitution + * @param string|null $value The value of a substitution + */ + public function addSubstitution($substitution, $value = null) + { + if (!($substitution instanceof Substitution)) { + $key = $substitution; + $substitution = new Substitution($key, $value); + } + $this->substitutions[$substitution->getKey()] = $substitution->getValue(); + } + + /** + * Retrieve substitution key/value pairs from a Personalization object + * + * @return array + */ + public function getSubstitutions() + { + return $this->substitutions; + } + + /** + * Add a CustomArg object to a Personalization object + * + * @param CustomArg $custom_arg CustomArg object + */ + public function addCustomArg($custom_arg) + { + $this->custom_args[$custom_arg->getKey()] = (string)$custom_arg->getValue(); + } + + /** + * Retrieve custom arg key/value pairs from a Personalization object + * + * @return array + */ + public function getCustomArgs() + { + return $this->custom_args; + } + + /** + * Add a SendAt object to a Personalization object + * + * @param SendAt $send_at SendAt object + * + * @throws TypeException + */ + public function setSendAt($send_at) + { + if (!($send_at instanceof SendAt)) { + throw new TypeException( + '$send_at must be an instance of SendGrid\Mail\SendAt' + ); + } + $this->send_at = $send_at; + } + + /** + * Retrieve a SendAt object from a Personalization object + * + * @return SendAt + */ + public function getSendAt() + { + return $this->send_at; + } + + /** + * Specify if this personalization is using dynamic templates + * + * @param bool $has_dynamic_template are we using dynamic templates + * + * @throws TypeException + */ + public function setHasDynamicTemplate($has_dynamic_template) + { + if (is_bool($has_dynamic_template) != true) { + throw new TypeException( + '$has_dynamic_template must be an instance of bool' + ); + } + $this->has_dynamic_template = $has_dynamic_template; + } + + /** + * Determine if this Personalization object is using dynamic templates + * + * @return bool + */ + public function getHasDynamicTemplate() + { + return $this->has_dynamic_template; + } + + /** + * Return an array representing a Personalization object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + if ($this->getHasDynamicTemplate() == true) { + $dynamic_substitutions = $this->getSubstitutions(); + $substitutions = null; + } else { + $substitutions = $this->getSubstitutions(); + $dynamic_substitutions = null; + } + + return array_filter( + [ + 'to' => $this->getTos(), + 'cc' => $this->getCcs(), + 'bcc' => $this->getBccs(), + 'subject' => $this->getSubject(), + 'headers' => $this->getHeaders(), + 'substitutions' => $substitutions, + 'dynamic_template_data' => $dynamic_substitutions, + 'custom_args' => $this->getCustomArgs(), + 'send_at' => $this->getSendAt() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/PlainTextContent.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/PlainTextContent.php new file mode 100644 index 0000000..a6acbef --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/PlainTextContent.php @@ -0,0 +1,33 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Content object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class PlainTextContent extends Content +{ + /** + * Create a Content object with a plain text mime type + * + * @param string $value plain text formatted content + */ + public function __construct($value) + { + parent::__construct(MimeType::TEXT, $value); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/ReplyTo.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/ReplyTo.php new file mode 100644 index 0000000..3f4e10d --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/ReplyTo.php @@ -0,0 +1,24 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a ReplyTo object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class ReplyTo extends EmailAddress implements \JsonSerializable +{ +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SandBoxMode.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SandBoxMode.php new file mode 100644 index 0000000..ab7a1fb --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SandBoxMode.php @@ -0,0 +1,80 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a SandBoxMode object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class SandBoxMode implements \JsonSerializable +{ + // @var bool Indicates if this setting is enabled + private $enable; + + /** + * Optional constructor + * + * @param bool|null $enable Indicates if this setting is enabled + */ + public function __construct($enable = null) + { + if (isset($enable)) { + $this->setEnable($enable); + } + } + + /** + * Update the enable setting on a SandBoxMode object + * + * @param bool $enable Indicates if this setting is enabled + * + * @throws TypeException + */ + public function setEnable($enable) + { + if (!is_bool($enable)) { + throw new TypeException('$enable must be of type bool.'); + } + $this->enable = $enable; + } + + /** + * Retrieve the enable setting on a SandBoxMode object + * + * @return bool + */ + public function getEnable() + { + return $this->enable; + } + + /** + * Return an array representing a SandBoxMode object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'enable' => $this->getEnable() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Section.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Section.php new file mode 100644 index 0000000..eb2e246 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Section.php @@ -0,0 +1,115 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Section object for the /mail/send API call + * + * An object of key/value pairs that define block sections of code to be used + * as substitutions + * + * @package SendGrid\Mail + */ +class Section implements \JsonSerializable +{ + /** @var $key string Section key */ + private $key; + /** @var $value string Section value */ + private $value; + + /** + * Optional constructor + * + * @param string|null $key Section key + * @param string|null $value Section value + */ + public function __construct($key = null, $value = null) + { + if (isset($key)) { + $this->setKey($key); + } + if (isset($value)) { + $this->setValue($value); + } + } + + /** + * Add the key on a Section object + * + * @param string $key Section key + * + * @throws TypeException + */ + public function setKey($key) + { + if (!is_string($key)) { + throw new TypeException('$key must be of type string.'); + } + $this->key = $key; + } + + /** + * Retrieve the key from a Section object + * + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Add the value on a Section object + * + * @param string $value Section value + * + * @throws TypeException + */ + public function setValue($value) + { + if (!is_string($value)) { + throw new TypeException('$value must be of type string.'); + } + $this->value = $value; + } + + /** + * Retrieve the value from a Section object + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Return an array representing a Section object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'key' => $this->getKey(), + 'value' => $this->getValue() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SendAt.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SendAt.php new file mode 100644 index 0000000..1dbb3f1 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SendAt.php @@ -0,0 +1,102 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ +namespace SendGrid\Mail; + +/** + * This class is used to construct a SendAt object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class SendAt implements \JsonSerializable +{ + /** + * @var $send_at int A unix timestamp allowing you to specify when you want your email + * to be delivered. This may be overridden by the personalizations[x].send_at + * parameter. You can't schedule more than 72 hours in advance. If you have + * the flexibility, it's better to schedule mail for off-peak times. Most + * emails are scheduled and sent at the top of the hour or half hour. + * Scheduling email to avoid those times (for example, scheduling at 10:53) can + * result in lower deferral rates because it won't be going through our servers + * at the same times as everyone else's mail + */ + + private $send_at; + + /** + * Optional constructor + * + * @param int|null $send_at A unix timestamp allowing you to specify when you + * want your email to be delivered. This may be + * overridden by the personalizations[x].send_at + * parameter. You can't schedule more than 72 hours + * in advance. If you have the flexibility, it's better + * to schedule mail for off-peak times. Most emails are + * scheduled and sent at the top of the hour or half + * hour. Scheduling email to avoid those times (for + * example, scheduling at 10:53) can result in lower + * deferral rates because it won't be going through + * our servers at the same times as everyone else's mail + */ + public function __construct($send_at=null) + { + if (isset($send_at)) { + $this->setSendAt($send_at); + } + } + + /** + * Add the send at value to a SendAt object + * + * @param int $send_at A unix timestamp allowing you to specify when you + * want your email to be delivered. This may be + * overridden by the personalizations[x].send_at + * parameter. You can't schedule more than 72 hours + * in advance. If you have the flexibility, it's better + * to schedule mail for off-peak times. Most emails are + * scheduled and sent at the top of the hour or half + * hour. Scheduling email to avoid those times (for + * example, scheduling at 10:53) can result in lower + * deferral rates because it won't be going through + * our servers at the same times as everyone else's mail + * + * @throws TypeException + */ + public function setSendAt($send_at) + { + if (!is_int($send_at)) { + throw new TypeException('$send_at must be of type int.'); + } + $this->send_at = $send_at; + } + + /** + * Retrieve the send at value from a SendAt object + * + * @return int + */ + public function getSendAt() + { + return $this->send_at; + } + + /** + * Return an array representing a SendAt object for the Twilio SendGrid API + * + * @return int + */ + public function jsonSerialize() + { + return $this->getSendAt(); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SpamCheck.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SpamCheck.php new file mode 100644 index 0000000..4173c77 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SpamCheck.php @@ -0,0 +1,161 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a SpamCheck object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class SpamCheck implements \JsonSerializable +{ + /** @var $enable bool Indicates if this setting is enabled */ + private $enable; + /** + * @var $threshold int The threshold used to determine if your content qualifies as + * spam on a scale from 1 to 10, with 10 being most strict, or most + * likely to be considered as spam + */ + private $threshold; + /** + * @var $post_to_urlstring An Inbound Parse URL that you would like a copy of your + * email along with the spam report to be sent to + */ + private $post_to_url; + + /** + * Optional constructor + * + * @param bool|null $enable Indicates if this setting is enabled + * @param int|null $threshold The threshold used to determine if your + * content qualifies as spam on a scale + * from 1 to 10, with 10 being most strict, + * or most + * @param string|null $post_to_url An Inbound Parse URL that you would like + * a copy of your email along with the spam + * report to be sent to + */ + public function __construct($enable = null, $threshold = null, $post_to_url = null) + { + if (isset($enable)) { + $this->setEnable($enable); + } + if (isset($threshold)) { + $this->setThreshold($threshold); + } + if (isset($post_to_url)) { + $this->setPostToUrl($post_to_url); + } + } + + /** + * Update the enable setting on a SpamCheck object + * + * @param bool $enable Indicates if this setting is enabled + * + * @throws TypeException + */ + public function setEnable($enable) + { + if (!is_bool($enable)) { + throw new TypeException('$enable must be of type bool.'); + } + $this->enable = $enable; + } + + /** + * Retrieve the enable setting on a SpamCheck object + * + * @return bool + */ + public function getEnable() + { + return $this->enable; + } + + /** + * Set the threshold value on a SpamCheck object + * + * @param int $threshold The threshold used to determine if your + * content qualifies as spam on a scale + * from 1 to 10, with 10 being most strict, + * or most + * + * @throws TypeException + */ + public function setThreshold($threshold) + { + if (!is_int($threshold)) { + throw new TypeException('$threshold must be of type int.'); + } + $this->threshold = $threshold; + } + + /** + * Retrieve the threshold value from a SpamCheck object + * + * @return int + */ + public function getThreshold() + { + return $this->threshold; + } + + /** + * Set the post to url value on a SpamCheck object + * + * @param string $post_to_url An Inbound Parse URL that you would like + * a copy of your email along with the spam + * report to be sent to + * + * @throws TypeException + */ + public function setPostToUrl($post_to_url) + { + if (!is_string($post_to_url)) { + throw new TypeException('$post_to_url must be of type string.'); + } + $this->post_to_url = $post_to_url; + } + + /** + * Retrieve the post to url value from a SpamCheck object + * + * @return string + */ + public function getPostToUrl() + { + return $this->post_to_url; + } + + /** + * Return an array representing a SpamCheck object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'enable' => $this->getEnable(), + 'threshold' => $this->getThreshold(), + 'post_to_url' => $this->getPostToUrl() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Subject.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Subject.php new file mode 100644 index 0000000..94b4066 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Subject.php @@ -0,0 +1,74 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Subject object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class Subject implements \JsonSerializable +{ + /** @var $subject string The email subject */ + private $subject; + + /** + * Optional constructor + * + * @param string|null $subject The email subject + */ + public function __construct($subject = null) + { + if (isset($subject)) { + $this->setSubject($subject); + } + } + + /** + * Set the subject on a Subject object + * + * @param string $subject The email subject + * + * @throws TypeException + */ + public function setSubject($subject) + { + if (!is_string($subject)) { + throw new TypeException('$subject must be of type string.'); + } + + $this->subject = $subject; + } + + /** + * Retrieve the subject from a Subject object + * + * @return string + */ + public function getSubject() + { + return mb_convert_encoding($this->subject, 'UTF-8', 'UTF-8'); + } + + /** + * Return an array representing a Subject object for the Twilio SendGrid API + * + * @return string + */ + public function jsonSerialize() + { + return $this->getSubject(); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SubscriptionTracking.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SubscriptionTracking.php new file mode 100644 index 0000000..87fb15a --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/SubscriptionTracking.php @@ -0,0 +1,228 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a SubscriptionTracking object for + * the /mail/send API call + * + * Allows you to insert a subscription management link at the bottom + * of the text and html bodies of your email. If you would like to + * specify the location of the link within your email, you may use + * the substitution_tag + * + * @package SendGrid\Mail + */ +class SubscriptionTracking implements \JsonSerializable +{ + /** @var $enable bool Indicates if this setting is enabled */ + private $enable; + /** + * @var $text string Text to be appended to the email, with the + * subscription tracking link. You may control where the + * link is by using the tag <% %> + */ + private $text; + /** + * @var $htmlstring string to be appended to the email, with the + * subscription tracking link. You may control where the + * link is by using the tag <% %> + */ + private $html; + /** + * @var $substitution_tag string A tag that will be replaced with the + * unsubscribe URL. for example: [unsubscribe_url]. If + * this parameter is used, it will override both the text + * and html parameters. The URL of the link will be placed + * at the substitution tag’s location, with no additional + * formatting + */ + private $substitution_tag; + + /** + * Optional constructor + * + * @param bool|null $enable Indicates if this setting is enabled + * @param string|null $text Text to be appended to the email, with + * the subscription tracking link. You may + * control where the link is by using the + * tag <% %> + * @param string|null $html HTML to be appended to the email, with + * the subscription tracking link. You may + * control where the link is by using the + * tag <% %> + * @param string|null $substitution_tag A tag that will be replaced with the + * unsubscribe URL. For example: + * [unsubscribe_url]. If this parameter + * is used, it will override both the text + * and html parameters. The URL of the link + * will be placed at the substitution tag’s + * location, with no additional formatting + */ + public function __construct( + $enable = null, + $text = null, + $html = null, + $substitution_tag = null + ) { + if (isset($enable)) { + $this->setEnable($enable); + } + if (isset($text)) { + $this->setText($text); + } + if (isset($html)) { + $this->setHtml($html); + } + if (isset($substitution_tag)) { + $this->setSubstitutionTag($substitution_tag); + } + } + + /** + * Update the enable setting on a SubscriptionTracking object + * + * @param bool $enable Indicates if this setting is enabled + * + * @throws TypeException + */ + public function setEnable($enable) + { + if (!is_bool($enable)) { + throw new TypeException('$enable must be of type bool.'); + } + $this->enable = $enable; + } + + /** + * Retrieve the enable setting from a SubscriptionTracking object + * + * @return bool + */ + public function getEnable() + { + return $this->enable; + } + + /** + * Add text to a SubscriptionTracking object + * + * @param string $text Text to be appended to the email, with + * the subscription tracking link. You may + * control where the link is by using the + * tag <% %> + * + * @throws TypeException + */ + public function setText($text) + { + if (!is_string($text)) { + throw new TypeException('$text must be of type string.'); + } + $this->text = $text; + } + + /** + * Retrieve text from a SubscriptionTracking object + * + * @return string + */ + public function getText() + { + return $this->text; + } + + /** + * Add HTML to a SubscriptionTracking object + * + * @param string $html HTML to be appended to the email, with + * the subscription tracking link. You may + * control where the link is by using the + * tag <% %> + * + * @throws TypeException + */ + public function setHtml($html) + { + if (!is_string($html)) { + throw new TypeException('$html must be of type string.'); + } + $this->html = $html; + } + + /** + * Retrieve HTML from a SubscriptionTracking object + * + * @return string + */ + public function getHtml() + { + return $this->html; + } + + /** + * Add a substitution tag to a SubscriptionTracking object + * + * @param string $substitution_tag A tag that will be replaced with the + * unsubscribe URL. for example: + * [unsubscribe_url]. If this parameter + * is used, it will override both the text + * and html parameters. The URL of the link + * will be placed at the substitution tag’s + * location, with no additional formatting %> + * + * @throws TypeException + */ + public function setSubstitutionTag($substitution_tag) + { + if (!is_string($substitution_tag)) { + throw new TypeException( + '$substitution_tag must be of type string.' + ); + } + $this->substitution_tag = $substitution_tag; + } + + /** + * Retrieve a substitution tag from a SubscriptionTracking object + * + * @return string + */ + public function getSubstitutionTag() + { + return $this->substitution_tag; + } + + /** + * Return an array representing a SubscriptionTracking object + * for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'enable' => $this->getEnable(), + 'text' => $this->getText(), + 'html' => $this->getHtml(), + 'substitution_tag' => $this->getSubstitutionTag() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Substitution.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Substitution.php new file mode 100644 index 0000000..c18e080 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/Substitution.php @@ -0,0 +1,120 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a Substitution object for the /mail/send API call + * + * A collection of key/value pairs following the pattern "substitution_tag":"value + * to substitute". All are assumed to be strings. These substitutions will apply + * to the text and html content of the body of your email, in addition to the + * subject and reply-to parameters. The total collective size of your substitutions + * may not exceed 10,000 bytes per personalization object + * + * @package SendGrid\Mail + */ +class Substitution implements \JsonSerializable +{ + /** @var $key string Substitution key */ + private $key; + /** @var $value string Substitution value */ + private $value; + + /** + * Optional constructor + * + * @param string|null $key Substitution key + * @param string|null $value Substitution value + */ + public function __construct($key = null, $value = null) + { + if (isset($key)) { + $this->setKey($key); + } + if (isset($value)) { + $this->setValue($value); + } + } + + /** + * Add the key on a Substitution object + * + * @param string $key Substitution key + * + * @throws TypeException + * @return null + */ + public function setKey($key) + { + if (!is_string($key)) { + throw new TypeException('$key must be of type string.'); + } + $this->key = (string) $key; + } + + /** + * Retrieve the key from a Substitution object + * + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * Add the value on a Substitution object + * + * @param string|array|bool|int $value Substitution value + * + * @throws TypeException + * @return null + */ + public function setValue($value) + { + if (!is_string($value) && !is_array($value) && !is_object($value) &&!is_bool($value) &&!is_int($value)) { + throw new TypeException('$value must be of type string, array or object.'); + } + $this->value = $value; + } + + /** + * Retrieve the value from a Substitution object + * + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * Return an array representing a Substitution object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'key' => $this->getKey(), + 'value' => $this->getValue() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TemplateId.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TemplateId.php new file mode 100644 index 0000000..890de3f --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TemplateId.php @@ -0,0 +1,86 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a TemplateId object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class TemplateId implements \JsonSerializable +{ + /** + * @var $template_id string The id of a template that you would like to use. If you use a + * template that contains a subject and content (either text or html), you do + * not need to specify those at the personalizations nor message level + */ + private $template_id; + + /** + * Optional constructor + * + * @param string|null $template_id The id of a template that you would like + * to use. If you use a template that contains + * a subject and content (either text or html), + * you do not need to specify those at the + * personalizations nor message level + */ + public function __construct($template_id = null) + { + if (isset($template_id)) { + $this->setTemplateId($template_id); + } + } + + /** + * Add a template id to a TemplateId object + * + * @param string $template_id The id of a template that you would like + * to use. If you use a template that contains + * a subject and content (either text or html), + * you do not need to specify those at the + * personalizations nor message level + * + * @throws TypeException + */ + public function setTemplateId($template_id) + { + if (!is_string($template_id)) { + throw new TypeException('$template_id must be of type string.'); + } + + $this->template_id = $template_id; + } + + /** + * Retrieve a template id from a TemplateId object + * + * @return string + */ + public function getTemplateId() + { + return $this->template_id; + } + + /** + * Return an array representing a TemplateId object for the Twilio SendGrid API + * + * @return string + */ + public function jsonSerialize() + { + return $this->getTemplateId(); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/To.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/To.php new file mode 100644 index 0000000..d9e3537 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/To.php @@ -0,0 +1,24 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a To object for the /mail/send API call + * + * @package SendGrid\Mail + */ +class To extends EmailAddress implements \JsonSerializable +{ +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TrackingSettings.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TrackingSettings.php new file mode 100644 index 0000000..271ec06 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TrackingSettings.php @@ -0,0 +1,252 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Mail; + +/** + * This class is used to construct a TrackingSettings object for the + * /mail/send API call + * + * @package SendGrid\Mail + */ +class TrackingSettings implements \JsonSerializable +{ + /** @var $click_tracking ClickTracking object */ + private $click_tracking; + /** @var $open_tracking OpenTracking object */ + private $open_tracking; + /** @var $subscription_tracking SubscriptionTracking object */ + private $subscription_tracking; + /** @var $ganalytics Ganalytics object */ + private $ganalytics; + + /** + * Optional constructor + * + * @param ClickTracking|null $click_tracking ClickTracking object + * @param OpenTracking|null $open_tracking OpenTracking object + * @param SubscriptionTracking|null $subscription_tracking SubscriptionTracking + * object + * @param Ganalytics|null $ganalytics Ganalytics object + */ + public function __construct( + $click_tracking = null, + $open_tracking = null, + $subscription_tracking = null, + $ganalytics = null + ) + { + if (isset($click_tracking)) { + $this->setClickTracking($click_tracking); + } + if (isset($open_tracking)) { + $this->setOpenTracking($open_tracking); + } + if (isset($subscription_tracking)) { + $this->setSubscriptionTracking($subscription_tracking); + } + if (isset($ganalytics)) { + $this->setGanalytics($ganalytics); + } + } + + /** + * Set the click tracking settings on a TrackingSettings object + * + * @param ClickTracking|bool $enable The ClickTracking object or an + * indication if the setting is enabled + * @param bool|null $enable_text Indicates if this setting should be + * included in the text/plain portion of + * your email + */ + public function setClickTracking($enable, $enable_text = null) + { + if ($enable instanceof ClickTracking) { + $click_tracking = $enable; + $this->click_tracking = $click_tracking; + return; + } + $this->click_tracking = new ClickTracking($enable, $enable_text); + } + + /** + * Retrieve the click tracking settings from a TrackingSettings object + * + * @return ClickTracking + */ + public function getClickTracking() + { + return $this->click_tracking; + } + + /** + * Set the open tracking settings on a TrackingSettings object + * + * @param OpenTracking|bool $enable The ClickTracking object or an + * indication if the setting is + * enabled + * @param string|null $substitution_tag Allows you to specify a + * substitution tag that you can + * insert in the body of your email + * at a location that you desire. + * This tag will be replaced by + * the open tracking pixelail + * + * @return null + */ + public function setOpenTracking($enable, $substitution_tag = null) + { + if ($enable instanceof OpenTracking) { + $open_tracking = $enable; + $this->open_tracking = $open_tracking; + return; + } + $this->open_tracking = new OpenTracking($enable, $substitution_tag); + return; + } + + /** + * Retrieve the open tracking settings on a TrackingSettings object + * + * @return OpenTracking + */ + public function getOpenTracking() + { + return $this->open_tracking; + } + + /** + * Set the subscription tracking settings on a TrackingSettings object + * + * @param SubscriptionTracking|bool $enable The SubscriptionTracking + * object or an indication + * if the setting is enabled + * @param string|null $text Text to be appended to the + * email, with the + * subscription tracking + * link. You may control + * where the link is by using + * the tag <% %> + * @param string|null $html HTML to be appended to the + * email, with the + * subscription tracking + * link. You may control + * where the link is by using + * the tag <% %> + * @param string|null $substitution_tag A tag that will be + * replaced with the + * unsubscribe URL. For + * example: + * [unsubscribe_url]. If this + * parameter is used, it will + * override both the text + * and html parameters. The + * URL of the link will be + * placed at the substitution + * tag’s location, with no + * additional formatting + */ + public function setSubscriptionTracking( + $enable, + $text = null, + $html = null, + $substitution_tag = null + ) { + if ($enable instanceof SubscriptionTracking) { + $subscription_tracking = $enable; + $this->subscription_tracking = $subscription_tracking; + return; + } + $this->subscription_tracking + = new SubscriptionTracking($enable, $text, $html, $substitution_tag); + } + + /** + * Retrieve the subscription tracking settings from a TrackingSettings object + * + * @return SubscriptionTracking + */ + public function getSubscriptionTracking() + { + return $this->subscription_tracking; + } + + /** + * Set the Google analytics settings on a TrackingSettings object + * + * @param Ganalytics|bool $enable The Ganalytics object or an indication + * if the setting is enabled + * @param string|null $utm_source Name of the referrer source. (e.g. + * Google, SomeDomain.com, or + * Marketing Email) + * @param string|null $utm_medium Name of the marketing medium. (e.g. + * Email) + * @param string|null $utm_term Used to identify any paid keywords + * @param string|null $utm_content Used to differentiate your campaign from + * advertisements + * @param string|null $utm_campaign The name of the campaign + */ + public function setGanalytics( + $enable, + $utm_source = null, + $utm_medium = null, + $utm_term = null, + $utm_content = null, + $utm_campaign = null + ) { + if ($enable instanceof Ganalytics) { + $ganalytics = $enable; + $this->ganalytics = $ganalytics; + return; + } + $this->ganalytics = new Ganalytics( + $enable, + $utm_source, + $utm_medium, + $utm_term, + $utm_content, + $utm_campaign + ); + } + + /** + * Retrieve the Google analytics settings from a TrackingSettings object + * + * @return Ganalytics + */ + public function getGanalytics() + { + return $this->ganalytics; + } + + /** + * Return an array representing a TrackingSettings object for the Twilio SendGrid API + * + * @return null|array + */ + public function jsonSerialize() + { + return array_filter( + [ + 'click_tracking' => $this->getClickTracking(), + 'open_tracking' => $this->getOpenTracking(), + 'subscription_tracking' => $this->getSubscriptionTracking(), + 'ganalytics' => $this->getGanalytics() + ], + function ($value) { + return $value !== null; + } + ) ?: null; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TypeException.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TypeException.php new file mode 100644 index 0000000..980b60f --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/TypeException.php @@ -0,0 +1,7 @@ + + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: + * @link http://packagist.org/packages/sendgrid/sendgrid + */ +namespace SendGrid\Stats; + +/** + * This class is used to retrieve stats from a /mail/send API call + * + * @package SendGrid\Mail + */ +class Stats +{ + const DATE_FORMAT = 'Y-m-d'; + const OPTIONS_SORT_DIRECTION = ['asc', 'desc']; + const OPTIONS_AGGREGATED_BY = ['day', 'week', 'month']; + + // @var string + private $startDate; + + // @var string + private $endDate; + + // @var string + private $aggregatedBy; + + /** + * Stats constructor + * + * @param string $startDate YYYYMMDD + * @param string $endDate YYYYMMDD + * @param string $aggregatedBy day|week|month + */ + public function __construct($startDate, $endDate = null, $aggregatedBy = null) + { + $this->validateDateFormat($startDate); + if (null !== $endDate) { + $this->validateDateFormat($endDate); + } + if (null !== $aggregatedBy) { + $this->validateOptions( + 'aggregatedBy', + $aggregatedBy, + self::OPTIONS_AGGREGATED_BY + ); + } + $this->startDate = $startDate; + $this->endDate = $endDate; + $this->aggregatedBy = $aggregatedBy; + } + + /** + * Retrieve global stats parameters, start date, end date and + * aggregated by + * + * @return array + */ + public function getGlobal() + { + return [ + 'start_date' => $this->startDate, + 'end_date' => $this->endDate, + 'aggregated_by' => $this->aggregatedBy + ]; + } + + /** + * Retrieve an array of categories + * + * @param array $categories + * + * @return array + * @throws \Exception + */ + public function getCategory($categories) + { + $this->validateNumericArray('categories', $categories); + $stats = $this->getGlobal(); + $stats['categories'] = $categories; + return $stats; + } + + /** + * Retrieve global stats parameters, start date, end date and + * aggregated for the given set of subusers + * + * @param array $subusers Subuser accounts + * + * @return array + * @throws \Exception + */ + public function getSubuser($subusers) + { + $this->validateNumericArray('subusers', $subusers); + $stats = $this->getGlobal(); + $stats['subusers'] = $subusers; + return $stats; + } + + /** + * Retrieve global stats parameters, start date, end date, + * aggregated by, sort by metric, sort by direction, limit + * and offset + * + * @param string $sortByMetric blocks|bounce_drops|bounces| + * clicks|deferred|delivered| + * invalid_emails|opens|processed| + * requests|spam_report_drops| + * spam_reports|unique_clicks| + * unique_opens|unsubscribe_drops| + * unsubsribes + * @param string $sortByDirection asc|desc + * @param integer $limit The number of results to return + * @param integer $offset The point in the list to begin + * retrieving results + * + * @return array + * @throws \Exception + */ + public function getSum( + $sortByMetric = 'delivered', + $sortByDirection = 'desc', + $limit = 5, $offset = 0 + ) { + $this->validateOptions( + 'sortByDirection', + $sortByDirection, + self::OPTIONS_SORT_DIRECTION + ); + $this->validateInteger('limit', $limit); + $this->validateInteger('offset', $offset); + $stats = $this->getGlobal(); + $stats['sort_by_metric'] = $sortByMetric; + $stats['sort_by_direction'] = $sortByDirection; + $stats['limit'] = $limit; + $stats['offset'] = $offset; + return $stats; + } + + /** + * Retrieve monthly stats by subuser + * + * @param string $subuser Subuser account + * @param string $sortByMetric blocks|bounce_drops|bounces| + * clicks|deferred|delivered| + * invalid_emails|opens|processed| + * requests|spam_report_drops| + * spam_reports|unique_clicks| + * unique_opens|unsubscribe_drops| + * unsubsribes + * @param string $sortByDirection asc|desc + * @param integer $limit The number of results to return + * @param integer $offset The point in the list to begin + * retrieving results + * + * @return array + * @throws \Exception + */ + public function getSubuserMonthly( + $subuser = null, + $sortByMetric = 'delivered', + $sortByDirection = 'desc', + $limit = 5, + $offset = 0 + ) { + $this->validateOptions( + 'sortByDirection', + $sortByDirection, + self::OPTIONS_SORT_DIRECTION + ); + $this->validateInteger('limit', $limit); + $this->validateInteger('offset', $offset); + return [ + 'date' => $this->startDate, + 'subuser' => $subuser, + 'sort_by_metric' => $sortByMetric, + 'sort_by_direction' => $sortByDirection, + 'limit' => $limit, + 'offset' => $offset + ]; + } + + /** + * Validate the date format + * + * @param string $date YYYY-MM-DD + * + * @return null + * @throws \Exception + */ + protected function validateDateFormat($date) + { + if (false === \DateTime::createFromFormat(self::DATE_FORMAT, $date)) { + throw new \Exception('Date must be in the YYYY-MM-DD format.'); + } + } + + /** + * Validate options + * + * @param string $name Name of option + * @param string $value Value of option + * @param array $options Array of options + * + * @return null + * @throws \Exception + */ + protected function validateOptions($name, $value, $options) + { + if (!in_array($value, $options)) { + throw new \Exception( + $name . ' must be one of: ' . implode(', ', $options) + ); + } + } + + /** + * Validate integer + * + * @param string $name Name as a string + * @param integer $value Value as an integer + * + * @return null + * @throws \Exception + */ + protected function validateInteger($name, $value) + { + if (!is_integer($value)) { + throw new \Exception($name . ' must be an integer.'); + } + } + + /** + * Validate a numeric array + * + * @param string $name Name as a string + * @param array $value Value as an array of integers + * + * @return null + * @throws \Exception + */ + protected function validateNumericArray($name, $value) + { + if (!is_array($value) || empty($value) || !$this->isNumeric($value)) { + throw new \Exception($name . ' must be a non-empty numeric array.'); + } + } + + /** + * Determine if the array is numeric + * + * @param array $array Array of values + * + * @return bool + */ + protected function isNumeric(array $array) + { + return array_keys($array) == range(0, count($array) - 1); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/phpcs.xml b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/phpcs.xml new file mode 100644 index 0000000..f646392 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/phpcs.xml @@ -0,0 +1,196 @@ + + + The PSR-2 coding standard. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + 0 + + + 0 + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3