diff options
121 files changed, 13141 insertions, 7110 deletions
diff --git a/Postman/Phpmailer/PostsmtpMailer.php b/Postman/Phpmailer/PostsmtpMailer.php new file mode 100644 index 0000000..9eee0a7 --- /dev/null +++ b/Postman/Phpmailer/PostsmtpMailer.php @@ -0,0 +1,122 @@ +<?php +require_once ABSPATH . WPINC . '/class-phpmailer.php'; +require_once ABSPATH . WPINC . '/class-smtp.php'; + +add_action('plugins_loaded', function() { + global $phpmailer; + + $phpmailer = new PostsmtpMailer(true); +}); + +class PostsmtpMailer extends PHPMailer { + + private $options; + + private $error; + + public function __construct($exceptions = null) + { + parent::__construct($exceptions); + + $this->options = PostmanOptions::getInstance(); + add_filter( 'postman_wp_mail_result', [ $this, 'postman_wp_mail_result' ] ); + } + + public function send() + { + require_once dirname(__DIR__) . '/PostmanWpMail.php'; + + // create a PostmanWpMail instance + $postmanWpMail = new PostmanWpMail(); + $postmanWpMail->init(); + + $senderEmail = $this->options->getMessageSenderEmail(); + $senderName = $this->options->getMessageSenderName(); + + // create a PostmanMessage instance + $message = $postmanWpMail->createNewMessage(); + + $message->setFrom( $senderEmail, $senderName ); + $message->addHeaders( $this->getHeaders() ); + $message->setBodyTextPart( $this->AltBody ); + $message->setBodyHtmlPart( $this->Body ); + $message->setBody( $this->Body ); + $message->setSubject( $this->Subject ); + $message->addTo( $this->flatArray($this->getToAddresses() ) ); + $message->setReplyTo( $this->flatArray( $this->getReplyToAddresses() ) ); + $message->addCc( $this->flatArray($this->getCcAddresses() ) ); + $message->addBCc( $this->flatArray( $this->getBccAddresses() ) ); + $message->setReplyTo( $this->flatArray( $this->getReplyToAddresses() ) ); + $message->setAttachments( $this->getAttachments() ); + + // create a PostmanEmailLog instance + $log = new PostmanEmailLog(); + + $log->originalTo = $this->flatArray($this->getToAddresses() ); + $log->originalSubject = $this->Subject; + $log->originalMessage = $this->Body; + $log->originalHeaders = $this->getCustomHeaders(); + + try { + return $postmanWpMail->sendMessage( $message, $log ); + } catch (phpmailerException $exc) { + + $this->error = $exc; + + $this->mailHeader = ''; + $this->setError($exc->getMessage()); + if ($this->exceptions) { + throw $exc; + } + return false; + } + + } + + public function getAttachments() { + $attachments = parent::getAttachments(); + + $data = array(); + foreach ( $attachments as $attachment ) { + $data[] = $attachment[0]; + } + + return $data; + } + + private function getHeaders() { + $headers = array(); + foreach ( $this->getCustomHeaders() as $header ) { + $headers[] = "{$header[0]}: {$header[1]}"; + } + + return $headers; + } + + public function postman_wp_mail_result() { + $result = [ + 'time' => '', + 'exception' => $this->error, + 'transcript' => '', + ]; + return $result; + } + + private function flatArray($arr) { + $result = []; + foreach ( $arr as $key => $value ) { + if ( is_array( $value ) ) { + foreach ($value as $k => $v ) { + if ( empty( $v ) ) { + continue; + } + $value = $v; + } + } + + $result[] = $value; + } + + return implode(',', $result ); + } +}
\ No newline at end of file diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.codeclimate.yml b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.codeclimate.yml new file mode 100644 index 0000000..0bd0385 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/.codeclimate.yml @@ -0,0 +1,18 @@ +engines: + duplication: + enabled: true + config: + languages: + - "php" + phpcodesniffer: + enabled: true + config: + file_extensions: "php" + standard: "PSR1,PSR2" +ratings: + paths: + - "**.php" +exclude_paths: + - "examples/**/*" + - "test/**/*" + - "vendor/**/*"
\ No newline at end of file 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 @@ +<!-- +We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines given above, then fill out the blanks below. + + +Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! +e.g. +Fixes #1 +Closes #2 +--> +# 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/CHANGELOG.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/CHANGELOG.md deleted file mode 100644 index dd0c13d..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/php-http-client/CHANGELOG.md +++ /dev/null @@ -1,130 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -This project adheres to [Semantic Versioning](http://semver.org/). - -## [3.9.6] - 2018-04-10 -### Added -- PR [#98](https://github.com/sendgrid/php-http-client/pull/98). Updated documention of `Client.php` using PHPDoc. -- Thanks to [Martijn Melchers](https://github.com/martijnmelchers) for the pull request! - -## [3.9.5] - 2018-03-26 -### Added -- Fixes [#94](https://github.com/sendgrid/php-http-client/issues/94), PR [#95](https://github.com/sendgrid/php-http-client/pull/95): CreateCurlOptions method regression tests -- Thanks to [Alexandr Ivanov](https://github.com/misantron) for the pull request! - -## [3.9.4] - 2018-03-22 -### Fixed -- Fixes [#586](https://github.com/sendgrid/sendgrid-php/issues/586), PR [#96](https://github.com/sendgrid/php-http-client/pull/96): Fix constructor function signature regression. - -## [3.9.3] - 2018-03-11 -### Fixed -- Fixes [#584](https://github.com/sendgrid/sendgrid-php/issues/584), PR [#93](https://github.com/sendgrid/php-http-client/pull/93): Don't overwrite headers set from upstream dependencies. - -## [3.9.2] - 2018-03-10 -### Fixed -- Fixes [#12](https://github.com/sendgrid/php-http-client/issues/12), PR [#91](https://github.com/sendgrid/php-http-client/pull/91): Curl Options broken as array merge does not preserve keys. - -## [3.9.1] - 2018-03-09 -### Fixed -- Fixes [#88](https://github.com/sendgrid/php-http-client/issues/88), PR [#89](https://github.com/sendgrid/php-http-client/pull/89): Restore missing function 'prepareResponse' due to bad previous merge. - -## [3.9.0] - 2018-03-08 -### Added -- PR [#24](https://github.com/sendgrid/php-http-client/pull/24): implements sending concurrent requests with curl multi, thanks to [Tuan Nguyen](https://github.com/lightbringer1991) for the PR! -- PR [#25](https://github.com/sendgrid/php-http-client/pull/25): Add description how install php-http-client manually, thanks to [Ivan](https://github.com/janczer) for the PR! -- PR [#28](https://github.com/sendgrid/php-http-client/pull/28): Create code of conduct, thanks to [Alexander Androsyuk](https://github.com/alex2sat) for the PR! -- Closes [#32](https://github.com/sendgrid/php-http-client/issues/32), PR [#33](https://github.com/sendgrid/php-http-client/pull/33): Added TROUBLESHOOTING + Debug Info, thanks to [Braunson Yager](https://github.com/Braunson) for the PR! -- Closes [#35](https://github.com/sendgrid/php-http-client/issues/35), PR [#37](https://github.com/sendgrid/php-http-client/pull/37): Update README badges, thanks to [Tim Harshman](https://github.com/goteamtim) for the PR! -- Closes [#34](https://github.com/sendgrid/php-http-client/issues/34), PR [#38](https://github.com/sendgrid/php-http-client/pull/38): Update .md files with hyphen vs underscore for page links to enhance SEO, thanks to [Eric Kates](https://github.com/positronek) for the PR! -- Closes [#39](https://github.com/sendgrid/php-http-client/issues/39), PR [#40](https://github.com/sendgrid/php-http-client/pull/40): Added Packagist badge to README, thanks to [Rakshan Shetty](https://github.com/rakshans1) for the PR! -- PR [#41](https://github.com/sendgrid/php-http-client/pull/41): Add table of contents in README.md, thanks to [thepriefy](https://github.com/thepriefy) for the PR! -- PR [#42](https://github.com/sendgrid/php-http-client/pull/42): Add SendGrid logo at the top of README.md, thanks to [thepriefy](https://github.com/thepriefy) for the PR! -- PR [#43](https://github.com/sendgrid/php-http-client/pull/43): Add License section to the README.md, thanks to [thepriefy](https://github.com/thepriefy) for the PR! -- Closes [#46](https://github.com/sendgrid/php-http-client/issues/46), PR [#47](https://github.com/sendgrid/php-http-client/pull/47): Create Pull Request Template, thanks to [Paweł Lewtak](https://github.com/pawel-lewtak) for the PR! -- Closes [#48](https://github.com/sendgrid/php-http-client/issues/48), PR [#51](https://github.com/sendgrid/php-http-client/pull/51): Added example file, updated .gitignore and README, thanks to [Diego Rocha](https://github.com/dhsrocha) for the PR! -- PR [#53](https://github.com/sendgrid/php-http-client/pull/53): README and usage example update, thanks to [Alexandr Ivanov](https://github.com/misantron) for the PR! -- PR [#55](https://github.com/sendgrid/php-http-client/pull/55): Code climate config, thanks to [Alexandr Ivanov](https://github.com/misantron) for the PR! -- Closes [#58](https://github.com/sendgrid/php-http-client/pull/58), PR [#60](https://github.com/sendgrid/php-http-client/pull/60): Adds unit test for checking file existence in repo, thanks to [Michele Orselli](https://github.com/micheleorselli) for the PR! -- Closes [#57](https://github.com/sendgrid/php-http-client/pull/57), PR [#61](https://github.com/sendgrid/php-http-client/pull/61): Adds unit test for checking year on licence, thanks to [Michele Orselli](https://github.com/micheleorselli) for the PR! -- Closes [#50](https://github.com/sendgrid/php-http-client/issues/50), PR [#62](https://github.com/sendgrid/php-http-client/pull/62): Create USAGE.md, thanks to [Nitanshu](https://github.com/nvzard) for the PR! -- Closes [#57](https://github.com/sendgrid/php-http-client/issues/57), PR [#66](https://github.com/sendgrid/php-http-client/pull/66): Add unit test for license year, thanks to [Alex](https://github.com/pushkyn) for the PR! -- Closes [#67](https://github.com/sendgrid/php-http-client/issues/67), PR [#68](https://github.com/sendgrid/php-http-client/pull/68): Add CodeCov support to .travis.yml, thanks to [Manjiri Tapaswi](https://github.com/mptap) for the PR! -- Closes [#49](https://github.com/sendgrid/php-http-client/issues/49), PR [#73](https://github.com/sendgrid/php-http-client/pull/73): Create Dockerfile, thanks to [Jessica Mauerhan](https://github.com/jmauerhan) for the PR! -- Closes [#76](https://github.com/sendgrid/php-http-client/issues/76), PR [#78](https://github.com/sendgrid/php-http-client/pull/78): Added Pull Requests Review section to CONTRIBUTE.md Closes, thanks to [Povilas Balzaravičius](https://github.com/Pawka) for the PR! -- Closes [#63](https://github.com/sendgrid/php-http-client/issues/63), PR [#79](https://github.com/sendgrid/php-http-client/pull/79): Refactor makeRequest method, thanks to [Michael Dennis](https://github.com/michaeljdennis) for the PR! -- PR [#82](https://github.com/sendgrid/php-http-client/pull/82): Add JsonSerializable type to phpDoc of $body parameter in makeRequest method, thanks to [Jan Konáš](https://github.com/jankonas) for the PR! -- PR [#85](https://github.com/sendgrid/php-http-client/pull/85): Updated the PHP Version details, thanks to [Siddhant Sharma](https://github.com/ssiddhantsharma) for the PR! -- PR [#86](https://github.com/sendgrid/php-http-client/pull/86): Add phpdoc for send method, thanks to [Vitaliy Ryaboy](https://github.com/rvitaliy) for the PR! -- PR [#84](https://github.com/sendgrid/php-http-client/pull/84): Update Docker instructions - - -### Fixed -- PR [#26](https://github.com/sendgrid/php-http-client/pull/26): README typo, thanks to [Cícero Pablo](https://github.com/ciceropablo) for the PR! -- PR [#30](https://github.com/sendgrid/php-http-client/pull/30), Fixes [#18](https://github.com/sendgrid/php-http-client/issues/18): Disable CURLOPT_FAILONERROR, thanks to [Zsolt Prontvai](https://github.com/ProZsolt) for the PR! -- PR [#44](https://github.com/sendgrid/php-http-client/pull/44): Fix Typo and add missing links to README, thanks to [Alex](https://github.com/pushkyn) for the PR! -- PR [#52](https://github.com/sendgrid/php-http-client/pull/52): Fix syntax errors in README examples, thanks to [Michael Spiss](https://github.com/michaelspiss) for the PR! -- Fixes [#56](https://github.com/sendgrid/php-http-client/pull/56), PR [#59](https://github.com/sendgrid/php-http-client/pull/59): Update LICENSE - fix year, thanks to [Alex](https://github.com/pushkyn) for the PR! -- PR [#69](https://github.com/sendgrid/php-http-client/pull/69): Remove extra parenthesis from README, thanks to [Jessica Mauerhan](https://github.com/jmauerhan) for the PR! -- PR [#71](https://github.com/sendgrid/php-http-client/pull/71): Fix typo in CONTRIBUTING.md, thanks to [thepriefy](https://github.com/thepriefy) for the PR! -- Fixes [#81](https://github.com/sendgrid/php-http-client/issues/81), PR [#87](https://github.com/sendgrid/php-http-client/pull/87): Stop using insecure option by default - -## [3.8.0] - 2017-09-13 -### Added -- Pull request #23: [Automatically retry when rate limit is reached](https://github.com/sendgrid/php-http-client/pull/23) -- Thanks to [Budi Chandra](https://github.com/budirec) for the pull request! - -## [3.7.0] - 2017-05-04 -### Added -- Pull request #19: [Added ability to get headers as associative array](https://github.com/sendgrid/php-http-client/pull/19) -- Solves issue #361: [https://github.com/sendgrid/sendgrid-php/issues/361](https://github.com/sendgrid/sendgrid-php/issues/361) -- Thanks to [Alexander](https://github.com/mazanax) for the pull request! - -## [3.6.0] - 2017-03-01 -### Added -- Pull request #16: [Pass the curlOptions to the client in buildClient](https://github.com/sendgrid/php-http-client/pull/16) -- Thanks to [Baptiste Clavié](https://github.com/Taluu) for the pull request! - -## [3.5.1] - 2016-11-17 -### Fixed -- Pull request #13, fixed issue #12: [Change from to php union operator to combine curl options](https://github.com/sendgrid/php-http-client/pull/13) -- Thanks to [emil](https://github.com/emilva) for the pull request! - -## [3.5.0] - 2016-10-18 -### Added -- Pull request #11: [Added curlOptions property to customize curl instance](https://github.com/sendgrid/php-http-client/pull/11) -- Thanks to [Alain Tiemblo](https://github.com/ninsuo) for the pull request! - -## [3.4.0] - 2016-09-27 -### Added -- Pull request #9: [Add getters for certain properties](https://github.com/sendgrid/php-http-client/pull/9) -- Thanks to [Arjan Keeman](https://github.com/akeeman) for the pull request! - -## [3.3.0] - 2016-09-13 -### Added -- Pull request #6: [Library refactoring around PSR-2 / PSR-4 code standards](https://github.com/sendgrid/php-http-client/pull/6) -- Thanks to [Alexandr Ivanov](https://github.com/misantron) for the pull request! - -## [3.1.0] - 2016-06-10 -### Added -- Automatically add Content-Type: application/json when there is a request body - -## [3.0.0] - 2016-06-06 -### Changed -- Made the Request and Response variables non-redundant. e.g. request.requestBody becomes request.body - -## [2.0.2] - 2016-02-29 -### Fixed -- Renaming files to conform to PSR-0, git ignored the case in 2.0.1 - -## [2.0.1] - 2016-02-29 -### Fixed -- Renaming files to conform to PSR-0 - -## [1.0.1] - 2016-02-29 -### Fixed -- Composer/Packagist install issues resolved - -## [1.0.0] - 2016-02-29 -### Added -- We are live! 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/.codeclimate.yml b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.codeclimate.yml new file mode 100644 index 0000000..bd9c6ec --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.codeclimate.yml @@ -0,0 +1,11 @@ +--- +engines: + duplication: + enabled: true + config: + languages: + - php + fixme: + enabled: true + phpmd: + enabled: true diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.env.sample b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.env.sample new file mode 100644 index 0000000..937e999 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/.env.sample @@ -0,0 +1 @@ +export SENDGRID_API_KEY='' 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 @@ +<!-- +We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines given above, then fill out the blanks below. + +**All third party contributors acknowledge that any contributions they provide will be made under the same open source license that the open source project is provided under.** + +Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! +e.g. +Fixes #1 +Closes #2 +--> +# 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/CHANGELOG.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CHANGELOG.md deleted file mode 100644 index dd55517..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CHANGELOG.md +++ /dev/null @@ -1,207 +0,0 @@ -# Change Log -All notable changes to this project will be documented in this file. - -This project adheres to [Semantic Versioning](http://semver.org/). - -## [6.0.0] - 2017-06-30 ## -### BREAKING CHANGE -- PR #408: Update Mail constructor to signify which parameters are required for sending all email -- The `Mail()` constructor now requires `$from`, `$subject`, `$to` and `$content` parameters like so: `Mail($from, $subject, $to, $content)`. Those are the minimaly required paramaters to send an email. -- Thanks to [Casey Wilson](https://github.com/caseyw) for the PR! - -## [5.6.2] - 2017-06-29 ## -### Fix -- PR #410: Adding name for ReplyTo for issue #390 -- Thanks to [Casey Wilson](https://github.com/caseyw) for the PR! - -## [5.6.1] - 2017-06-26 ## -### Fix -- Versioning mistake (forgot the .0 at the end) - -## [5.6.0] - 2017-06-26 ## -### Added -- Pull #405: Updating docs and non-composer includes -- Thanks to [Casey Wilson](https://github.com/caseyw) for the PR! - -## [5.5.1] - 2017-05-18 ## -### Fixed -- Pull #396: Use `print_r` instead of `echo` on Arrays -- Thanks to [Ryan P.C. McQuen](https://github.com/ryanpcmcquen) for the PR! - -## [5.5.0] - 2017-05-04 ## -### Added -- Pull #393: Update [php-http-client](https://github.com/sendgrid/php-http-client) dependency -- [v3.6](https://github.com/sendgrid/php-http-client/releases/tag/v3.6.0): Pass the curlOptions to the client in buildClient -- [v3.7](https://github.com/sendgrid/php-http-client/releases/tag/v3.7.0): Added ability to get headers as associative array - -## [5.4.2] - 2017-04-18 ## -### Fixes -- Fixes #292 -- Removes Prism file in sendgrid-php.zip - -## [5.4.1] - 2017-04-04 ## -### Added -- Pull #373 -- PSR1 & PSR2 Conversion -- Thanks to [Braunson Yager](https://github.com/Braunson) for the PR! - -## [5.4.0] - 2017-03-16 ## -### Added -- Pull #337 -- API level addressing of the string-only custom arg rule -- Thanks to [Chris Schuld](https://github.com/cbschuld) for the PR! - -## [5.3.0] - 2017-03-15 ## -### Added -- Pull #367 -- UTF8 encoding forced for content value and message subject -- Thanks to [Chris Schuld](https://github.com/cbschuld) for the PR! - -## [5.2.3] - 2017-03-03 ## -### Fixed -- Pull #334 -- Fixed serialization of empty JSON objects, fixes #332 & #314 -- Thanks to [Matthew Dreyer](https://github.com/Dreyer) for the PR! - -## [5.2.2] - 2017-03-03 ## -### Fixed -- Pull #323 -- Typo 'user' for 'usr' -- Thanks to [Mike Ralphson](https://github.com/MikeRalphson) for the PR! - -## [5.2.1] - 2017-03-01 ## -### Fixed -- Pull #353 -- Fixed Issue #352 -- Relative path fix for background jobs -- Thanks to [Tarcísio Zotelli Ferraz](https://github.com/tarcisiozf) for the PR! - -## [5.2.0] - 2017-02-23 ## -### Added -- Pull #346 -- Allow passing curlOptions to the client -- Thanks to [Taluu](https://github.com/sendgrid/sendgrid-php/pull/346) for the PR! - -## [5.1.2] - 2016-10-11 ## -### Added -- Pull #330, Fixes #320 -- Delete subaccounts returns 200 issue resolved -- The fix happened at the [php-http-client](https://github.com/sendgrid/php-http-client/releases/tag/v3.5.1) dependency. -- Thanks to [emil](https://github.com/emilva) for the PR! - -## [5.1.1] - 2016-10-11 ## -### Added -- Pull #307, Fixes #276 -- Adds phpdoc and style fixes -- Thanks to [Avishkar Autar](https://github.com/aautar) for the PR! - -## [5.1.0] - 2016-09-29 ## -### Fixed -- Pull #295: [Upgrade sendgrid/php-http-client](https://github.com/sendgrid/sendgrid-php/pull/295/files) -- This adds getters for certain properties, please see [this pull request](https://github.com/sendgrid/php-http-client/pull/9) for details -- Thanks to [Arjan Keeman](https://github.com/akeeman) for the pull request! - -## [5.0.9] - 2016-09-13 ## -### Fixed -- Pull request #289: [Replace "\jsonSerializable" with "\JsonSerializable" ](https://github.com/sendgrid/sendgrid-php/pull/289) -- Thanks to [Issei.M](https://github.com/issei-m) for the pull request! - -## [5.0.8] - 2016-08-24 ## -### Added -- Table of Contents in the README -- Added a [USE_CASES.md](https://github.com/sendgrid/sendgrid-php/blob/master/USE_CASES.md) section, with the first use case example for transactional templates - -## [5.0.7] - 2016-07-25 ## -### Added -- [Troubleshooting](https://github.com/sendgrid/sendgrid-php/blob/master/TROUBLESHOOTING.md) section - -## [5.0.6] - 2016-07-20 ## -### Added -- README updates -- Update introduction blurb to include information regarding our forward path -- Update the v3 /mail/send example to include non-helper usage -- Update the generic v3 example to include non-fluent interface usage - -## [5.0.5] - 2016-07-12 ## -### Added -- Update docs, unit tests and examples to include Sender ID - -## [5.0.4] - 2016-07-07 ## -### Added -- Tests now mocked automatically against [prism](https://stoplight.io/prism/) - -## [5.0.3] - 2016-07-05 ## -### Updated -- Content based on our updated [Swagger/OAI doc](https://github.com/sendgrid/sendgrid-oai) - -## [5.0.2] - 2016-07-05 ## -### Added -- Accept: application/json header per https://sendgrid.com/docs/API_Reference/Web_API_v3/How_To_Use_The_Web_API_v3/requests.html - -### Updated -- Content based on our updated [Swagger/OAI doc](https://github.com/sendgrid/sendgrid-oai) - -## [5.0.1] - 2016-06-17 ## -### Fixed -- Issue with packaged version for non-composer uses - -## [5.0.0] - 2016-06-13 ## -### Added -- Breaking change to support the v3 Web API -- New HTTP client -- v3 Mail Send helper - -## [v4.0.4] - (2016-02-18) ## -### Added -- Ability to add scopes to API Keys endpoint [POST] - -## [v4.0.3] - (2016-02-18) ## -### Added -- API Keys endpoint [PUT] - -## [v4.0.2] - (2015-12-15) ## -### Added -- Tests for API Keys endpoint [POST, PATCH, DELETE] - -## [v4.0.1] - (2015-12-03) ## -### Fixed -- HTTP 406 Not Acceptable Errors [#177](https://github.com/sendgrid/sendgrid-php/issues/177) - -## [v4.0.0] - (2015-10-16) ## -### Added -- Added support for accessing the [SendGrid Web API v3 endpoints](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) -- Implemented part of the /api_keys, /groups and /suppressions endpoints - -## [v3.2.0] - (2015-05-13) ## - -### Added -- Specify Guzzle proxy via [#149](https://github.com/sendgrid/sendgrid-php/pull/149) -- Option to disable exception raising - -## [v3.1.0] - (2015-04-27) -### Added -- Support for API keys - -## [v3.0.0] - (2015-04-14) -### Fixed -- CC and BCC not working with SMTPAPI To - -### Changed -- **Breaking:** A `\SendGrid\Exception` is now raised when response is not 200 -- **Breaking:** `addTo` now uses the Web API parameter as opposed to the SMTPAPI Header. Substitutions will most likely break unless you update to use `addSmtpapiTo` -- The library now depends on Guzzle3 -- Major refactoring - -### Added -- **Breaking:** `send()` now returns an instance of `\SendGrid\Response` -- Numerous missing methods for new functionality -- `addSmtpapiTo` for using the SMTPAPI To - -## [v2.2.1] - (2014-01-29) -### Fixed -- Fix turn_off_ssl_verification option via [#123](https://github.com/sendgrid/sendgrid-php/pull/123) - -## [v2.2.0] - (2014-01-12) -### Changed -- Remove [Unirest](https://github.com/Mashape/unirest-php/) and replace with native cURL -- Add CHANGELOG.md diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CODE_OF_CONDUCT.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..2bd6362 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CODE_OF_CONDUCT.md @@ -0,0 +1,38 @@ +# Twilio SendGrid Community Code of Conduct + +The Twilio SendGrid open source community is made up of members from around the globe with a diverse set of skills, personalities, and experiences. It is through these differences that our community experiences successes and continued growth. When you're working with members of the community, we encourage you to follow these guidelines, which help steer our interactions and strive to maintain a positive, successful and growing community. + +### Be Open +Members of the community are open to collaboration, whether it's on pull requests, code reviews, approvals, issues or otherwise. We're receptive to constructive comments and criticism, as the experiences and skill sets of all members contribute to the whole of our efforts. We're accepting of all who wish to take part in our activities, fostering an environment where anyone can participate, and everyone can make a difference. + +### Be Considerate +Members of the community are considerate of their peers, which include other contributors and users of Twilio SendGrid. We're thoughtful when addressing the efforts of others, keeping in mind that often the labor was completed with the intent of the good of the community. We're attentive in our communications, whether in person or online, and we're tactful when approaching differing views. + +### Be Respectful +Members of the community are respectful. We're respectful of others, their positions, their skills, their commitments and their efforts. We're respectful of the volunteer efforts that permeate the Twilio SendGrid community. We're respectful of the processes outlined in the community, and we work within them. When we disagree, we are courteous in raising our issues. Overall, we're good to each other. We contribute to this community not because we have to, but because we want to. If we remember that, these guidelines will come naturally. + +## Additional Guidance + +### Disclose Potential Conflicts of Interest +Community discussions often involve interested parties. We expect participants to be aware when they are conflicted due to employment or other projects they are involved in and disclose those interests to other project members. When in doubt, over-disclose. Perceived conflicts of interest are important to address so that the community’s decisions are credible even when unpopular, difficult or favorable to the interests of one group over another. + +### Interpretation +This Code is not exhaustive or complete. It is not a rulebook; it serves to distill our common understanding of a collaborative, shared environment and goals. We expect it to be followed in spirit as much as in the letter. When in doubt, try to abide by [Twilio SendGrid’s cultural values](https://sendgrid.com/blog/employee-engagement-the-4h-way) defined by our “4H’s”: Happy, Hungry, Humble and Honest. + +### Enforcement +Most members of the Twilio SendGrid community always comply with this Code, not because of the existence of this Code, but because they have long experience participating in open source communities where the conduct described above is normal and expected. However, failure to observe this Code may be grounds for suspension, reporting the user for abuse or changing permissions for outside contributors. + +## If you have concerns about someone’s conduct +**Initiate Direct Contact** - It is always appropriate to email a community member (if contact information is available), mention that you think their behavior was out of line, and (if necessary) point them to this Code. + +**Discuss Publicly** - Discussing publicly is always acceptable. Note, though, that approaching the person directly may be better, as it tends to make them less defensive, and it respects the time of other community members, so you probably want to try direct contact first. + +**Contact the Moderators** - You can reach the Twilio SendGrid moderators by emailing dx@sendgrid.com. + +## Attribution + +Twilio SendGrid thanks the following, on which it draws for content and inspiration: + +* [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/) +* [Open Source Initiative General Code of Conduct](https://opensource.org/codeofconduct) +* [Apache Code of Conduct](https://www.apache.org/foundation/policies/conduct.html) diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CONTRIBUTING.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CONTRIBUTING.md deleted file mode 100644 index 60a06c4..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/CONTRIBUTING.md +++ /dev/null @@ -1,193 +0,0 @@ -Hello! Thank you for choosing to help contribute to one of the SendGrid open source libraries. There are many ways you can contribute and help is always welcome. We simply ask that you follow the following contribution policies. - -- [CLAs and CCLAs](#cla) -- [Roadmap & Milestones](#roadmap) -- [Feature Request](#feature_request) -- [Submit a Bug Report](#submit_a_bug_report) -- [Improvements to the Codebase](#improvements_to_the_codebase) -- [Understanding the Code Base](#understanding_the_codebase) -- [Testing](#testing) -- [Style Guidelines & Naming Conventions](#style_guidelines_and_naming_conventions) -- [Creating a Pull Request](#creating_a_pull_request) - -<a name="roadmap"></a> -We use [Milestones](https://github.com/sendgrid/sendgrid-php/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged. - -<a name="cla"></a> -## CLAs and CCLAs - -Before you get started, SendGrid requires that a SendGrid Contributor License Agreement (CLA) be filled out by every contributor to a SendGrid open source project. - -Our goal with the CLA is to clarify the rights of our contributors and reduce other risks arising from inappropriate contributions. The CLA also clarifies the rights SendGrid holds in each contribution and helps to avoid misunderstandings over what rights each contributor is required to grant to SendGrid when making a contribution. In this way the CLA encourages broad participation by our open source community and helps us build strong open source projects, free from any individual contributor withholding or revoking rights to any contribution. - -SendGrid does not merge a pull request made against a SendGrid open source project until that pull request is associated with a signed CLA. Copies of the CLA are available [here](https://gist.github.com/SendGridDX/98b42c0a5d500058357b80278fde3be8#file-sendgrid_cla). - -When you create a Pull Request, after a few seconds, a comment will appear with a link to the CLA. Click the link and fill out the brief form and then click the "I agree" button and you are all set. You will not be asked to re-sign the CLA unless we make a change. - -There are a few ways to contribute, which we'll enumerate below: - -<a name="feature_request"></a> -## Feature Request - -If you'd like to make a feature request, please read this section. - -The GitHub issue tracker is the preferred channel for library feature requests, but please respect the following restrictions: - -- Please **search for existing issues** in order to ensure we don't have duplicate bugs/feature requests. -- Please be respectful and considerate of others when commenting on issues - -<a name="submit_a_bug_report"></a> -## Submit a Bug Report - -Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public. - -A software bug is a demonstrable issue in the code base. In order for us to diagnose the issue and respond as quickly as possible, please add as much detail as possible into your bug report. - -Before you decide to create a new issue, please try the following: - -1. Check the Github issues tab if the identified issue has already been reported, if so, please add a +1 to the existing post. -2. Update to the latest version of this code and check if issue has already been fixed -3. Copy and fill in the Bug Report Template we have provided below - -### Please use our Bug Report Template - -In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/sendgrid-php/blob/master/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting. - -<a name="improvements_to_the_codebase"></a> -## Improvements to the Codebase - -We welcome direct contributions to the sendgrid-php code base. Thank you! - -### Development Environment ### - -#### Install and Run Locally #### - -##### Prerequisites ##### - -- PHP 5.6 or 7.0 - -##### Initial setup: ##### - -```bash -git clone https://github.com/sendgrid/sendgrid-php.git -cd sendgrid-php -composer install -``` - -## Environment Variables - -First, get your free SendGrid account [here](https://sendgrid.com/free?source=sendgrid-php). - -Next, update your environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys). - -```bash -echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env -echo "sendgrid.env" >> .gitignore -source ./sendgrid.env -``` - -##### Execute: ##### - -See the [examples folder](https://github.com/sendgrid/sendgrid-php/tree/master/examples) to get started quickly. - -If you are using composer, replace <PATH_TO> with the path to your `vendor/autoload.php`. Otherwise, include lib/loader.php. - -<a name="understanding_the_codebase"></a> -## Understanding the Code Base - -**/examples** - -Working examples that demonstrate usage. - -```bash -php examples/example.php -``` - -**/test/unit** - -Unit tests for the HTTP client. - -**/lib** - -The interface to the SendGrid API. - -<a name="testing"></a> -## Testing - -All PRs require passing tests before the PR will be reviewed. - -All test files are in the [`/test/unit`](https://github.com/sendgrid/sendgrid-php/tree/master/test/unit) directory. - -For the purposes of contributing to this repo, please update the [`SendGridTest.php`](https://github.com/sendgrid/sendgrid-php/tree/master/test/unit/SendGridTest.php) file with unit tests as you modify the code. - -```bash -composer install -cd test/unit -../../vendor/bin/phpunit . --bootstrap bootstrap.php --filter test* -``` - -<a name="style_guidelines_and_naming_conventions"></a> -## Style Guidelines & Naming Conventions - -Generally, we follow the style guidelines as suggested by the official language. However, we ask that you conform to the styles that already exist in the library. If you wish to deviate, please explain your reasoning. - -- [PSR2 Coding Standards](http://www.php-fig.org/psr/psr-2/) - -Please run your code through: - -- [PHP Code Sniffer](https://github.com/squizlabs/PHP_CodeSniffer) - -## Creating a Pull Request<a name="creating_a_pull_request"></a> - -1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork, - and configure the remotes: - - ```bash - # Clone your fork of the repo into the current directory - git clone https://github.com/sendgrid/sendgrid-php - # Navigate to the newly cloned directory - cd sendgrid-php - # Assign the original repo to a remote called "upstream" - git remote add upstream https://github.com/sendgrid/sendgrid-php - ``` - -2. If you cloned a while ago, get the latest changes from upstream: - - ```bash - git checkout <dev-branch> - git pull upstream <dev-branch> - ``` - -3. Create a new topic branch (off the main project development branch) to - contain your feature, change, or fix: - - ```bash - git checkout -b <topic-branch-name> - ``` - -4. Commit your changes in logical chunks. Please adhere to these [git commit - message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) - or your code is unlikely be merged into the main project. Use Git's - [interactive rebase](https://help.github.com/articles/interactive-rebase) - feature to tidy up your commits before making them public. - -4a. Create tests. - -4b. Create or update the example code that demonstrates the functionality of this change to the code. - -5. Locally merge (or rebase) the upstream development branch into your topic branch: - - ```bash - git pull [--rebase] upstream master - ``` - -6. Push your topic branch up to your fork: - - ```bash - git push origin <topic-branch-name> - ``` - -7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) - with a clear title and description against the `master` branch. All tests must be passing before we will review the PR. - -If you have any additional questions, please feel free to [email](mailto:dx@sendgrid.com) us or create an issue in this repo. diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/LICENSE.txt b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/LICENSE.md index 7f9d537..42495db 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/LICENSE.txt +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2012-2016 SendGrid, Inc. +Copyright (c) 2012-19 Twilio SendGrid, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/TROUBLESHOOTING.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/TROUBLESHOOTING.md deleted file mode 100644 index ec0a293..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/TROUBLESHOOTING.md +++ /dev/null @@ -1,89 +0,0 @@ -If you have a non-library SendGrid issue, please contact our [support team](https://support.sendgrid.com). - -If you can't find a solution below, please open an [issue](https://github.com/sendgrid/sendgrid-php/issues). - - -## Table of Contents - -* [Migrating from v2 to v3](#migrating) -* [Continue Using v2](#v2) -* [Testing v3 /mail/send Calls Directly](#testing) -* [Error Messages](#error) -* [Versions](#versions) -* [Environment Variables and Your SendGrid API Key](#environment) -* [Using the Package Manager](#package-manager) - -<a name="migrating"></a> -## Migrating from v2 to v3 - -Please review [our guide](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html) on how to migrate from v2 to v3. - -<a name="v2"></a> -## Continue Using v2 - -[Here](https://github.com/sendgrid/sendgrid-php/tree/75970eb82f5629e66db4d6da08ff7ef0c507e9b0) is the last working version with v2 support. - -Using composer: - -```json -{ - "require": { - "sendgrid/sendgrid": "~3.2" - } -} -``` - -Download packaged zip [here](https://sendgrid-open-source.s3.amazonaws.com/sendgrid-php/versions/sendgrid-php-75970eb.zip). - -<a name="testing"></a> -## Testing v3 /mail/send Calls Directly - -[Here](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/curl_examples.html) are some cURL examples for common use cases. - -<a name="error"></a> -## Error Messages - -To read the error message returned by SendGrid's API: - -```php -try { - $response = $sendgrid->client->mail()->send()->post($mail); -} catch (Exception $e) { - echo 'Caught exception: ', $e->getMessage(), "\n"; -} -``` - -<a name="versions"></a> -## Versions - -We follow the MAJOR.MINOR.PATCH versioning scheme as described by [SemVer.org](http://semver.org). Therefore, we recommend that you always pin (or vendor) the particular version you are working with to your code and never auto-update to the latest version. Especially when there is a MAJOR point release, since that is guarenteed to be a breaking change. Changes are documented in the [CHANGELOG](https://github.com/sendgrid/sendgrid-php/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-php/releases) section. - -<a name="environment"></a> -## Environment Variables and Your SendGrid API Key - -All of our examples assume you are using [environment variables](https://github.com/sendgrid/sendgrid-php#setup-environment-variables) to hold your SendGrid API key. - -If you choose to add your SendGrid API key directly (not recommended): - -`$apiKey = getenv('SENDGRID_API_KEY');` - -becomes - -`$apiKey = 'SENDGRID_API_KEY';` - -In the first case SENDGRID_API_KEY is in reference to the name of the environment variable, while the second case references the actual SendGrid API Key. - -<a name="package-manager"></a> -## Using the Package Manager - -We upload this library to [Packagist](https://packagist.org/packages/sendgrid/sendgrid) whenever we make a release. This allows you to use [composer](https://getcomposer.org) for easy installation. - -In most cases we recommend you download the latest version of the library, but if you need a different version, please use: - -```json -{ - "require": { - "sendgrid/sendgrid": "~X.X.X" - } -} -```
\ No newline at end of file diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USAGE.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USAGE.md deleted file mode 100644 index 00a0d0d..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USAGE.md +++ /dev/null @@ -1,5038 +0,0 @@ -This documentation is based on our [OAI specification](https://github.com/sendgrid/sendgrid-oai). - -# INITIALIZATION - -```php -// If you are using Composer -require 'vendor/autoload.php'; - - -$apiKey = getenv('SENDGRID_API_KEY'); -$sg = new \SendGrid($apiKey); -``` - -# Table of Contents - -* [ACCESS SETTINGS](#access_settings) -* [ALERTS](#alerts) -* [API KEYS](#api_keys) -* [ASM](#asm) -* [BROWSERS](#browsers) -* [CAMPAIGNS](#campaigns) -* [CATEGORIES](#categories) -* [CLIENTS](#clients) -* [CONTACTDB](#contactdb) -* [DEVICES](#devices) -* [GEO](#geo) -* [IPS](#ips) -* [MAIL](#mail) -* [MAIL SETTINGS](#mail_settings) -* [MAILBOX PROVIDERS](#mailbox_providers) -* [PARTNER SETTINGS](#partner_settings) -* [SCOPES](#scopes) -* [SENDERS](#senders) -* [STATS](#stats) -* [SUBUSERS](#subusers) -* [SUPPRESSION](#suppression) -* [TEMPLATES](#templates) -* [TRACKING SETTINGS](#tracking_settings) -* [USER](#user) -* [WHITELABEL](#whitelabel) - - -<a name="access_settings"></a> -# ACCESS SETTINGS - -## Retrieve all recent access attempts - -**This endpoint allows you to retrieve a list of all of the IP addresses that recently attempted to access your account either through the User Interface or the API.** - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### GET /access_settings/activity - - -```php -$query_params = json_decode('{"limit": 1}'); -$response = $sg->client->access_settings()->activity()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add one or more IPs to the whitelist - -**This endpoint allows you to add one or more IP addresses to your IP whitelist.** - -When adding an IP to your whitelist, include the IP address in an array. You can whitelist one IP at a time, or you can whitelist multiple IPs at once. - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### POST /access_settings/whitelist - - -```php -$request_body = json_decode('{ - "ips": [ - { - "ip": "192.168.1.1" - }, - { - "ip": "192.*.*.*" - }, - { - "ip": "192.168.1.3/32" - } - ] -}'); -$response = $sg->client->access_settings()->whitelist()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a list of currently whitelisted IPs - -**This endpoint allows you to retrieve a list of IP addresses that are currently whitelisted.** - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### GET /access_settings/whitelist - - -```php -$response = $sg->client->access_settings()->whitelist()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Remove one or more IPs from the whitelist - -**This endpoint allows you to remove one or more IPs from your IP whitelist.** - -You can remove one IP at a time, or you can remove multiple IP addresses. - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### DELETE /access_settings/whitelist - - -```php -$request_body = json_decode('{ - "ids": [ - 1, - 2, - 3 - ] -}'); -$response = $sg->client->access_settings()->whitelist()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific whitelisted IP - -**This endpoint allows you to retreive a specific IP address that has been whitelisted.** - -You must include the ID for the specific IP address you want to retrieve in your call. - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### GET /access_settings/whitelist/{rule_id} - - -```php -$rule_id = "test_url_param"; -$response = $sg->client->access_settings()->whitelist()->_($rule_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Remove a specific IP from the whitelist - -**This endpoint allows you to remove a specific IP address from your IP whitelist.** - -When removing a specific IP address from your whitelist, you must include the ID in your call. - -IP Access Management allows you to control which IP addresses can be used to access your account, either through the User Interface or the API. There is no limit to the number of IP addresses that you can add to your whitelist. It is possible to remove your own IP address from the whitelist, thus preventing yourself from accessing your account. - -For more information, please see our [User Guide](http://sendgrid.com/docs/User_Guide/Settings/ip_access_management.html). - -### DELETE /access_settings/whitelist/{rule_id} - - -```php -$rule_id = "test_url_param"; -$response = $sg->client->access_settings()->whitelist()->_($rule_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="alerts"></a> -# ALERTS - -## Create a new Alert - -**This endpoint allows you to create a new alert.** - -Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. -* Usage alerts allow you to set the threshold at which an alert will be sent. -* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". - -For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). - -### POST /alerts - - -```php -$request_body = json_decode('{ - "email_to": "example@example.com", - "frequency": "daily", - "type": "stats_notification" -}'); -$response = $sg->client->alerts()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all alerts - -**This endpoint allows you to retieve all of your alerts.** - -Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. -* Usage alerts allow you to set the threshold at which an alert will be sent. -* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". - -For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). - -### GET /alerts - - -```php -$response = $sg->client->alerts()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update an alert - -**This endpoint allows you to update an alert.** - -Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. -* Usage alerts allow you to set the threshold at which an alert will be sent. -* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". - -For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). - -### PATCH /alerts/{alert_id} - - -```php -$request_body = json_decode('{ - "email_to": "example@example.com" -}'); -$alert_id = "test_url_param"; -$response = $sg->client->alerts()->_($alert_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific alert - -**This endpoint allows you to retrieve a specific alert.** - -Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. -* Usage alerts allow you to set the threshold at which an alert will be sent. -* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". - -For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). - -### GET /alerts/{alert_id} - - -```php -$alert_id = "test_url_param"; -$response = $sg->client->alerts()->_($alert_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete an alert - -**This endpoint allows you to delete an alert.** - -Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. -* Usage alerts allow you to set the threshold at which an alert will be sent. -* Stats notifications allow you to set how frequently you would like to receive email statistics reports. For example, "daily", "weekly", or "monthly". - -For more information about alerts, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/alerts.html). - -### DELETE /alerts/{alert_id} - - -```php -$alert_id = "test_url_param"; -$response = $sg->client->alerts()->_($alert_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="api_keys"></a> -# API KEYS - -## Create API keys - -**This enpoint allows you to create a new random API Key for the user.** - -A JSON request body containing a "name" property is required. If number of maximum keys is reached, HTTP 403 will be returned. - -There is a limit of 100 API Keys on your account. - -The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - -See the [API Key Permissions List](https://sendgrid.com/docs/API_Reference/Web_API_v3/API_Keys/api_key_permissions_list.html) for a list of all available scopes. - -### POST /api_keys - - -```php -$request_body = json_decode('{ - "name": "My API Key", - "sample": "data", - "scopes": [ - "mail.send", - "alerts.create", - "alerts.read" - ] -}'); -$response = $sg->client->api_keys()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all API Keys belonging to the authenticated user - -**This endpoint allows you to retrieve all API Keys that belong to the authenticated user.** - -The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - -### GET /api_keys - - -```php -$query_params = json_decode('{"limit": 1}'); -$response = $sg->client->api_keys()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update the name & scopes of an API Key - -**This endpoint allows you to update the name and scopes of a given API key.** - -A JSON request body with a "name" property is required. -Most provide the list of all the scopes an api key should have. - -The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - - -### PUT /api_keys/{api_key_id} - - -```php -$request_body = json_decode('{ - "name": "A New Hope", - "scopes": [ - "user.profile.read", - "user.profile.update" - ] -}'); -$api_key_id = "test_url_param"; -$response = $sg->client->api_keys()->_($api_key_id)->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update API keys - -**This endpoint allows you to update the name of an existing API Key.** - -A JSON request body with a "name" property is required. - -The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - -## URI Parameters - -| URI Parameter | Type | Required? | Description | -|---|---|---|---| -|api_key_id |string | required | The ID of the API Key you are updating.| - -### PATCH /api_keys/{api_key_id} - - -```php -$request_body = json_decode('{ - "name": "A New Hope" -}'); -$api_key_id = "test_url_param"; -$response = $sg->client->api_keys()->_($api_key_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve an existing API Key - -**This endpoint allows you to retrieve a single api key.** - -If the API Key ID does not exist an HTTP 404 will be returned. - -### GET /api_keys/{api_key_id} - - -```php -$api_key_id = "test_url_param"; -$response = $sg->client->api_keys()->_($api_key_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete API keys - -**This endpoint allows you to revoke an existing API Key** - -Authentications using this API Key will fail after this request is made, with some small propogation delay.If the API Key ID does not exist an HTTP 404 will be returned. - -The API Keys feature allows customers to be able to generate an API Key credential which can be used for authentication with the SendGrid v3 Web API or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - -## URI Parameters - -| URI Parameter | Type | Required? | Description | -|---|---|---|---| -|api_key_id |string | required | The ID of the API Key you are deleting.| - -### DELETE /api_keys/{api_key_id} - - -```php -$api_key_id = "test_url_param"; -$response = $sg->client->api_keys()->_($api_key_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="asm"></a> -# ASM - -## Create a new suppression group - -**This endpoint allows you to create a new suppression group.** - -Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts. - -The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions. - -Each user can create up to 25 different suppression groups. - -### POST /asm/groups - - -```php -$request_body = json_decode('{ - "description": "Suggestions for products our users might like.", - "is_default": true, - "name": "Product Suggestions" -}'); -$response = $sg->client->asm()->groups()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve information about multiple suppression groups - -**This endpoint allows you to retrieve information about multiple suppression groups.** - -This endpoint will return information for each group ID that you include in your request. To add a group ID to your request, simply append `&id=` followed by the group ID. - -Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). - -Suppression groups, or [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html), allow you to label a category of content that you regularly send. This gives your recipients the ability to opt out of a specific set of your email. For example, you might define a group for your transactional email, and one for your marketing email so that your users can continue recieving your transactional email witout having to receive your marketing content. - -### GET /asm/groups - - -```php -$query_params = json_decode('{"id": 1}'); -$response = $sg->client->asm()->groups()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a suppression group. - -**This endpoint allows you to update or change a suppression group.** - -Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts. - -The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions. - -Each user can create up to 25 different suppression groups. - -### PATCH /asm/groups/{group_id} - - -```php -$request_body = json_decode('{ - "description": "Suggestions for items our users might like.", - "id": 103, - "name": "Item Suggestions" -}'); -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Get information on a single suppression group. - -**This endpoint allows you to retrieve a single suppression group.** - -Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts. - -The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions. - -Each user can create up to 25 different suppression groups. - -### GET /asm/groups/{group_id} - - -```php -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a suppression group. - -**This endpoint allows you to delete a suppression group.** - -You can only delete groups that have not been attached to sent mail in the last 60 days. If a recipient uses the "one-click unsubscribe" option on an email associated with a deleted group, that recipient will be added to the global suppression list. - -Suppression groups, or unsubscribe groups, are specific types or categories of email that you would like your recipients to be able to unsubscribe from. For example: Daily Newsletters, Invoices, System Alerts. - -The **name** and **description** of the unsubscribe group will be visible by recipients when they are managing their subscriptions. - -Each user can create up to 25 different suppression groups. - -### DELETE /asm/groups/{group_id} - - -```php -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add suppressions to a suppression group - -**This endpoint allows you to add email addresses to an unsubscribe group.** - -If you attempt to add suppressions to a group that has been deleted or does not exist, the suppressions will be added to the global suppressions list. - -Suppressions are recipient email addresses that are added to [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). Once a recipient's address is on the suppressions list for an unsubscribe group, they will not receive any emails that are tagged with that unsubscribe group. - -### POST /asm/groups/{group_id}/suppressions - - -```php -$request_body = json_decode('{ - "recipient_emails": [ - "test1@example.com", - "test2@example.com" - ] -}'); -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->suppressions()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all suppressions for a suppression group - -**This endpoint allows you to retrieve all suppressed email addresses belonging to the given group.** - -Suppressions are recipient email addresses that are added to [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). Once a recipient's address is on the suppressions list for an unsubscribe group, they will not receive any emails that are tagged with that unsubscribe group. - -### GET /asm/groups/{group_id}/suppressions - - -```php -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->suppressions()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Search for suppressions within a group - -**This endpoint allows you to search a suppression group for multiple suppressions.** - -When given a list of email addresses and a group ID, this endpoint will return only the email addresses that have been unsubscribed from the given group. - -Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). - -### POST /asm/groups/{group_id}/suppressions/search - - -```php -$request_body = json_decode('{ - "recipient_emails": [ - "exists1@example.com", - "exists2@example.com", - "doesnotexists@example.com" - ] -}'); -$group_id = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->suppressions()->search()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a suppression from a suppression group - -**This endpoint allows you to remove a suppressed email address from the given suppression group.** - -Suppressions are recipient email addresses that are added to [unsubscribe groups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). Once a recipient's address is on the suppressions list for an unsubscribe group, they will not receive any emails that are tagged with that unsubscribe group. - -### DELETE /asm/groups/{group_id}/suppressions/{email} - - -```php -$group_id = "test_url_param"; -$email = "test_url_param"; -$response = $sg->client->asm()->groups()->_($group_id)->suppressions()->_($email)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all suppressions - -**This endpoint allows you to retrieve a list of all suppressions.** - -Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). - -### GET /asm/suppressions - - -```php -$response = $sg->client->asm()->suppressions()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add recipient addresses to the global suppression group. - -**This endpoint allows you to add one or more email addresses to the global suppressions group.** - -A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html). - -### POST /asm/suppressions/global - - -```php -$request_body = json_decode('{ - "recipient_emails": [ - "test1@example.com", - "test2@example.com" - ] -}'); -$response = $sg->client->asm()->suppressions()->global()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Global Suppression - -**This endpoint allows you to retrieve a global suppression. You can also use this endpoint to confirm if an email address is already globally suppresed.** - -If the email address you include in the URL path parameter `{email}` is alreayd globally suppressed, the response will include that email address. If the address you enter for `{email}` is not globally suppressed, an empty JSON object `{}` will be returned. - -A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html). - -### GET /asm/suppressions/global/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->asm()->suppressions()->global()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Global Suppression - -**This endpoint allows you to remove an email address from the global suppressions group.** - -A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html). - -### DELETE /asm/suppressions/global/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->asm()->suppressions()->global()->_($email)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all suppression groups for an email address - -**This endpoint returns the list of all groups that the given email address has been unsubscribed from.** - -Suppressions are a list of email addresses that will not receive content sent under a given [group](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html). - -### GET /asm/suppressions/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->asm()->suppressions()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="browsers"></a> -# BROWSERS - -## Retrieve email statistics by browser. - -**This endpoint allows you to retrieve your email statistics segmented by browser type.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /browsers/stats - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "browsers": "test_string", "limit": "test_string", "offset": "test_string", "start_date": "2016-01-01"}'); -$response = $sg->client->browsers()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="campaigns"></a> -# CAMPAIGNS - -## Create a Campaign - -**This endpoint allows you to create a campaign.** - -Our Marketing Campaigns API lets you create, manage, send, and schedule campaigns. - -Note: In order to send or schedule the campaign, you will be required to provide a subject, sender ID, content (we suggest both html and plain text), and at least one list or segment ID. This information is not required when you create a campaign. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### POST /campaigns - - -```php -$request_body = json_decode('{ - "categories": [ - "spring line" - ], - "custom_unsubscribe_url": "", - "html_content": "<html><head><title></title></head><body><p>Check out our spring line!</p></body></html>", - "ip_pool": "marketing", - "list_ids": [ - 110, - 124 - ], - "plain_content": "Check out our spring line!", - "segment_ids": [ - 110 - ], - "sender_id": 124451, - "subject": "New Products for Spring!", - "suppression_group_id": 42, - "title": "March Newsletter" -}'); -$response = $sg->client->campaigns()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all Campaigns - -**This endpoint allows you to retrieve a list of all of your campaigns.** - -Returns campaigns in reverse order they were created (newest first). - -Returns an empty array if no campaigns exist. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### GET /campaigns - - -```php -$query_params = json_decode('{"limit": 1, "offset": 1}'); -$response = $sg->client->campaigns()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a Campaign - -Update a campaign. This is especially useful if you only set up the campaign using POST /campaigns, but didn't set many of the parameters. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### PATCH /campaigns/{campaign_id} - - -```php -$request_body = json_decode('{ - "categories": [ - "summer line" - ], - "html_content": "<html><head><title></title></head><body><p>Check out our summer line!</p></body></html>", - "plain_content": "Check out our summer line!", - "subject": "New Products for Summer!", - "title": "May Newsletter" -}'); -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a single campaign - -**This endpoint allows you to retrieve a specific campaign.** - -Our Marketing Campaigns API lets you create, manage, send, and schedule campaigns. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### GET /campaigns/{campaign_id} - - -```php -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Campaign - -**This endpoint allows you to delete a specific campaign.** - -Our Marketing Campaigns API lets you create, manage, send, and schedule campaigns. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### DELETE /campaigns/{campaign_id} - - -```php -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a Scheduled Campaign - -**This endpoint allows to you change the scheduled time and date for a campaign to be sent.** - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### PATCH /campaigns/{campaign_id}/schedules - - -```php -$request_body = json_decode('{ - "send_at": 1489451436 -}'); -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Schedule a Campaign - -**This endpoint allows you to schedule a specific date and time for your campaign to be sent.** - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### POST /campaigns/{campaign_id}/schedules - - -```php -$request_body = json_decode('{ - "send_at": 1489771528 -}'); -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## View Scheduled Time of a Campaign - -**This endpoint allows you to retrieve the date and time that the given campaign has been scheduled to be sent.** - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### GET /campaigns/{campaign_id}/schedules - - -```php -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Unschedule a Scheduled Campaign - -**This endpoint allows you to unschedule a campaign that has already been scheduled to be sent.** - -A successful unschedule will return a 204. -If the specified campaign is in the process of being sent, the only option is to cancel (a different method). - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### DELETE /campaigns/{campaign_id}/schedules - - -```php -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Send a Campaign - -**This endpoint allows you to immediately send a campaign at the time you make the API call.** - -Normally a POST would have a request body, but since this endpoint is telling us to send a resource that is already created, a request body is not needed. - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### POST /campaigns/{campaign_id}/schedules/now - - -```php -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->now()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Send a Test Campaign - -**This endpoint allows you to send a test campaign.** - -To send to multiple addresses, use an array for the JSON "to" value ["one@address","two@address"] - -For more information: - -* [User Guide > Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) - -### POST /campaigns/{campaign_id}/schedules/test - - -```php -$request_body = json_decode('{ - "to": "your.email@example.com" -}'); -$campaign_id = "test_url_param"; -$response = $sg->client->campaigns()->_($campaign_id)->schedules()->test()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="categories"></a> -# CATEGORIES - -## Retrieve all categories - -**This endpoint allows you to retrieve a list of all of your categories.** - -Categories can help organize your email analytics by enabling you to tag emails by type or broad topic. You can define your own custom categories. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html). - -### GET /categories - - -```php -$query_params = json_decode('{"category": "test_string", "limit": 1, "offset": 1}'); -$response = $sg->client->categories()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Email Statistics for Categories - -**This endpoint allows you to retrieve all of your email statistics for each of your categories.** - -If you do not define any query parameters, this endpoint will return a sum for each category in groups of 10. - -Categories allow you to group your emails together according to broad topics that you define. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html). - -### GET /categories/stats - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "categories": "test_string"}'); -$response = $sg->client->categories()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve sums of email stats for each category [Needs: Stats object defined, has category ID?] - -**This endpoint allows you to retrieve the total sum of each email statistic for every category over the given date range.** - -If you do not define any query parameters, this endpoint will return a sum for each category in groups of 10. - -Categories allow you to group your emails together according to broad topics that you define. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/categories.html). - -### GET /categories/stats/sums - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}'); -$response = $sg->client->categories()->stats()->sums()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="clients"></a> -# CLIENTS - -## Retrieve email statistics by client type. - -**This endpoint allows you to retrieve your email statistics segmented by client type.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /clients/stats - - -```php -$query_params = json_decode('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}'); -$response = $sg->client->clients()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve stats by a specific client type. - -**This endpoint allows you to retrieve your email statistics segmented by a specific client type.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -## Available Client Types -- phone -- tablet -- webmail -- desktop - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /clients/{client_type}/stats - - -```php -$query_params = json_decode('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}'); -$client_type = "test_url_param"; -$response = $sg->client->clients()->_($client_type)->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="contactdb"></a> -# CONTACTDB - -## Create a Custom Field - -**This endpoint allows you to create a custom field.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### POST /contactdb/custom_fields - - -```php -$request_body = json_decode('{ - "name": "pet", - "type": "text" -}'); -$response = $sg->client->contactdb()->custom_fields()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all custom fields - -**This endpoint allows you to retrieve all custom fields.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### GET /contactdb/custom_fields - - -```php -$response = $sg->client->contactdb()->custom_fields()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Custom Field - -**This endpoint allows you to retrieve a custom field by ID.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### GET /contactdb/custom_fields/{custom_field_id} - - -```php -$custom_field_id = "test_url_param"; -$response = $sg->client->contactdb()->custom_fields()->_($custom_field_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Custom Field - -**This endpoint allows you to delete a custom field by ID.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### DELETE /contactdb/custom_fields/{custom_field_id} - - -```php -$custom_field_id = "test_url_param"; -$response = $sg->client->contactdb()->custom_fields()->_($custom_field_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create a List - -**This endpoint allows you to create a list for your recipients.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### POST /contactdb/lists - - -```php -$request_body = json_decode('{ - "name": "your list name" -}'); -$response = $sg->client->contactdb()->lists()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all lists - -**This endpoint allows you to retrieve all of your recipient lists. If you don't have any lists, an empty array will be returned.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/lists - - -```php -$response = $sg->client->contactdb()->lists()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete Multiple lists - -**This endpoint allows you to delete multiple recipient lists.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### DELETE /contactdb/lists - - -```php -$request_body = json_decode('[ - 1, - 2, - 3, - 4 -]'); -$response = $sg->client->contactdb()->lists()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a List - -**This endpoint allows you to update the name of one of your recipient lists.** - - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### PATCH /contactdb/lists/{list_id} - - -```php -$request_body = json_decode('{ - "name": "newlistname" -}'); -$query_params = json_decode('{"list_id": 1}'); -$list_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->patch($request_body, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a single list - -This endpoint allows you to retrieve a single recipient list. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/lists/{list_id} - - -```php -$query_params = json_decode('{"list_id": 1}'); -$list_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a List - -**This endpoint allows you to delete a specific recipient list with the given ID.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### DELETE /contactdb/lists/{list_id} - - -```php -$query_params = json_decode('{"delete_contacts": "true"}'); -$list_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->delete(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add Multiple Recipients to a List - -**This endpoint allows you to add multiple recipients to a list.** - -Adds existing recipients to a list, passing in the recipient IDs to add. Recipient IDs should be passed exactly as they are returned from recipient endpoints. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### POST /contactdb/lists/{list_id}/recipients - - -```php -$request_body = json_decode('[ - "recipient_id1", - "recipient_id2" -]'); -$list_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->recipients()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all recipients on a List - -**This endpoint allows you to retrieve all recipients on the list with the given ID.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/lists/{list_id}/recipients - - -```php -$query_params = json_decode('{"page": 1, "page_size": 1}'); -$list_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->recipients()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add a Single Recipient to a List - -**This endpoint allows you to add a single recipient to a list.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### POST /contactdb/lists/{list_id}/recipients/{recipient_id} - - -```php -$list_id = "test_url_param"; -$recipient_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->recipients()->_($recipient_id)->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Single Recipient from a Single List - -**This endpoint allows you to delete a single recipient from a list.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### DELETE /contactdb/lists/{list_id}/recipients/{recipient_id} - - -```php -$query_params = json_decode('{"recipient_id": 1, "list_id": 1}'); -$list_id = "test_url_param"; -$recipient_id = "test_url_param"; -$response = $sg->client->contactdb()->lists()->_($list_id)->recipients()->_($recipient_id)->delete(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Recipient - -**This endpoint allows you to update one or more recipients.** - -The body of an API call to this endpoint must include an array of one or more recipient objects. - -It is of note that you can add custom field data as parameters on recipient objects. We have provided an example using some of the default custom fields SendGrid provides. - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### PATCH /contactdb/recipients - - -```php -$request_body = json_decode('[ - { - "email": "jones@example.com", - "first_name": "Guy", - "last_name": "Jones" - } -]'); -$response = $sg->client->contactdb()->recipients()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add recipients - -**This endpoint allows you to add a Marketing Campaigns recipient.** - -It is of note that you can add custom field data as a parameter on this endpoint. We have provided an example using some of the default custom fields SendGrid provides. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### POST /contactdb/recipients - - -```php -$request_body = json_decode('[ - { - "age": 25, - "email": "example@example.com", - "first_name": "", - "last_name": "User" - }, - { - "age": 25, - "email": "example2@example.com", - "first_name": "Example", - "last_name": "User" - } -]'); -$response = $sg->client->contactdb()->recipients()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve recipients - -**This endpoint allows you to retrieve all of your Marketing Campaigns recipients.** - -Batch deletion of a page makes it possible to receive an empty page of recipients before reaching the end of -the list of recipients. To avoid this issue; iterate over pages until a 404 is retrieved. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/recipients - - -```php -$query_params = json_decode('{"page": 1, "page_size": 1}'); -$response = $sg->client->contactdb()->recipients()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete Recipient - -**This endpoint allows you to deletes one or more recipients.** - -The body of an API call to this endpoint must include an array of recipient IDs of the recipients you want to delete. - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### DELETE /contactdb/recipients - - -```php -$request_body = json_decode('[ - "recipient_id1", - "recipient_id2" -]'); -$response = $sg->client->contactdb()->recipients()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve the count of billable recipients - -**This endpoint allows you to retrieve the number of Marketing Campaigns recipients that you will be billed for.** - -You are billed for marketing campaigns based on the highest number of recipients you have had in your account at one time. This endpoint will allow you to know the current billable count value. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/recipients/billable_count - - -```php -$response = $sg->client->contactdb()->recipients()->billable_count()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Count of Recipients - -**This endpoint allows you to retrieve the total number of Marketing Campaigns recipients.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### GET /contactdb/recipients/count - - -```php -$response = $sg->client->contactdb()->recipients()->count()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve recipients matching search criteria - -**This endpoint allows you to perform a search on all of your Marketing Campaigns recipients.** - -field_name: - -* is a variable that is substituted for your actual custom field name from your recipient. -* Text fields must be url-encoded. Date fields are searchable only by unix timestamp (e.g. 2/2/2015 becomes 1422835200) -* If field_name is a 'reserved' date field, such as created_at or updated_at, the system will internally convert -your epoch time to a date range encompassing the entire day. For example, an epoch time of 1422835600 converts to -Mon, 02 Feb 2015 00:06:40 GMT, but internally the system will search from Mon, 02 Feb 2015 00:00:00 GMT through -Mon, 02 Feb 2015 23:59:59 GMT. - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### GET /contactdb/recipients/search - - -```php -$query_params = json_decode('{"{field_name}": "test_string"}'); -$response = $sg->client->contactdb()->recipients()->search()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a single recipient - -**This endpoint allows you to retrieve a single recipient by ID from your contact database.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/recipients/{recipient_id} - - -```php -$recipient_id = "test_url_param"; -$response = $sg->client->contactdb()->recipients()->_($recipient_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Recipient - -**This endpoint allows you to delete a single recipient with the given ID from your contact database.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### DELETE /contactdb/recipients/{recipient_id} - - -```php -$recipient_id = "test_url_param"; -$response = $sg->client->contactdb()->recipients()->_($recipient_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve the lists that a recipient is on - -**This endpoint allows you to retrieve the lists that a given recipient belongs to.** - -Each recipient can be on many lists. This endpoint gives you all of the lists that any one recipient has been added to. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -### GET /contactdb/recipients/{recipient_id}/lists - - -```php -$recipient_id = "test_url_param"; -$response = $sg->client->contactdb()->recipients()->_($recipient_id)->lists()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve reserved fields - -**This endpoint allows you to list all fields that are reserved and can't be used for custom field names.** - -The contactdb is a database of your contacts for [SendGrid Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html). - -### GET /contactdb/reserved_fields - - -```php -$response = $sg->client->contactdb()->reserved_fields()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create a Segment - -**This endpoint allows you to create a segment.** - -All recipients in your contactdb will be added or removed automatically depending on whether they match the criteria for this segment. - -List Id: - -* Send this to segment from an existing list -* Don't send this in order to segment from your entire contactdb. - -Valid operators for create and update depend on the type of the field you are segmenting: - -* **Dates:** "eq", "ne", "lt" (before), "gt" (after) -* **Text:** "contains", "eq" (is - matches the full field), "ne" (is not - matches any field where the entire field is not the condition value) -* **Numbers:** "eq", "lt", "gt" -* **Email Clicks and Opens:** "eq" (opened), "ne" (not opened) - -Segment conditions using "eq" or "ne" for email clicks and opens should provide a "field" of either *clicks.campaign_identifier* or *opens.campaign_identifier*. The condition value should be a string containing the id of a completed campaign. - -Segments may contain multiple condtions, joined by an "and" or "or" in the "and_or" field. The first condition in the conditions list must have an empty "and_or", and subsequent conditions must all specify an "and_or". - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### POST /contactdb/segments - - -```php -$request_body = json_decode('{ - "conditions": [ - { - "and_or": "", - "field": "last_name", - "operator": "eq", - "value": "Miller" - }, - { - "and_or": "and", - "field": "last_clicked", - "operator": "gt", - "value": "01/02/2015" - }, - { - "and_or": "or", - "field": "clicks.campaign_identifier", - "operator": "eq", - "value": "513" - } - ], - "list_id": 4, - "name": "Last Name Miller" -}'); -$response = $sg->client->contactdb()->segments()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all segments - -**This endpoint allows you to retrieve all of your segments.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### GET /contactdb/segments - - -```php -$response = $sg->client->contactdb()->segments()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a segment - -**This endpoint allows you to update a segment.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### PATCH /contactdb/segments/{segment_id} - - -```php -$request_body = json_decode('{ - "conditions": [ - { - "and_or": "", - "field": "last_name", - "operator": "eq", - "value": "Miller" - } - ], - "list_id": 5, - "name": "The Millers" -}'); -$query_params = json_decode('{"segment_id": "test_string"}'); -$segment_id = "test_url_param"; -$response = $sg->client->contactdb()->segments()->_($segment_id)->patch($request_body, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a segment - -**This endpoint allows you to retrieve a single segment with the given ID.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### GET /contactdb/segments/{segment_id} - - -```php -$query_params = json_decode('{"segment_id": 1}'); -$segment_id = "test_url_param"; -$response = $sg->client->contactdb()->segments()->_($segment_id)->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a segment - -**This endpoint allows you to delete a segment from your recipients database.** - -You also have the option to delete all the contacts from your Marketing Campaigns recipient database who were in this segment. - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### DELETE /contactdb/segments/{segment_id} - - -```php -$query_params = json_decode('{"delete_contacts": "true"}'); -$segment_id = "test_url_param"; -$response = $sg->client->contactdb()->segments()->_($segment_id)->delete(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve recipients on a segment - -**This endpoint allows you to retrieve all of the recipients in a segment with the given ID.** - -The Contacts API helps you manage your [Marketing Campaigns](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/index.html) recipients. - -For more information about segments in Marketing Campaigns, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/lists.html#-Create-a-Segment). - -### GET /contactdb/segments/{segment_id}/recipients - - -```php -$query_params = json_decode('{"page": 1, "page_size": 1}'); -$segment_id = "test_url_param"; -$response = $sg->client->contactdb()->segments()->_($segment_id)->recipients()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="devices"></a> -# DEVICES - -## Retrieve email statistics by device type. - -**This endpoint allows you to retrieve your email statistics segmented by the device type.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -## Available Device Types -| **Device** | **Description** | **Example** | -|---|---|---| -| Desktop | Email software on desktop computer. | I.E., Outlook, Sparrow, or Apple Mail. | -| Webmail | A web-based email client. | I.E., Yahoo, Google, AOL, or Outlook.com. | -| Phone | A smart phone. | iPhone, Android, Blackberry, etc. -| Tablet | A tablet computer. | iPad, android based tablet, etc. | -| Other | An unrecognized device. | - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /devices/stats - - -```php -$query_params = json_decode('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}'); -$response = $sg->client->devices()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="geo"></a> -# GEO - -## Retrieve email statistics by country and state/province. - -**This endpoint allows you to retrieve your email statistics segmented by country and state/province.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /geo/stats - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "country": "US", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01"}'); -$response = $sg->client->geo()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="ips"></a> -# IPS - -## Retrieve all IP addresses - -**This endpoint allows you to retrieve a list of all assigned and unassigned IPs.** - -Response includes warm up status, pools, assigned subusers, and whitelabel info. The start_date field corresponds to when warmup started for that IP. - -A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it. - -### GET /ips - - -```php -$query_params = json_decode('{"subuser": "test_string", "ip": "test_string", "limit": 1, "exclude_whitelabels": "true", "offset": 1}'); -$response = $sg->client->ips()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all assigned IPs - -**This endpoint allows you to retrieve only assigned IP addresses.** - -A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it. - -### GET /ips/assigned - - -```php -$response = $sg->client->ips()->assigned()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create an IP pool. - -**This endpoint allows you to create an IP pool.** - -**Each user can create up to 10 different IP pools.** - -IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic. - -IP pools can only be used with whitelabeled IP addresses. - -If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools. - -### POST /ips/pools - - -```php -$request_body = json_decode('{ - "name": "marketing" -}'); -$response = $sg->client->ips()->pools()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all IP pools. - -**This endpoint allows you to retreive all of your IP pools.** - -IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic. - -IP pools can only be used with whitelabeled IP addresses. - -If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools. - -### GET /ips/pools - - -```php -$response = $sg->client->ips()->pools()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update an IP pools name. - -**This endpoint allows you to update the name of an IP pool.** - -IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic. - -IP pools can only be used with whitelabeled IP addresses. - -If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools. - -### PUT /ips/pools/{pool_name} - - -```php -$request_body = json_decode('{ - "name": "new_pool_name" -}'); -$pool_name = "test_url_param"; -$response = $sg->client->ips()->pools()->_($pool_name)->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all IPs in a specified pool. - -**This endpoint allows you to list all of the IP addresses that are in a specific IP pool.** - -IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic. - -IP pools can only be used with whitelabeled IP addresses. - -If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools. - -### GET /ips/pools/{pool_name} - - -```php -$pool_name = "test_url_param"; -$response = $sg->client->ips()->pools()->_($pool_name)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete an IP pool. - -**This endpoint allows you to delete an IP pool.** - -IP Pools allow you to group your dedicated SendGrid IP addresses together. For example, you could create separate pools for your transactional and marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic. - -IP pools can only be used with whitelabeled IP addresses. - -If an IP pool is NOT specified for an email, it will use any IP available, including ones in pools. - -### DELETE /ips/pools/{pool_name} - - -```php -$pool_name = "test_url_param"; -$response = $sg->client->ips()->pools()->_($pool_name)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add an IP address to a pool - -**This endpoint allows you to add an IP address to an IP pool.** - -You can add the same IP address to multiple pools. It may take up to 60 seconds for your IP address to be added to a pool after your request is made. - -A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it. - -### POST /ips/pools/{pool_name}/ips - - -```php -$request_body = json_decode('{ - "ip": "0.0.0.0" -}'); -$pool_name = "test_url_param"; -$response = $sg->client->ips()->pools()->_($pool_name)->ips()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Remove an IP address from a pool. - -**This endpoint allows you to remove an IP address from an IP pool.** - -The same IP address can be added to multiple IP pools. - -A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it. - -### DELETE /ips/pools/{pool_name}/ips/{ip} - - -```php -$pool_name = "test_url_param"; -$ip = "test_url_param"; -$response = $sg->client->ips()->pools()->_($pool_name)->ips()->_($ip)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add an IP to warmup - -**This endpoint allows you to enter an IP address into warmup mode.** - -SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup. - -For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html). - -### POST /ips/warmup - - -```php -$request_body = json_decode('{ - "ip": "0.0.0.0" -}'); -$response = $sg->client->ips()->warmup()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all IPs currently in warmup - -**This endpoint allows you to retrieve all of your IP addresses that are currently warming up.** - -SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup. - -For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html). - -### GET /ips/warmup - - -```php -$response = $sg->client->ips()->warmup()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve warmup status for a specific IP address - -**This endpoint allows you to retrieve the warmup status for a specific IP address.** - -SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup. - -For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html). - -### GET /ips/warmup/{ip_address} - - -```php -$ip_address = "test_url_param"; -$response = $sg->client->ips()->warmup()->_($ip_address)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Remove an IP from warmup - -**This endpoint allows you to remove an IP address from warmup mode.** - -SendGrid can automatically warm up dedicated IP addresses by limiting the amount of mail that can be sent through them per hour, with the limit determined by how long the IP address has been in warmup. See the [warmup schedule](https://sendgrid.com/docs/API_Reference/Web_API_v3/IP_Management/ip_warmup_schedule.html) for more details on how SendGrid limits your email traffic for IPs in warmup. - -For more general information about warming up IPs, please see our [Classroom](https://sendgrid.com/docs/Classroom/Deliver/Delivery_Introduction/warming_up_ips.html). - -### DELETE /ips/warmup/{ip_address} - - -```php -$ip_address = "test_url_param"; -$response = $sg->client->ips()->warmup()->_($ip_address)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all IP pools an IP address belongs to - -**This endpoint allows you to see which IP pools a particular IP address has been added to.** - -The same IP address can be added to multiple IP pools. - -A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. The reputation of this IP is based on the aggregate performance of all the senders who use it. - -### GET /ips/{ip_address} - - -```php -$ip_address = "test_url_param"; -$response = $sg->client->ips()->_($ip_address)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="mail"></a> -# MAIL - -## Create a batch ID - -**This endpoint allows you to generate a new batch ID. This batch ID can be associated with scheduled sends via the mail/send endpoint.** - -If you set the SMTPAPI header `batch_id`, it allows you to then associate multiple scheduled mail/send requests together with the same ID. Then at anytime up to 10 minutes before the schedule date, you can cancel all of the mail/send requests that have this batch ID by calling the Cancel Scheduled Send endpoint. - -More Information: - -* [Scheduling Parameters > Batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html) - -### POST /mail/batch - - -```php -$response = $sg->client->mail()->batch()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Validate batch ID - -**This endpoint allows you to validate a batch ID.** - -If you set the SMTPAPI header `batch_id`, it allows you to then associate multiple scheduled mail/send requests together with the same ID. Then at anytime up to 10 minutes before the schedule date, you can cancel all of the mail/send requests that have this batch ID by calling the Cancel Scheduled Send endpoint. - -More Information: - -* [Scheduling Parameters > Batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html) - -### GET /mail/batch/{batch_id} - - -```php -$batch_id = "test_url_param"; -$response = $sg->client->mail()->batch()->_($batch_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## v3 Mail Send - -This endpoint allows you to send email over SendGrids v3 Web API, the most recent version of our API. If you are looking for documentation about the v2 Mail Send endpoint, please see our [v2 API Reference](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). - -* Top level parameters are referred to as "global". -* Individual fields within the personalizations array will override any other global, or message level, parameters that are defined outside of personalizations. - -For an overview of the v3 Mail Send endpoint, please visit our [v3 API Reference](https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html) - -For more detailed information about how to use the v3 Mail Send endpoint, please visit our [Classroom](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/index.html). - -### POST /mail/send - -This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-php/blob/master/lib/helpers/mail/README.md). - -```php -$request_body = json_decode('{ - "asm": { - "group_id": 1, - "groups_to_display": [ - 1, - 2, - 3 - ] - }, - "attachments": [ - { - "content": "[BASE64 encoded content block here]", - "content_id": "ii_139db99fdb5c3704", - "disposition": "inline", - "filename": "file1.jpg", - "name": "file1", - "type": "jpg" - } - ], - "batch_id": "[YOUR BATCH ID GOES HERE]", - "categories": [ - "category1", - "category2" - ], - "content": [ - { - "type": "text/html", - "value": "<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>" - } - ], - "custom_args": { - "New Argument 1": "New Value 1", - "activationAttempt": "1", - "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]" - }, - "from": { - "email": "sam.smith@example.com", - "name": "Sam Smith" - }, - "headers": {}, - "ip_pool_name": "[YOUR POOL NAME GOES HERE]", - "mail_settings": { - "bcc": { - "email": "ben.doe@example.com", - "enable": true - }, - "bypass_list_management": { - "enable": true - }, - "footer": { - "enable": true, - "html": "<p>Thanks</br>The SendGrid Team</p>", - "text": "Thanks,/n The SendGrid Team" - }, - "sandbox_mode": { - "enable": false - }, - "spam_check": { - "enable": true, - "post_to_url": "http://example.com/compliance", - "threshold": 3 - } - }, - "personalizations": [ - { - "bcc": [ - { - "email": "sam.doe@example.com", - "name": "Sam Doe" - } - ], - "cc": [ - { - "email": "jane.doe@example.com", - "name": "Jane Doe" - } - ], - "custom_args": { - "New Argument 1": "New Value 1", - "activationAttempt": "1", - "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]" - }, - "headers": { - "X-Accept-Language": "en", - "X-Mailer": "MyApp" - }, - "send_at": 1409348513, - "subject": "Hello, World!", - "substitutions": { - "id": "substitutions", - "type": "object" - }, - "to": [ - { - "email": "john.doe@example.com", - "name": "John Doe" - } - ] - } - ], - "reply_to": { - "email": "sam.smith@example.com", - "name": "Sam Smith" - }, - "sections": { - "section": { - ":sectionName1": "section 1 text", - ":sectionName2": "section 2 text" - } - }, - "send_at": 1409348513, - "subject": "Hello, World!", - "template_id": "[YOUR TEMPLATE ID GOES HERE]", - "tracking_settings": { - "click_tracking": { - "enable": true, - "enable_text": true - }, - "ganalytics": { - "enable": true, - "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]", - "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]", - "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]", - "utm_name": "[NAME OF YOUR CAMPAIGN]", - "utm_term": "[IDENTIFY PAID KEYWORDS HERE]" - }, - "open_tracking": { - "enable": true, - "substitution_tag": "%opentrack" - }, - "subscription_tracking": { - "enable": true, - "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.", - "substitution_tag": "<%click here%>", - "text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>." - } - } -}'); -$response = $sg->client->mail()->send()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="mail_settings"></a> -# MAIL SETTINGS - -## Retrieve all mail settings - -**This endpoint allows you to retrieve a list of all mail settings.** - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings - - -```php -$query_params = json_decode('{"limit": 1, "offset": 1}'); -$response = $sg->client->mail_settings()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update address whitelist mail settings - -**This endpoint allows you to update your current email address whitelist settings.** - -The address whitelist setting whitelists a specified email address or domain for which mail should never be suppressed. For example, you own the domain example.com, and one or more of your recipients use email@example.com addresses, by placing example.com in the address whitelist setting, all bounces, blocks, and unsubscribes logged for that domain will be ignored and sent as if under normal sending conditions. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/address_whitelist - - -```php -$request_body = json_decode('{ - "enabled": true, - "list": [ - "email1@example.com", - "example.com" - ] -}'); -$response = $sg->client->mail_settings()->address_whitelist()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve address whitelist mail settings - -**This endpoint allows you to retrieve your current email address whitelist settings.** - -The address whitelist setting whitelists a specified email address or domain for which mail should never be suppressed. For example, you own the domain example.com, and one or more of your recipients use email@example.com addresses, by placing example.com in the address whitelist setting, all bounces, blocks, and unsubscribes logged for that domain will be ignored and sent as if under normal sending conditions. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/address_whitelist - - -```php -$response = $sg->client->mail_settings()->address_whitelist()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update BCC mail settings - -**This endpoint allows you to update your current BCC mail settings.** - -When the BCC mail setting is enabled, SendGrid will automatically send a blind carbon copy (BCC) to an address for every email sent without adding that address to the header. Please note that only one email address may be entered in this field, if you wish to distribute BCCs to multiple addresses you will need to create a distribution group or use forwarding rules. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/bcc - - -```php -$request_body = json_decode('{ - "email": "email@example.com", - "enabled": false -}'); -$response = $sg->client->mail_settings()->bcc()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all BCC mail settings - -**This endpoint allows you to retrieve your current BCC mail settings.** - -When the BCC mail setting is enabled, SendGrid will automatically send a blind carbon copy (BCC) to an address for every email sent without adding that address to the header. Please note that only one email address may be entered in this field, if you wish to distribute BCCs to multiple addresses you will need to create a distribution group or use forwarding rules. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/bcc - - -```php -$response = $sg->client->mail_settings()->bcc()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update bounce purge mail settings - -**This endpoint allows you to update your current bounce purge settings.** - -This setting allows you to set a schedule for SendGrid to automatically delete contacts from your soft and hard bounce suppression lists. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/bounce_purge - - -```php -$request_body = json_decode('{ - "enabled": true, - "hard_bounces": 5, - "soft_bounces": 5 -}'); -$response = $sg->client->mail_settings()->bounce_purge()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve bounce purge mail settings - -**This endpoint allows you to retrieve your current bounce purge settings.** - -This setting allows you to set a schedule for SendGrid to automatically delete contacts from your soft and hard bounce suppression lists. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/bounce_purge - - -```php -$response = $sg->client->mail_settings()->bounce_purge()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update footer mail settings - -**This endpoint allows you to update your current Footer mail settings.** - -The footer setting will insert a custom footer at the bottom of the text and HTML bodies. Use the embedded HTML editor and plain text entry fields to create the content of the footers to be inserted into your emails. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/footer - - -```php -$request_body = json_decode('{ - "enabled": true, - "html_content": "...", - "plain_content": "..." -}'); -$response = $sg->client->mail_settings()->footer()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve footer mail settings - -**This endpoint allows you to retrieve your current Footer mail settings.** - -The footer setting will insert a custom footer at the bottom of the text and HTML bodies. Use the embedded HTML editor and plain text entry fields to create the content of the footers to be inserted into your emails. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/footer - - -```php -$response = $sg->client->mail_settings()->footer()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update forward bounce mail settings - -**This endpoint allows you to update your current bounce forwarding mail settings.** - -Activating this setting allows you to specify an email address to which bounce reports are forwarded. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/forward_bounce - - -```php -$request_body = json_decode('{ - "email": "example@example.com", - "enabled": true -}'); -$response = $sg->client->mail_settings()->forward_bounce()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve forward bounce mail settings - -**This endpoint allows you to retrieve your current bounce forwarding mail settings.** - -Activating this setting allows you to specify an email address to which bounce reports are forwarded. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/forward_bounce - - -```php -$response = $sg->client->mail_settings()->forward_bounce()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update forward spam mail settings - -**This endpoint allows you to update your current Forward Spam mail settings.** - -Enabling the forward spam setting allows you to specify an email address to which spam reports will be forwarded. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/forward_spam - - -```php -$request_body = json_decode('{ - "email": "", - "enabled": false -}'); -$response = $sg->client->mail_settings()->forward_spam()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve forward spam mail settings - -**This endpoint allows you to retrieve your current Forward Spam mail settings.** - -Enabling the forward spam setting allows you to specify an email address to which spam reports will be forwarded. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/forward_spam - - -```php -$response = $sg->client->mail_settings()->forward_spam()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update plain content mail settings - -**This endpoint allows you to update your current Plain Content mail settings.** - -The plain content setting will automatically convert any plain text emails that you send to HTML before sending. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/plain_content - - -```php -$request_body = json_decode('{ - "enabled": false -}'); -$response = $sg->client->mail_settings()->plain_content()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve plain content mail settings - -**This endpoint allows you to retrieve your current Plain Content mail settings.** - -The plain content setting will automatically convert any plain text emails that you send to HTML before sending. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/plain_content - - -```php -$response = $sg->client->mail_settings()->plain_content()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update spam check mail settings - -**This endpoint allows you to update your current spam checker mail settings.** - -The spam checker filter notifies you when emails are detected that exceed a predefined spam threshold. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/spam_check - - -```php -$request_body = json_decode('{ - "enabled": true, - "max_score": 5, - "url": "url" -}'); -$response = $sg->client->mail_settings()->spam_check()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve spam check mail settings - -**This endpoint allows you to retrieve your current Spam Checker mail settings.** - -The spam checker filter notifies you when emails are detected that exceed a predefined spam threshold. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/spam_check - - -```php -$response = $sg->client->mail_settings()->spam_check()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update template mail settings - -**This endpoint allows you to update your current legacy email template settings.** - -This setting refers to our original email templates. We currently support more fully featured [transactional templates](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### PATCH /mail_settings/template - - -```php -$request_body = json_decode('{ - "enabled": true, - "html_content": "<% body %>" -}'); -$response = $sg->client->mail_settings()->template()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve legacy template mail settings - -**This endpoint allows you to retrieve your current legacy email template settings.** - -This setting refers to our original email templates. We currently support more fully featured [transactional templates](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -The legacy email template setting wraps an HTML template around your email content. This can be useful for sending out marketing email and/or other HTML formatted messages. - -Mail settings allow you to tell SendGrid specific things to do to every email that you send to your recipients over SendGrids [Web API](https://sendgrid.com/docs/API_Reference/Web_API/mail.html) or [SMTP Relay](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -### GET /mail_settings/template - - -```php -$response = $sg->client->mail_settings()->template()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="mailbox_providers"></a> -# MAILBOX PROVIDERS - -## Retrieve email statistics by mailbox provider. - -**This endpoint allows you to retrieve your email statistics segmented by recipient mailbox provider.** - -**We only store up to 7 days of email activity in our database.** By default, 500 items will be returned per request via the Advanced Stats API endpoints. - -Advanced Stats provide a more in-depth view of your email statistics and the actions taken by your recipients. You can segment these statistics by geographic location, device type, client type, browser, and mailbox provider. For more information about statistics, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/index.html). - -### GET /mailbox_providers/stats - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "mailbox_providers": "test_string", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01"}'); -$response = $sg->client->mailbox_providers()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="partner_settings"></a> -# PARTNER SETTINGS - -## Returns a list of all partner settings. - -**This endpoint allows you to retrieve a list of all partner settings that you can enable.** - -Our partner settings allow you to integrate your SendGrid account with our partners to increase your SendGrid experience and functionality. For more information about our partners, and how you can begin integrating with them, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/partners.html). - -### GET /partner_settings - - -```php -$query_params = json_decode('{"limit": 1, "offset": 1}'); -$response = $sg->client->partner_settings()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Updates New Relic partner settings. - -**This endpoint allows you to update or change your New Relic partner settings.** - -Our partner settings allow you to integrate your SendGrid account with our partners to increase your SendGrid experience and functionality. For more information about our partners, and how you can begin integrating with them, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/partners.html). - -By integrating with New Relic, you can send your SendGrid email statistics to your New Relic Dashboard. If you enable this setting, your stats will be sent to New Relic every 5 minutes. You will need your New Relic License Key to enable this setting. For more information, please see our [Classroom](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/new_relic.html). - -### PATCH /partner_settings/new_relic - - -```php -$request_body = json_decode('{ - "enable_subuser_statistics": true, - "enabled": true, - "license_key": "" -}'); -$response = $sg->client->partner_settings()->new_relic()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Returns all New Relic partner settings. - -**This endpoint allows you to retrieve your current New Relic partner settings.** - -Our partner settings allow you to integrate your SendGrid account with our partners to increase your SendGrid experience and functionality. For more information about our partners, and how you can begin integrating with them, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/partners.html). - -By integrating with New Relic, you can send your SendGrid email statistics to your New Relic Dashboard. If you enable this setting, your stats will be sent to New Relic every 5 minutes. You will need your New Relic License Key to enable this setting. For more information, please see our [Classroom](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/new_relic.html). - -### GET /partner_settings/new_relic - - -```php -$response = $sg->client->partner_settings()->new_relic()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="scopes"></a> -# SCOPES - -## Retrieve a list of scopes for which this user has access. - -**This endpoint returns a list of all scopes that this user has access to.** - -API Keys can be used to authenticate the use of [SendGrids v3 Web API](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html), or the [Mail API Endpoint](https://sendgrid.com/docs/API_Reference/Web_API/mail.html). API Keys may be assigned certain permissions, or scopes, that limit which API endpoints they are able to access. For a more detailed explanation of how you can use API Key permissios, please visit our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html#-API-Key-Permissions) or [Classroom](https://sendgrid.com/docs/Classroom/Basics/API/api_key_permissions.html). - -### GET /scopes - - -```php -$response = $sg->client->scopes()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="senders"></a> -# SENDERS - -## Create a Sender Identity - -**This endpoint allows you to create a new sender identity.** - -*You may create up to 100 unique sender identities.* - -Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -### POST /senders - - -```php -$request_body = json_decode('{ - "address": "123 Elm St.", - "address_2": "Apt. 456", - "city": "Denver", - "country": "United States", - "from": { - "email": "from@example.com", - "name": "Example INC" - }, - "nickname": "My Sender ID", - "reply_to": { - "email": "replyto@example.com", - "name": "Example INC" - }, - "state": "Colorado", - "zip": "80202" -}'); -$response = $sg->client->senders()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Get all Sender Identities - -**This endpoint allows you to retrieve a list of all sender identities that have been created for your account.** - -Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -### GET /senders - - -```php -$response = $sg->client->senders()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a Sender Identity - -**This endpoint allows you to update a sender identity.** - -Updates to `from.email` require re-verification. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -Partial updates are allowed, but fields that are marked as "required" in the POST (create) endpoint must not be nil if that field is included in the PATCH request. - -### PATCH /senders/{sender_id} - - -```php -$request_body = json_decode('{ - "address": "123 Elm St.", - "address_2": "Apt. 456", - "city": "Denver", - "country": "United States", - "from": { - "email": "from@example.com", - "name": "Example INC" - }, - "nickname": "My Sender ID", - "reply_to": { - "email": "replyto@example.com", - "name": "Example INC" - }, - "state": "Colorado", - "zip": "80202" -}'); -$sender_id = "test_url_param"; -$response = $sg->client->senders()->_($sender_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## View a Sender Identity - -**This endpoint allows you to retrieve a specific sender identity.** - -Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -### GET /senders/{sender_id} - - -```php -$sender_id = "test_url_param"; -$response = $sg->client->senders()->_($sender_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Sender Identity - -**This endoint allows you to delete one of your sender identities.** - -Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -### DELETE /senders/{sender_id} - - -```php -$sender_id = "test_url_param"; -$response = $sg->client->senders()->_($sender_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Resend Sender Identity Verification - -**This enpdoint allows you to resend a sender identity verification email.** - -Sender Identities are required to be verified before use. If your domain has been whitelabeled it will auto verify on creation. Otherwise an email will be sent to the `from.email`. - -### POST /senders/{sender_id}/resend_verification - - -```php -$sender_id = "test_url_param"; -$response = $sg->client->senders()->_($sender_id)->resend_verification()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="stats"></a> -# STATS - -## Retrieve global email statistics - -**This endpoint allows you to retrieve all of your global email statistics between a given date range.** - -Parent accounts will see aggregated stats for their account and all subuser accounts. Subuser accounts will only see their own stats. - -### GET /stats - - -```php -$query_params = json_decode('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}'); -$response = $sg->client->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="subusers"></a> -# SUBUSERS - -## Create Subuser - -This endpoint allows you to retrieve a list of all of your subusers. You can choose to retrieve specific subusers as well as limit the results that come back from the API. - -For more information about Subusers: - -* [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html) -* [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html) - -### POST /subusers - - -```php -$request_body = json_decode('{ - "email": "John@example.com", - "ips": [ - "1.1.1.1", - "2.2.2.2" - ], - "password": "johns_password", - "username": "John@example.com" -}'); -$response = $sg->client->subusers()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## List all Subusers - -This endpoint allows you to retrieve a list of all of your subusers. You can choose to retrieve specific subusers as well as limit the results that come back from the API. - -For more information about Subusers: - -* [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html) -* [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html) - -### GET /subusers - - -```php -$query_params = json_decode('{"username": "test_string", "limit": 1, "offset": 1}'); -$response = $sg->client->subusers()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Subuser Reputations - -Subuser sender reputations give a good idea how well a sender is doing with regards to how recipients and recipient servers react to the mail that is being received. When a bounce, spam report, or other negative action happens on a sent email, it will effect your sender rating. - -This endpoint allows you to request the reputations for your subusers. - -### GET /subusers/reputations - - -```php -$query_params = json_decode('{"usernames": "test_string"}'); -$response = $sg->client->subusers()->reputations()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve email statistics for your subusers. - -**This endpoint allows you to retrieve the email statistics for the given subusers.** - -You may retrieve statistics for up to 10 different subusers by including an additional _subusers_ parameter for each additional subuser. - -While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings. - -For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html). - -### GET /subusers/stats - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "subusers": "test_string"}'); -$response = $sg->client->subusers()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve monthly stats for all subusers - -**This endpoint allows you to retrieve the monthly email statistics for all subusers over the given date range.** - -While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats for your subusers. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings. - -When using the `sort_by_metric` to sort your stats by a specific metric, you can not sort by the following metrics: -`bounce_drops`, `deferred`, `invalid_emails`, `processed`, `spam_report_drops`, `spam_reports`, or `unsubscribe_drops`. - -For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html). - -### GET /subusers/stats/monthly - - -```php -$query_params = json_decode('{"subuser": "test_string", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "date": "test_string", "sort_by_direction": "asc"}'); -$response = $sg->client->subusers()->stats()->monthly()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve the totals for each email statistic metric for all subusers. - -**This endpoint allows you to retrieve the total sums of each email statistic metric for all subusers over the given date range.** - - -While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings. - -For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html). - -### GET /subusers/stats/sums - - -```php -$query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}'); -$response = $sg->client->subusers()->stats()->sums()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Enable/disable a subuser - -This endpoint allows you to enable or disable a subuser. - -For more information about Subusers: - -* [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html) -* [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html) - -### PATCH /subusers/{subuser_name} - - -```php -$request_body = json_decode('{ - "disabled": false -}'); -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a subuser - -This endpoint allows you to delete a subuser. This is a permanent action, once deleted a subuser cannot be retrieved. - -For more information about Subusers: - -* [User Guide > Subusers](https://sendgrid.com/docs/User_Guide/Settings/Subusers/index.html) -* [Classroom > How do I add more subusers to my account?](https://sendgrid.com/docs/Classroom/Basics/Account/how_do_i_add_more_subusers_to_my_account.html) - -### DELETE /subusers/{subuser_name} - - -```php -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update IPs assigned to a subuser - -Each subuser should be assigned to an IP address, from which all of this subuser's mail will be sent. Often, this is the same IP as the parent account, but each subuser can have their own, or multiple, IP addresses as well. - -More information: - -* [How to request more IPs](https://sendgrid.com/docs/Classroom/Basics/Account/adding_an_additional_dedicated_ip_to_your_account.html) -* [IPs can be whitelabeled](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/ips.html) - -### PUT /subusers/{subuser_name}/ips - - -```php -$request_body = json_decode('[ - "127.0.0.1" -]'); -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->ips()->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Monitor Settings for a subuser - -Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails. - -### PUT /subusers/{subuser_name}/monitor - - -```php -$request_body = json_decode('{ - "email": "example@example.com", - "frequency": 500 -}'); -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->monitor()->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create monitor settings - -Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails. - -### POST /subusers/{subuser_name}/monitor - - -```php -$request_body = json_decode('{ - "email": "example@example.com", - "frequency": 50000 -}'); -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->monitor()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve monitor settings for a subuser - -Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails. - -### GET /subusers/{subuser_name}/monitor - - -```php -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->monitor()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete monitor settings - -Subuser monitor settings allow you to receive a sample of an outgoing message by a specific customer at a specific frequency of emails. - -### DELETE /subusers/{subuser_name}/monitor - - -```php -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->monitor()->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve the monthly email statistics for a single subuser - -**This endpoint allows you to retrive the monthly email statistics for a specific subuser.** - -While you can always view the statistics for all email activity on your account, subuser statistics enable you to view specific segments of your stats for your subusers. Emails sent, bounces, and spam reports are always tracked for subusers. Unsubscribes, clicks, and opens are tracked if you have enabled the required settings. - -When using the `sort_by_metric` to sort your stats by a specific metric, you can not sort by the following metrics: -`bounce_drops`, `deferred`, `invalid_emails`, `processed`, `spam_report_drops`, `spam_reports`, or `unsubscribe_drops`. - -For more information, see our [User Guide](https://sendgrid.com/docs/User_Guide/Statistics/subuser.html). - -### GET /subusers/{subuser_name}/stats/monthly - - -```php -$query_params = json_decode('{"date": "test_string", "sort_by_direction": "asc", "limit": 1, "sort_by_metric": "test_string", "offset": 1}'); -$subuser_name = "test_url_param"; -$response = $sg->client->subusers()->_($subuser_name)->stats()->monthly()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="suppression"></a> -# SUPPRESSION - -## Retrieve all blocks - -**This endpoint allows you to retrieve a list of all email addresses that are currently on your blocks list.** - -[Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html). - -### GET /suppression/blocks - - -```php -$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); -$response = $sg->client->suppression()->blocks()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete blocks - -**This endpoint allows you to delete all email addresses on your blocks list.** - -There are two options for deleting blocked emails: - -1. You can delete all blocked emails by setting `delete_all` to true in the request body. -2. You can delete some blocked emails by specifying the email addresses in an array in the request body. - -[Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html). - -### DELETE /suppression/blocks - - -```php -$request_body = json_decode('{ - "delete_all": false, - "emails": [ - "example1@example.com", - "example2@example.com" - ] -}'); -$response = $sg->client->suppression()->blocks()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific block - -**This endpoint allows you to retrieve a specific email address from your blocks list.** - -[Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html). - -### GET /suppression/blocks/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->blocks()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a specific block - -**This endpoint allows you to delete a specific email address from your blocks list.** - -[Blocks](https://sendgrid.com/docs/Glossary/blocks.html) happen when your message was rejected for a reason related to the message, not the recipient address. This can happen when your mail server IP address has been added to a blacklist or blocked by an ISP, or if the message content is flagged by a filter on the receiving server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/blocks.html). - -### DELETE /suppression/blocks/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->blocks()->_($email)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all bounces - -**This endpoint allows you to retrieve all of your bounces.** - -Bounces are messages that are returned to the server that sent it. - -For more information see: - -* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information -* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html) - -### GET /suppression/bounces - - -```php -$query_params = json_decode('{"start_time": 1, "end_time": 1}'); -$response = $sg->client->suppression()->bounces()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete bounces - -**This endpoint allows you to delete all of your bounces. You can also use this endpoint to remove a specific email address from your bounce list.** - -Bounces are messages that are returned to the server that sent it. - -For more information see: - -* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information -* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html) -* [Classroom > List Scrubbing Guide](https://sendgrid.com/docs/Classroom/Deliver/list_scrubbing.html) - -Note: the `delete_all` and `emails` parameters should be used independently of each other as they have different purposes. - -### DELETE /suppression/bounces - - -```php -$request_body = json_decode('{ - "delete_all": true, - "emails": [ - "example@example.com", - "example2@example.com" - ] -}'); -$response = $sg->client->suppression()->bounces()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Bounce - -**This endpoint allows you to retrieve a specific bounce for a given email address.** - -Bounces are messages that are returned to the server that sent it. - -For more information see: - -* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information -* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html) -* [Classroom > List Scrubbing Guide](https://sendgrid.com/docs/Classroom/Deliver/list_scrubbing.html) - -### GET /suppression/bounces/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->bounces()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a bounce - -**This endpoint allows you to remove an email address from your bounce list.** - -Bounces are messages that are returned to the server that sent it. This endpoint allows you to delete a single email addresses from your bounce list. - -For more information see: - -* [User Guide > Bounces](https://sendgrid.com/docs/User_Guide/Suppressions/bounces.html) for more information -* [Glossary > Bounces](https://sendgrid.com/docs/Glossary/Bounces.html) -* [Classroom > List Scrubbing Guide](https://sendgrid.com/docs/Classroom/Deliver/list_scrubbing.html) - -### DELETE /suppression/bounces/{email} - - -```php -$query_params = json_decode('{"email_address": "example@example.com"}'); -$email = "test_url_param"; -$response = $sg->client->suppression()->bounces()->_($email)->delete(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all invalid emails - -**This endpoint allows you to retrieve a list of all invalid email addresses.** - -An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server. - -Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html). - -### GET /suppression/invalid_emails - - -```php -$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); -$response = $sg->client->suppression()->invalid_emails()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete invalid emails - -**This endpoint allows you to remove email addresses from your invalid email address list.** - -There are two options for deleting invalid email addresses: - -1) You can delete all invalid email addresses by setting `delete_all` to true in the request body. -2) You can delete some invalid email addresses by specifying certain addresses in an array in the request body. - -An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server. - -Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html). - -### DELETE /suppression/invalid_emails - - -```php -$request_body = json_decode('{ - "delete_all": false, - "emails": [ - "example1@example.com", - "example2@example.com" - ] -}'); -$response = $sg->client->suppression()->invalid_emails()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific invalid email - -**This endpoint allows you to retrieve a specific invalid email addresses.** - -An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server. - -Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html). - -### GET /suppression/invalid_emails/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->invalid_emails()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a specific invalid email - -**This endpoint allows you to remove a specific email address from the invalid email address list.** - -An invalid email occurs when you attempt to send email to an address that is formatted in a manner that does not meet internet email format standards or the email does not exist at the recipients mail server. - -Examples include addresses without the @ sign or addresses that include certain special characters and/or spaces. This response can come from our own server or the recipient mail server. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/invalid_emails.html). - -### DELETE /suppression/invalid_emails/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->invalid_emails()->_($email)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific spam report - -**This endpoint allows you to retrieve a specific spam report.** - -[Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html). - -### GET /suppression/spam_report/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->spam_report()->_($email)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a specific spam report - -**This endpoint allows you to delete a specific spam report.** - -[Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html). - -### DELETE /suppression/spam_report/{email} - - -```php -$email = "test_url_param"; -$response = $sg->client->suppression()->spam_report()->_($email)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all spam reports - -**This endpoint allows you to retrieve all spam reports.** - -[Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html). - -### GET /suppression/spam_reports - - -```php -$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); -$response = $sg->client->suppression()->spam_reports()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete spam reports - -**This endpoint allows you to delete your spam reports.** - -There are two options for deleting spam reports: - -1) You can delete all spam reports by setting "delete_all" to true in the request body. -2) You can delete some spam reports by specifying the email addresses in an array in the request body. - -[Spam reports](https://sendgrid.com/docs/Glossary/spam_reports.html) happen when a recipient indicates that they think your email is [spam](https://sendgrid.com/docs/Glossary/spam.html) and then their email provider reports this to SendGrid. - -For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/spam_reports.html). - -### DELETE /suppression/spam_reports - - -```php -$request_body = json_decode('{ - "delete_all": false, - "emails": [ - "example1@example.com", - "example2@example.com" - ] -}'); -$response = $sg->client->suppression()->spam_reports()->delete($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all global suppressions - -**This endpoint allows you to retrieve a list of all email address that are globally suppressed.** - -A global suppression (or global unsubscribe) is an email address of a recipient who does not want to receive any of your messages. A globally suppressed recipient will be removed from any email you send. For more information, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Suppressions/global_unsubscribes.html). - -### GET /suppression/unsubscribes - - -```php -$query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); -$response = $sg->client->suppression()->unsubscribes()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="templates"></a> -# TEMPLATES - -## Create a transactional template. - -**This endpoint allows you to create a transactional template.** - -Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts. - -Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -### POST /templates - - -```php -$request_body = json_decode('{ - "name": "example_name" -}'); -$response = $sg->client->templates()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all transactional templates. - -**This endpoint allows you to retrieve all transactional templates.** - -Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts. - -Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -### GET /templates - - -```php -$response = $sg->client->templates()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Edit a transactional template. - -**This endpoint allows you to edit a transactional template.** - -Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts. - -Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - - -### PATCH /templates/{template_id} - - -```php -$request_body = json_decode('{ - "name": "new_example_name" -}'); -$template_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a single transactional template. - -**This endpoint allows you to retrieve a single transactional template.** - -Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts. - -Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - - -### GET /templates/{template_id} - - -```php -$template_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a template. - -**This endpoint allows you to delete a transactional template.** - -Each user can create up to 300 different transactional templates. Transactional templates are specific to accounts and subusers. Templates created on a parent account will not be accessible from the subuser accounts. - -Transactional templates are templates created specifically for transactional email and are not to be confused with [Marketing Campaigns templates](https://sendgrid.com/docs/User_Guide/Marketing_Campaigns/templates.html). For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - - -### DELETE /templates/{template_id} - - -```php -$template_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create a new transactional template version. - -**This endpoint allows you to create a new version of a template.** - -Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates. - -For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - - -### POST /templates/{template_id}/versions - - -```php -$request_body = json_decode('{ - "active": 1, - "html_content": "<%body%>", - "name": "example_version_name", - "plain_content": "<%body%>", - "subject": "<%subject%>", - "template_id": "ddb96bbc-9b92-425e-8979-99464621b543" -}'); -$template_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->versions()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Edit a transactional template version. - -**This endpoint allows you to edit a version of one of your transactional templates.** - -Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates. - -For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| template_id | string | The ID of the original template | -| version_id | string | The ID of the template version | - -### PATCH /templates/{template_id}/versions/{version_id} - - -```php -$request_body = json_decode('{ - "active": 1, - "html_content": "<%body%>", - "name": "updated_example_name", - "plain_content": "<%body%>", - "subject": "<%subject%>" -}'); -$template_id = "test_url_param"; -$version_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->versions()->_($version_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific transactional template version. - -**This endpoint allows you to retrieve a specific version of a template.** - -Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates. - -For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| template_id | string | The ID of the original template | -| version_id | string | The ID of the template version | - -### GET /templates/{template_id}/versions/{version_id} - - -```php -$template_id = "test_url_param"; -$version_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->versions()->_($version_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a transactional template version. - -**This endpoint allows you to delete one of your transactional template versions.** - -Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates. - -For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| template_id | string | The ID of the original template | -| version_id | string | The ID of the template version | - -### DELETE /templates/{template_id}/versions/{version_id} - - -```php -$template_id = "test_url_param"; -$version_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->versions()->_($version_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Activate a transactional template version. - -**This endpoint allows you to activate a version of one of your templates.** - -Each transactional template can have multiple versions, each version with its own subject and content. Each user can have up to 300 versions across across all templates. - - -For more information about transactional templates, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| template_id | string | The ID of the original template | -| version_id | string | The ID of the template version | - -### POST /templates/{template_id}/versions/{version_id}/activate - - -```php -$template_id = "test_url_param"; -$version_id = "test_url_param"; -$response = $sg->client->templates()->_($template_id)->versions()->_($version_id)->activate()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="tracking_settings"></a> -# TRACKING SETTINGS - -## Retrieve Tracking Settings - -**This endpoint allows you to retrieve a list of all tracking settings that you can enable on your account.** - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### GET /tracking_settings - - -```php -$query_params = json_decode('{"limit": 1, "offset": 1}'); -$response = $sg->client->tracking_settings()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Click Tracking Settings - -**This endpoint allows you to change your current click tracking setting. You can enable, or disable, click tracking using this endpoint.** - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### PATCH /tracking_settings/click - - -```php -$request_body = json_decode('{ - "enabled": true -}'); -$response = $sg->client->tracking_settings()->click()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Click Track Settings - -**This endpoint allows you to retrieve your current click tracking setting.** - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### GET /tracking_settings/click - - -```php -$response = $sg->client->tracking_settings()->click()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Google Analytics Settings - -**This endpoint allows you to update your current setting for Google Analytics.** - -For more information about using Google Analytics, please refer to [Googles URL Builder](https://support.google.com/analytics/answer/1033867?hl=en) and their article on ["Best Practices for Campaign Building"](https://support.google.com/analytics/answer/1037445). - -We default the settings to Googles recommendations. For more information, see [Google Analytics Demystified](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/google_analytics_demystified_ga_statistics_vs_sg_statistics.html). - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### PATCH /tracking_settings/google_analytics - - -```php -$request_body = json_decode('{ - "enabled": true, - "utm_campaign": "website", - "utm_content": "", - "utm_medium": "email", - "utm_source": "sendgrid.com", - "utm_term": "" -}'); -$response = $sg->client->tracking_settings()->google_analytics()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Google Analytics Settings - -**This endpoint allows you to retrieve your current setting for Google Analytics.** - -For more information about using Google Analytics, please refer to [Googles URL Builder](https://support.google.com/analytics/answer/1033867?hl=en) and their article on ["Best Practices for Campaign Building"](https://support.google.com/analytics/answer/1037445). - -We default the settings to Googles recommendations. For more information, see [Google Analytics Demystified](https://sendgrid.com/docs/Classroom/Track/Collecting_Data/google_analytics_demystified_ga_statistics_vs_sg_statistics.html). - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### GET /tracking_settings/google_analytics - - -```php -$response = $sg->client->tracking_settings()->google_analytics()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Open Tracking Settings - -**This endpoint allows you to update your current settings for open tracking.** - -Open Tracking adds an invisible image at the end of the email which can track email opens. If the email recipient has images enabled on their email client, a request to SendGrids server for the invisible image is executed and an open event is logged. These events are logged in the Statistics portal, Email Activity interface, and are reported by the Event Webhook. - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### PATCH /tracking_settings/open - - -```php -$request_body = json_decode('{ - "enabled": true -}'); -$response = $sg->client->tracking_settings()->open()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Get Open Tracking Settings - -**This endpoint allows you to retrieve your current settings for open tracking.** - -Open Tracking adds an invisible image at the end of the email which can track email opens. If the email recipient has images enabled on their email client, a request to SendGrids server for the invisible image is executed and an open event is logged. These events are logged in the Statistics portal, Email Activity interface, and are reported by the Event Webhook. - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### GET /tracking_settings/open - - -```php -$response = $sg->client->tracking_settings()->open()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Subscription Tracking Settings - -**This endpoint allows you to update your current settings for subscription tracking.** - -Subscription tracking adds links to the bottom of your emails that allows your recipients to subscribe to, or unsubscribe from, your emails. - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### PATCH /tracking_settings/subscription - - -```php -$request_body = json_decode('{ - "enabled": true, - "html_content": "html content", - "landing": "landing page html", - "plain_content": "text content", - "replace": "replacement tag", - "url": "url" -}'); -$response = $sg->client->tracking_settings()->subscription()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Subscription Tracking Settings - -**This endpoint allows you to retrieve your current settings for subscription tracking.** - -Subscription tracking adds links to the bottom of your emails that allows your recipients to subscribe to, or unsubscribe from, your emails. - -You can track a variety of the actions your recipients may take when interacting with your emails including opening your emails, clicking on links in your emails, and subscribing to (or unsubscribing from) your emails. - -For more information about tracking, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/tracking.html). - -### GET /tracking_settings/subscription - - -```php -$response = $sg->client->tracking_settings()->subscription()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="user"></a> -# USER - -## Get a user's account information. - -**This endpoint allows you to retrieve your user account details.** - -Your user's account information includes the user's account type and reputation. - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### GET /user/account - - -```php -$response = $sg->client->user()->account()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve your credit balance - -**This endpoint allows you to retrieve the current credit balance for your account.** - -Your monthly credit allotment limits the number of emails you may send before incurring overage charges. For more information about credits and billing, please visit our [Clssroom](https://sendgrid.com/docs/Classroom/Basics/Billing/billing_info_and_faqs.html). - -### GET /user/credits - - -```php -$response = $sg->client->user()->credits()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update your account email address - -**This endpoint allows you to update the email address currently on file for your account.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### PUT /user/email - - -```php -$request_body = json_decode('{ - "email": "example@example.com" -}'); -$response = $sg->client->user()->email()->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve your account email address - -**This endpoint allows you to retrieve the email address currently on file for your account.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### GET /user/email - - -```php -$response = $sg->client->user()->email()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update your password - -**This endpoint allows you to update your password.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### PUT /user/password - - -```php -$request_body = json_decode('{ - "new_password": "new_password", - "old_password": "old_password" -}'); -$response = $sg->client->user()->password()->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a user's profile - -**This endpoint allows you to update your current profile details.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -It should be noted that any one or more of the parameters can be updated via the PATCH /user/profile endpoint. The only requirement is that you include at least one when you PATCH. - -### PATCH /user/profile - - -```php -$request_body = json_decode('{ - "city": "Orange", - "first_name": "Example", - "last_name": "User" -}'); -$response = $sg->client->user()->profile()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Get a user's profile - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### GET /user/profile - - -```php -$response = $sg->client->user()->profile()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Cancel or pause a scheduled send - -**This endpoint allows you to cancel or pause an email that has been scheduled to be sent.** - -If the maximum number of cancellations/pauses are added, HTTP 400 will -be returned. - -The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled. - -### POST /user/scheduled_sends - - -```php -$request_body = json_decode('{ - "batch_id": "YOUR_BATCH_ID", - "status": "pause" -}'); -$response = $sg->client->user()->scheduled_sends()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all scheduled sends - -**This endpoint allows you to retrieve all cancel/paused scheduled send information.** - -The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled. - -### GET /user/scheduled_sends - - -```php -$response = $sg->client->user()->scheduled_sends()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update user scheduled send information - -**This endpoint allows you to update the status of a scheduled send for the given `batch_id`.** - -The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled. - -### PATCH /user/scheduled_sends/{batch_id} - - -```php -$request_body = json_decode('{ - "status": "pause" -}'); -$batch_id = "test_url_param"; -$response = $sg->client->user()->scheduled_sends()->_($batch_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve scheduled send - -**This endpoint allows you to retrieve the cancel/paused scheduled send information for a specific `batch_id`.** - -The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled. - -### GET /user/scheduled_sends/{batch_id} - - -```php -$batch_id = "test_url_param"; -$response = $sg->client->user()->scheduled_sends()->_($batch_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a cancellation or pause of a scheduled send - -**This endpoint allows you to delete the cancellation/pause of a scheduled send.** - -The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID included in the SMTPAPI header.Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled. - -### DELETE /user/scheduled_sends/{batch_id} - - -```php -$batch_id = "test_url_param"; -$response = $sg->client->user()->scheduled_sends()->_($batch_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Enforced TLS settings - -**This endpoint allows you to update your current Enforced TLS settings.** - -The Enforced TLS settings specify whether or not the recipient is required to support TLS or have a valid certificate. See the [SMTP Ports User Guide](https://sendgrid.com/docs/Classroom/Basics/Email_Infrastructure/smtp_ports.html) for more information on opportunistic TLS. - -**Note:** If either setting is enabled and the recipient does not support TLS or have a valid certificate, we drop the message and send a block event with TLS required but not supported as the description. - -### PATCH /user/settings/enforced_tls - - -```php -$request_body = json_decode('{ - "require_tls": true, - "require_valid_cert": false -}'); -$response = $sg->client->user()->settings()->enforced_tls()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve current Enforced TLS settings. - -**This endpoint allows you to retrieve your current Enforced TLS settings.** - -The Enforced TLS settings specify whether or not the recipient is required to support TLS or have a valid certificate. See the [SMTP Ports User Guide](https://sendgrid.com/docs/Classroom/Basics/Email_Infrastructure/smtp_ports.html) for more information on opportunistic TLS. - -**Note:** If either setting is enabled and the recipient does not support TLS or have a valid certificate, we drop the message and send a block event with TLS required but not supported as the description. - -### GET /user/settings/enforced_tls - - -```php -$response = $sg->client->user()->settings()->enforced_tls()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update your username - -**This endpoint allows you to update the username for your account.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### PUT /user/username - - -```php -$request_body = json_decode('{ - "username": "test_username" -}'); -$response = $sg->client->user()->username()->put($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve your username - -**This endpoint allows you to retrieve your current account username.** - -Keeping your user profile up to date is important. This will help SendGrid to verify who you are as well as contact you should we need to. - -For more information about your user profile: - -* [SendGrid Account Settings](https://sendgrid.com/docs/User_Guide/Settings/account.html) - -### GET /user/username - - -```php -$response = $sg->client->user()->username()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update Event Notification Settings - -**This endpoint allows you to update your current event webhook settings.** - -If an event type is marked as `true`, then the event webhook will include information about that event. - -SendGrids Event Webhook will notify a URL of your choice via HTTP POST with information about events that occur as SendGrid processes your email. - -Common uses of this data are to remove unsubscribes, react to spam reports, determine unengaged recipients, identify bounced email addresses, or create advanced analytics of your email program. - -### PATCH /user/webhooks/event/settings - - -```php -$request_body = json_decode('{ - "bounce": true, - "click": true, - "deferred": true, - "delivered": true, - "dropped": true, - "enabled": true, - "group_resubscribe": true, - "group_unsubscribe": true, - "open": true, - "processed": true, - "spam_report": true, - "unsubscribe": true, - "url": "url" -}'); -$response = $sg->client->user()->webhooks()->event()->settings()->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Event Webhook settings - -**This endpoint allows you to retrieve your current event webhook settings.** - -If an event type is marked as `true`, then the event webhook will include information about that event. - -SendGrids Event Webhook will notify a URL of your choice via HTTP POST with information about events that occur as SendGrid processes your email. - -Common uses of this data are to remove unsubscribes, react to spam reports, determine unengaged recipients, identify bounced email addresses, or create advanced analytics of your email program. - -### GET /user/webhooks/event/settings - - -```php -$response = $sg->client->user()->webhooks()->event()->settings()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Test Event Notification Settings - -**This endpoint allows you to test your event webhook by sending a fake event notification post to the provided URL.** - -SendGrids Event Webhook will notify a URL of your choice via HTTP POST with information about events that occur as SendGrid processes your email. - -Common uses of this data are to remove unsubscribes, react to spam reports, determine unengaged recipients, identify bounced email addresses, or create advanced analytics of your email program. - -### POST /user/webhooks/event/test - - -```php -$request_body = json_decode('{ - "url": "url" -}'); -$response = $sg->client->user()->webhooks()->event()->test()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create a parse setting - -**This endpoint allows you to create a new inbound parse setting.** - -The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the content, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). - -### POST /user/webhooks/parse/settings - - -```php -$request_body = json_decode('{ - "hostname": "myhostname.com", - "send_raw": false, - "spam_check": true, - "url": "http://email.myhosthame.com" -}'); -$response = $sg->client->user()->webhooks()->parse()->settings()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all parse settings - -**This endpoint allows you to retrieve all of your current inbound parse settings.** - -The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). - -### GET /user/webhooks/parse/settings - - -```php -$response = $sg->client->user()->webhooks()->parse()->settings()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a parse setting - -**This endpoint allows you to update a specific inbound parse setting.** - -The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). - -### PATCH /user/webhooks/parse/settings/{hostname} - - -```php -$request_body = json_decode('{ - "send_raw": true, - "spam_check": false, - "url": "http://newdomain.com/parse" -}'); -$hostname = "test_url_param"; -$response = $sg->client->user()->webhooks()->parse()->settings()->_($hostname)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a specific parse setting - -**This endpoint allows you to retrieve a specific inbound parse setting.** - -The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). - -### GET /user/webhooks/parse/settings/{hostname} - - -```php -$hostname = "test_url_param"; -$response = $sg->client->user()->webhooks()->parse()->settings()->_($hostname)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a parse setting - -**This endpoint allows you to delete a specific inbound parse setting.** - -The inbound parse webhook allows you to have incoming emails parsed, extracting some or all of the contnet, and then have that content POSTed by SendGrid to a URL of your choosing. For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Webhooks/parse.html). - -### DELETE /user/webhooks/parse/settings/{hostname} - - -```php -$hostname = "test_url_param"; -$response = $sg->client->user()->webhooks()->parse()->settings()->_($hostname)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieves Inbound Parse Webhook statistics. - -**This endpoint allows you to retrieve the statistics for your Parse Webhook useage.** - -SendGrid's Inbound Parse Webhook allows you to parse the contents and attachments of incomming emails. The Parse API can then POST the parsed emails to a URL that you specify. The Inbound Parse Webhook cannot parse messages greater than 20MB in size, including all attachments. - -There are a number of pre-made integrations for the SendGrid Parse Webhook which make processing events easy. You can find these integrations in the [Library Index](https://sendgrid.com/docs/Integrate/libraries.html#-Webhook-Libraries). - -### GET /user/webhooks/parse/stats - - -```php -$query_params = json_decode('{"aggregated_by": "day", "limit": "test_string", "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": "test_string"}'); -$response = $sg->client->user()->webhooks()->parse()->stats()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -<a name="whitelabel"></a> -# WHITELABEL - -## Create a domain whitelabel. - -**This endpoint allows you to create a whitelabel for one of your domains.** - -If you are creating a domain whitelabel that you would like a subuser to use, you have two options: -1. Use the "username" parameter. This allows you to create a whitelabel on behalf of your subuser. This means the subuser is able to see and modify the created whitelabel. -2. Use the Association workflow (see Associate Domain section). This allows you to assign a whitelabel created by the parent to a subuser. This means the subuser will default to the assigned whitelabel, but will not be able to see or modify that whitelabel. However, if the subuser creates their own whitelabel it will overwrite the assigned whitelabel. - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -### POST /whitelabel/domains - - -```php -$request_body = json_decode('{ - "automatic_security": false, - "custom_spf": true, - "default": true, - "domain": "example.com", - "ips": [ - "192.168.1.1", - "192.168.1.2" - ], - "subdomain": "news", - "username": "john@example.com" -}'); -$response = $sg->client->whitelabel()->domains()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## List all domain whitelabels. - -**This endpoint allows you to retrieve a list of all domain whitelabels you have created.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - - -### GET /whitelabel/domains - - -```php -$query_params = json_decode('{"username": "test_string", "domain": "test_string", "exclude_subusers": "true", "limit": 1, "offset": 1}'); -$response = $sg->client->whitelabel()->domains()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Get the default domain whitelabel. - -**This endpoint allows you to retrieve the default whitelabel for a domain.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| domain | string |The domain to find a default domain whitelabel for. | - -### GET /whitelabel/domains/default - - -```php -$response = $sg->client->whitelabel()->domains()->default()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## List the domain whitelabel associated with the given user. - -**This endpoint allows you to retrieve all of the whitelabels that have been assigned to a specific subuser.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| username | string | Username of the subuser to find associated whitelabels for. | - -### GET /whitelabel/domains/subuser - - -```php -$response = $sg->client->whitelabel()->domains()->subuser()->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Disassociate a domain whitelabel from a given user. - -**This endpoint allows you to disassociate a specific whitelabel from a subuser.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Required? | Description | -|---|---|---|---| -| username | string | required | Username for the subuser to find associated whitelabels for. | - -### DELETE /whitelabel/domains/subuser - - -```php -$response = $sg->client->whitelabel()->domains()->subuser()->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a domain whitelabel. - -**This endpoint allows you to update the settings for a domain whitelabel.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -### PATCH /whitelabel/domains/{domain_id} - - -```php -$request_body = json_decode('{ - "custom_spf": true, - "default": false -}'); -$domain_id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($domain_id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a domain whitelabel. - -**This endpoint allows you to retrieve a specific domain whitelabel.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - - -### GET /whitelabel/domains/{domain_id} - - -```php -$domain_id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($domain_id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a domain whitelabel. - -**This endpoint allows you to delete a domain whitelabel.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -### DELETE /whitelabel/domains/{domain_id} - - -```php -$domain_id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($domain_id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Associate a domain whitelabel with a given user. - -**This endpoint allows you to associate a specific domain whitelabel with a subuser.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -Domain whitelabels can be associated with (i.e. assigned to) subusers from a parent account. This functionality allows subusers to send mail using their parent's whitelabels. To associate a whitelabel with a subuser, the parent account must first create the whitelabel and validate it. The the parent may then associate the whitelabel via the subuser management tools. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| domain_id | integer | ID of the domain whitelabel to associate with the subuser. | - -### POST /whitelabel/domains/{domain_id}/subuser - - -```php -$request_body = json_decode('{ - "username": "jane@example.com" -}'); -$domain_id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($domain_id)->subuser()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Add an IP to a domain whitelabel. - -**This endpoint allows you to add an IP address to a domain whitelabel.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| id | integer | ID of the domain to which you are adding an IP | - -### POST /whitelabel/domains/{id}/ips - - -```php -$request_body = json_decode('{ - "ip": "192.168.0.1" -}'); -$id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($id)->ips()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Remove an IP from a domain whitelabel. - -**This endpoint allows you to remove a domain's IP address from that domain's whitelabel.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| id | integer | ID of the domain whitelabel to delete the IP from. | -| ip | string | IP to remove from the domain whitelabel. | - -### DELETE /whitelabel/domains/{id}/ips/{ip} - - -```php -$id = "test_url_param"; -$ip = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($id)->ips()->_($ip)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Validate a domain whitelabel. - -**This endpoint allows you to validate a domain whitelabel. If it fails, it will return an error message describing why the whitelabel could not be validated.** - -A domain whitelabel allows you to remove the via or sent on behalf of message that your recipients see when they read your emails. Whitelabeling a domain allows you to replace sendgrid.net with your personal sending domain. You will be required to create a subdomain so that SendGrid can generate the DNS records which you must give to your host provider. If you choose to use Automated Security, SendGrid will provide you with 3 CNAME records. If you turn Automated Security off, you will be given 2 TXT records and 1 MX record. - -For more information on whitelabeling, please see our [User Guide](https://sendgrid.com/docs/User_Guide/Settings/Whitelabel/index.html) - -## URI Parameters -| URI Parameter | Type | Description | -|---|---|---| -| id | integer |ID of the domain whitelabel to validate. | - -### POST /whitelabel/domains/{id}/validate - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->domains()->_($id)->validate()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create an IP whitelabel - -**This endpoint allows you to create an IP whitelabel.** - -When creating an IP whitelable, you should use the same subdomain that you used when you created a domain whitelabel. - -A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html). - -### POST /whitelabel/ips - - -```php -$request_body = json_decode('{ - "domain": "example.com", - "ip": "192.168.1.1", - "subdomain": "email" -}'); -$response = $sg->client->whitelabel()->ips()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all IP whitelabels - -**This endpoint allows you to retrieve all of the IP whitelabels that have been createdy by this account.** - -You may include a search key by using the "ip" parameter. This enables you to perform a prefix search for a given IP segment (e.g. "192."). - -A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html). - -### GET /whitelabel/ips - - -```php -$query_params = json_decode('{"ip": "test_string", "limit": 1, "offset": 1}'); -$response = $sg->client->whitelabel()->ips()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve an IP whitelabel - -**This endpoint allows you to retrieve an IP whitelabel.** - -A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html). - -### GET /whitelabel/ips/{id} - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->ips()->_($id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete an IP whitelabel - -**This endpoint allows you to delete an IP whitelabel.** - -A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html). - -### DELETE /whitelabel/ips/{id} - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->ips()->_($id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Validate an IP whitelabel - -**This endpoint allows you to validate an IP whitelabel.** - -A IP whitelabel consists of a subdomain and domain that will be used to generate a reverse DNS record for a given IP. Once SendGrid has verified that the appropriate A record for the IP has been created, the appropriate reverse DNS record for the IP is generated. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html). - -### POST /whitelabel/ips/{id}/validate - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->ips()->_($id)->validate()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Create a Link Whitelabel - -**This endpoint allows you to create a new link whitelabel.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### POST /whitelabel/links - - -```php -$request_body = json_decode('{ - "default": true, - "domain": "example.com", - "subdomain": "mail" -}'); -$query_params = json_decode('{"limit": 1, "offset": 1}'); -$response = $sg->client->whitelabel()->links()->post($request_body, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve all link whitelabels - -**This endpoint allows you to retrieve all link whitelabels.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### GET /whitelabel/links - - -```php -$query_params = json_decode('{"limit": 1}'); -$response = $sg->client->whitelabel()->links()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Default Link Whitelabel - -**This endpoint allows you to retrieve the default link whitelabel.** - -Default link whitelabel is the actual link whitelabel to be used when sending messages. If there are multiple link whitelabels, the default is determined by the following order: -<ul> - <li>Validated link whitelabels marked as "default"</li> - <li>Legacy link whitelabels (migrated from the whitelabel wizard)</li> - <li>Default SendGrid link whitelabel (i.e. 100.ct.sendgrid.net)</li> -</ul> - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### GET /whitelabel/links/default - - -```php -$query_params = json_decode('{"domain": "test_string"}'); -$response = $sg->client->whitelabel()->links()->default()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve Associated Link Whitelabel - -**This endpoint allows you to retrieve the associated link whitelabel for a subuser.** - -Link whitelables can be associated with subusers from the parent account. This functionality allows -subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account -must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface. - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### GET /whitelabel/links/subuser - - -```php -$query_params = json_decode('{"username": "test_string"}'); -$response = $sg->client->whitelabel()->links()->subuser()->get(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Disassociate a Link Whitelabel - -**This endpoint allows you to disassociate a link whitelabel from a subuser.** - -Link whitelables can be associated with subusers from the parent account. This functionality allows -subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account -must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface. - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### DELETE /whitelabel/links/subuser - - -```php -$query_params = json_decode('{"username": "test_string"}'); -$response = $sg->client->whitelabel()->links()->subuser()->delete(null, $query_params); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Update a Link Whitelabel - -**This endpoint allows you to update a specific link whitelabel. You can use this endpoint to change a link whitelabel's default status.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### PATCH /whitelabel/links/{id} - - -```php -$request_body = json_decode('{ - "default": true -}'); -$id = "test_url_param"; -$response = $sg->client->whitelabel()->links()->_($id)->patch($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Retrieve a Link Whitelabel - -**This endpoint allows you to retrieve a specific link whitelabel.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### GET /whitelabel/links/{id} - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->links()->_($id)->get(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Delete a Link Whitelabel - -**This endpoint allows you to delete a link whitelabel.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### DELETE /whitelabel/links/{id} - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->links()->_($id)->delete(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Validate a Link Whitelabel - -**This endpoint allows you to validate a link whitelabel.** - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### POST /whitelabel/links/{id}/validate - - -```php -$id = "test_url_param"; -$response = $sg->client->whitelabel()->links()->_($id)->validate()->post(); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` -## Associate a Link Whitelabel - -**This endpoint allows you to associate a link whitelabel with a subuser account.** - -Link whitelables can be associated with subusers from the parent account. This functionality allows -subusers to send mail using their parent's linke whitelabels. To associate a link whitelabel, the parent account -must first create a whitelabel and validate it. The parent may then associate that whitelabel with a subuser via the API or the Subuser Management page in the user interface. - -Email link whitelabels allow all of the click-tracked links you send in your emails to include the URL of your domain instead of sendgrid.net. - -For more information, please see our [User Guide](https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html). - -### POST /whitelabel/links/{link_id}/subuser - - -```php -$request_body = json_decode('{ - "username": "jane@example.com" -}'); -$link_id = "test_url_param"; -$response = $sg->client->whitelabel()->links()->_($link_id)->subuser()->post($request_body); -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` - diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USE_CASES.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USE_CASES.md deleted file mode 100644 index c7cb0a1..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/USE_CASES.md +++ /dev/null @@ -1,168 +0,0 @@ -This documentation provides examples for specific use cases. Please [open an issue](https://github.com/sendgrid/sendgrid-php/issues) or make a pull request for any use cases you would like us to document here. Thank you! - -# Table of Contents -* [Attachments](#attachments) -* [Transactional Templates](#transactional_templates) - -<a name="attachments"></a> -# Attachments - -Here is an example of attaching a text file to your email, assuming that text file `my_file.txt` is located in the same directory. - -```php -<?php -// using SendGrid's PHP Library -// https://github.com/sendgrid/sendgrid-php - -// If you are using Composer (recommended) -require 'vendor/autoload.php'; - -// If you are not using Composer -// require("path/to/sendgrid-php/sendgrid-php.php"); - -$from = new SendGrid\Email("Example User", "test@example.com"); -$subject = "Sending with SendGrid is Fun"; -$to = new SendGrid\Email("Example User", "test@example.com"); -$content = new SendGrid\Content("text/plain", "and easy to do anywhere, even with PHP"); -$file = 'my_file.txt'; -$file_encoded = base64_encode(file_get_contents($file)); -$attachment = new SendGrid\Attachment(); -$attachment->setContent($file_encoded); -$attachment->setType("application/text"); -$attachment->setDisposition("attachment"); -$attachment->setFilename("my_file.txt"); - -$mail = new SendGrid\Mail($from, $subject, $to, $content); -$mail->addAttachment($attachment); - -$apiKey = getenv('SENDGRID_API_KEY'); -$sg = new \SendGrid($apiKey); - -$response = $sg->client->mail()->send()->post($mail); -echo $response->statusCode(); -print_r($response->headers()); -echo $response->body(); - -?> -``` - -<a name="transactional_templates"></a> -# Transactional Templates - -For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing. - -Template ID (replace with your own): - -```text -13b8f94f-bcae-4ec6-b752-70d6cb59f932 -``` - -Email Subject: - -```text -<%subject%> -``` - -Template Body: - -```html -<html> -<head> - <title></title> -</head> -<body> -Hello -name-, -<br /><br/> -I'm glad you are trying out the template feature! -<br /><br/> -<%body%> -<br /><br/> -I hope you are having a great day in -city- :) -<br /><br/> -</body> -</html> -``` - -## With Mail Helper Class - -```php -<?php -// If you are using Composer -require 'vendor/autoload.php'; - -// If you are not using Composer (recommended) -// require("path/to/sendgrid-php/sendgrid-php.php"); - -$from = new SendGrid\Email(null, "test@example.com"); -$subject = "I'm replacing the subject tag"; -$to = new SendGrid\Email(null, "test@example.com"); -$content = new SendGrid\Content("text/html", "I'm replacing the <strong>body tag</strong>"); -$mail = new SendGrid\Mail($from, $subject, $to, $content); -$mail->personalization[0]->addSubstitution("-name-", "Example User"); -$mail->personalization[0]->addSubstitution("-city-", "Denver"); -$mail->setTemplateId("13b8f94f-bcae-4ec6-b752-70d6cb59f932"); - -$apiKey = getenv('SENDGRID_API_KEY'); -$sg = new \SendGrid($apiKey); - -try { - $response = $sg->client->mail()->send()->post($mail); -} catch (Exception $e) { - echo 'Caught exception: ', $e->getMessage(), "\n"; -} - -echo $response->statusCode(); -print_r($response->headers()); -echo $response->body(); -``` - -## Without Mail Helper Class - -```php -<?php -// If you are using Composer -require 'vendor/autoload.php'; - -// If you are not using Composer (recommended) -// require("path/to/sendgrid-php/sendgrid-php.php"); - -$request_body = json_decode('{ - "personalizations": [ - { - "to": [ - { - "email": "dx@sendgrid.com" - } - ], - "substitutions": { - "-name-": "Example User", - "-city-": "Denver" - }, - "subject": "I\'m replacing the subject tag" - } - ], - "from": { - "email": "elmer@sendgrid.com" - }, - "content": [ - { - "type": "text/html", - "value": "I\'m replacing the <strong>body tag</strong>" - } - ], - "template_id": "13b8f94f-bcae-4ec6-b752-70d6cb59f932" -}'); - -$apiKey = getenv('SENDGRID_API_KEY'); -$sg = new \SendGrid($apiKey); - -try { - $response = $sg->client->mail()->send()->post($request_body); -} catch (Exception $e) { - echo 'Caught exception: ', $e->getMessage(), "\n"; -} - -echo $response->statusCode(); -echo $response->body(); -print_r($response->headers()); -``` 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/docker/README.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/docker/README.md new file mode 100644 index 0000000..7a2b4cb --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/docker/README.md @@ -0,0 +1,50 @@ +Use Docker to easily try out or contribute to the sendgrid-php library. + +This Docker image contains: + - PHP 7.1.16 + - A running instance of [Stoplight.io's Prism](https://stoplight.io/platform/prism/), which lets you try out the Twilio SendGrid API without actually sending email + - A mirrored copy of sendgrid-php so that you may develop locally and then run the tests within the Docker container. + +# Table of Contents + +* [Quick Start](#quick-start) +* [Testing](#testing) +* [Contributing](#contributing) + +<a name="quick-start"></a> +# Quick Start + +0. Install Composer: + - `php -r "readfile('https://getcomposer.org/installer');" | php` + - `mv composer.phar /usr/local/bin/composer` +1. Clone the sendgrid-php repo + - `git clone https://github.com/sendgrid/sendgrid-php.git` + - `cd sendgrid-php` + - `composer install` +2. [Install Docker](https://docs.docker.com/install/) +3. [Setup local environment variable SENDGRID_API_KEY](https://github.com/sendgrid/sendgrid-php#setup-environment-variables) +4. Build Docker image, run Docker container, login to the Docker container + - `docker image build --tag="sendgrid/php7" ./docker` + - `docker run -itd --name="sendgrid_php7" -v $(pwd):/root/sendgrid-php sendgrid/php7 /bin/bash` +5. Run the tests within the Docker container + - `docker exec -it sendgrid_php7 /bin/bash -c 'cd sendgrid-php/test; ../vendor/bin/phpunit . --filter test*; exec "${SHELL:-sh}"'` + +Now you can continue development locally, and run `../vendor/bin/phpunit . --filter test*` inside of the container to test. Replace `test*` with the name of a particular test if you do not wish to run the entire suite of tests. + +To clean up the container: `docker stop sendgrid_php7 && docker rm sendgrid_php7`. + +Happy Hacking! + +<a name="testing"></a> +# For Testing the Library (Kick the Tires) + +- After step 5 in the QuickStart, within the Docker container: + - `cd ../` + - `php sendmail.php` + +<a name="contributing"></a> +# For Contributors + +- Develop per usual locally, but before pushing up to GitHub, you can run the tests locally in the Docker container per step 5 of the quickstart. +- To run all the tests: `../vendor/bin/phpunit . --filter test*` +- To run an individual test: `../vendor/bin/phpunit . --filter [Name of Test]` diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/docker/entrypoint.sh b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/docker/entrypoint.sh new file mode 100644 index 0000000..fd2bcbd --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/docker/entrypoint.sh @@ -0,0 +1,15 @@ +#! /bin/bash +clear + +if [ "$1" != "--no-mock" ] +then + echo "Starting Prism in mock mode. Calls made to Prism will not actually send emails." + echo "Disable this by running this container with --no-mock." + prism run --mock --spec $OAI_SPEC_URL 2> /dev/null & +else + echo "Starting Prism in live (--no-mock) mode. Calls made to Prism will send emails." + prism run --spec $OAI_SPEC_URL 2> /dev/null & +fi + +cd sendgrid-php +exec $SHELL diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/README.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/README.md new file mode 100644 index 0000000..601f3b3 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/contacts/README.md @@ -0,0 +1,16 @@ +# Recipients Helper + +**This helper allows you to quickly and easily build a subscription form to add contacts to your contactdb in Sendgrid.** + +## Quick Start + +Run the [example](https://github.com/sendgrid/sendgrid-php/blob/master/examples/helpers/contacts/recipients.php) (make sure you have set your environment variable to include your SENDGRID_API_KEY). + +```bash +php examples/helpers/contacts/recipients.php +``` + +## Usage + +- See this complete working [example](https://github.com/sendgrid/sendgrid-php/blob/master/examples/helpers/contacts/recipients.php). +- [Documentation](https://sendgrid.com/docs/API_Reference/api_v3.html#contacts-api-recipients) 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 @@ +<?php +/** + * This helper builds a recipient for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Contacts + * @author Kraig Hufstedler <kraigory@gmail.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds a html form and provides a submission endpoint + * for the form that makes a /contactdb/recipients API call. + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Contacts + * @author Kraig Hufstedler <kraigory@gmail.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 = '<form action="' . $url . '" method="post"> + First Name: <input type="text" name="first-name"><br> + Last Name: <input type="text" name="last-name"><br> + E-mail: <input type="text" name="email"><br> + <input type="submit"> +</form>'; + $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/helpers/mail/Mail.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/helpers/mail/Mail.php deleted file mode 100644 index ef4d8db..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/helpers/mail/Mail.php +++ /dev/null @@ -1,1172 +0,0 @@ -<?php -/** - * This helper builds the request body for a /mail/send API call. - * - * PHP version 5.6, 7 - * - * @author Elmer Thomas <dx@sendgrid.com> - * @copyright 2017 SendGrid - * @license https://opensource.org/licenses/MIT The MIT License - * @version GIT: <git_id> - * @link http://packagist.org/packages/sendgrid/sendgrid - */ -namespace SendGrid; - -class ReplyTo implements \JsonSerializable -{ - private $email; - private $name; - - public function __construct($email, $name = null) - { - $this->email = $email; - - if (!is_null($name)) { - $this->name = $name; - } - } - - public function setEmail($email) - { - $this->email = $email; - } - - public function getEmail() - { - return $this->email; - } - - public function setName($name) - { - $this->name = $name; - } - - public function getName() - { - return $this->name; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'email' => $this->getEmail(), - 'name' => $this->getName(), - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class ClickTracking implements \JsonSerializable -{ - private $enable; - private $enable_text; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setEnableText($enable_text) - { - $this->enable_text = $enable_text; - } - - public function getEnableText() - { - return $this->enable_text; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'enable_text' => $this->getEnableText() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class OpenTracking implements \JsonSerializable -{ - private $enable; - private $substitution_tag; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setSubstitutionTag($substitution_tag) - { - $this->substitution_tag = $substitution_tag; - } - - public function getSubstitutionTag() - { - return $this->substitution_tag; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'substitution_tag' => $this->getSubstitutionTag() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class SubscriptionTracking implements \JsonSerializable -{ - private $enable; - private $text; - private $html; - private $substitution_tag; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setText($text) - { - $this->text = $text; - } - - public function getText() - { - return $this->text; - } - - public function setHtml($html) - { - $this->html = $html; - } - - public function getHtml() - { - return $this->html; - } - - public function setSubstitutionTag($substitution_tag) - { - $this->substitution_tag = $substitution_tag; - } - - public function getSubstitutionTag() - { - return $this->substitution_tag; - } - - 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; - } -} - -class Ganalytics implements \JsonSerializable -{ - private $enable; - private $utm_source; - private $utm_medium; - private $utm_term; - private $utm_content; - private $utm_campaign; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setCampaignSource($utm_source) - { - $this->utm_source = $utm_source; - } - - public function getCampaignSource() - { - return $this->utm_source; - } - - public function setCampaignMedium($utm_medium) - { - $this->utm_medium = $utm_medium; - } - - public function getCampaignMedium() - { - return $this->utm_medium; - } - - public function setCampaignTerm($utm_term) - { - $this->utm_term = $utm_term; - } - - public function getCampaignTerm() - { - return $this->utm_term; - } - - public function setCampaignContent($utm_content) - { - $this->utm_content = $utm_content; - } - - public function getCampaignContent() - { - return $this->utm_content; - } - - public function setCampaignName($utm_campaign) - { - $this->utm_campaign = $utm_campaign; - } - - public function getCampaignName() - { - return $this->utm_campaign; - } - - 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; - } -} - -class TrackingSettings implements \JsonSerializable -{ - private $click_tracking; - private $open_tracking; - private $subscription_tracking; - private $ganalytics; - - public function setClickTracking($click_tracking) - { - $this->click_tracking = $click_tracking; - } - - public function getClickTracking() - { - return $this->click_tracking; - } - - public function setOpenTracking($open_tracking) - { - $this->open_tracking = $open_tracking; - } - - public function getOpenTracking() - { - return $this->open_tracking; - } - - public function setSubscriptionTracking($subscription_tracking) - { - $this->subscription_tracking = $subscription_tracking; - } - - public function getSubscriptionTracking() - { - return $this->subscription_tracking; - } - - public function setGanalytics($ganalytics) - { - $this->ganalytics = $ganalytics; - } - - public function getGanalytics() - { - return $this->ganalytics; - } - - 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; - } -} - -class BccSettings implements \JsonSerializable -{ - private $enable; - private $email; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setEmail($email) - { - $this->email = $email; - } - - public function getEmail() - { - return $this->email; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'email' => $this->getEmail() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class BypassListManagement implements \JsonSerializable -{ - private $enable; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class Footer implements \JsonSerializable -{ - private $enable; - private $text; - private $html; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setText($text) - { - $this->text = $text; - } - - public function getText() - { - return $this->text; - } - - public function setHtml($html) - { - $this->html = $html; - } - - public function getHtml() - { - return $this->html; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'text' => $this->getText(), - 'html' => $this->getHtml() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class SandBoxMode implements \JsonSerializable -{ - private $enable; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class SpamCheck implements \JsonSerializable -{ - private $enable; - private $threshold; - private $post_to_url; - - public function setEnable($enable) - { - $this->enable = $enable; - } - - public function getEnable() - { - return $this->enable; - } - - public function setThreshold($threshold) - { - $this->threshold = $threshold; - } - - public function getThreshold() - { - return $this->threshold; - } - - public function setPostToUrl($post_to_url) - { - $this->post_to_url = $post_to_url; - } - - public function getPostToUrl() - { - return $this->post_to_url; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'enable' => $this->getEnable(), - 'threshold' => $this->getThreshold(), - 'post_to_url' => $this->getPostToUrl() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class MailSettings implements \JsonSerializable -{ - private $bcc; - private $bypass_list_management; - private $footer; - private $sandbox_mode; - private $spam_check; - - public function setBccSettings($bcc) - { - $this->bcc = $bcc; - } - - public function getBccSettings() - { - return $this->bcc; - } - - public function setBypassListManagement($bypass_list_management) - { - $this->bypass_list_management = $bypass_list_management; - } - - public function getBypassListManagement() - { - return $this->bypass_list_management; - } - - public function setFooter($footer) - { - $this->footer = $footer; - } - - public function getFooter() - { - return $this->footer; - } - - public function setSandboxMode($sandbox_mode) - { - $this->sandbox_mode = $sandbox_mode; - } - - public function getSandboxMode() - { - return $this->sandbox_mode; - } - - public function setSpamCheck($spam_check) - { - $this->spam_check = $spam_check; - } - - public function getSpamCheck() - { - return $this->spam_check; - } - - 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; - } -} - -class ASM implements \JsonSerializable -{ - private $group_id; - private $groups_to_display; - - public function setGroupId($group_id) - { - $this->group_id = $group_id; - } - - public function getGroupId() - { - return $this->group_id; - } - - public function setGroupsToDisplay($group_ids) - { - $this->groups_to_display = $group_ids; - } - - public function getGroupsToDisplay() - { - return $this->groups_to_display; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'group_id' => $this->getGroupId(), - 'groups_to_display' => $this->getGroupsToDisplay() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class Attachment implements \JsonSerializable -{ - private $content; - private $type; - private $filename; - private $disposition; - private $content_id; - - public function setContent($content) - { - $this->content = $content; - } - - public function getContent() - { - return $this->content; - } - - public function setType($type) - { - $this->type = $type; - } - - public function getType() - { - return $this->type; - } - - public function setFilename($filename) - { - $this->filename = $filename; - } - - public function getFilename() - { - return $this->filename; - } - - public function setDisposition($disposition) - { - $this->disposition = $disposition; - } - - public function getDisposition() - { - return $this->disposition; - } - - public function setContentID($content_id) - { - $this->content_id = $content_id; - } - - public function getContentID() - { - return $this->content_id; - } - - 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; - } -} - -class Content implements \JsonSerializable -{ - private $type; - private $value; - - public function __construct($type, $value) - { - $this->type = $type; - $this->value = mb_convert_encoding($value, 'UTF-8', 'UTF-8'); - } - - public function setType($type) - { - $this->type = $type; - } - - public function getType() - { - return $this->type; - } - - public function setValue($value) - { - $this->value = mb_convert_encoding($value, 'UTF-8', 'UTF-8'); - } - - public function getValue() - { - return $this->value; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'type' => $this->getType(), - 'value' => $this->getValue() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class Personalization implements \JsonSerializable -{ - private $tos; - private $ccs; - private $bccs; - private $subject; - private $headers; - private $substitutions; - private $custom_args; - private $send_at; - - public function addTo($email) - { - $this->tos[] = $email; - } - - public function getTos() - { - return $this->tos; - } - - public function addCc($email) - { - $this->ccs[] = $email; - } - - public function getCcs() - { - return $this->ccs; - } - - public function addBcc($email) - { - $this->bccs[] = $email; - } - - public function getBccs() - { - return $this->bccs; - } - - public function setSubject($subject) - { - $this->subject = mb_convert_encoding($subject, 'UTF-8', 'UTF-8'); - } - - public function getSubject() - { - return $this->subject; - } - - public function addHeader($key, $value) - { - $this->headers[$key] = $value; - } - - public function getHeaders() - { - return $this->headers; - } - - public function addSubstitution($key, $value) - { - $this->substitutions[$key] = $value; - } - - public function getSubstitutions() - { - return $this->substitutions; - } - - public function addCustomArg($key, $value) - { - $this->custom_args[$key] = (string)$value; - } - - public function getCustomArgs() - { - return $this->custom_args; - } - - public function setSendAt($send_at) - { - $this->send_at = $send_at; - } - - public function getSendAt() - { - return $this->send_at; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'to' => $this->getTos(), - 'cc' => $this->getCcs(), - 'bcc' => $this->getBccs(), - 'subject' => $this->subject, - 'headers' => $this->getHeaders(), - 'substitutions' => $this->getSubstitutions(), - 'custom_args' => $this->getCustomArgs(), - 'send_at' => $this->getSendAt() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -class Email implements \JsonSerializable -{ - private $name; - private $email; - - public function __construct($name, $email) - { - $this->name = $name; - $this->email = $email; - } - - public function setName($name) - { - $this->name = $name; - } - - public function getName() - { - return $this->name; - } - - public function setEmail($email) - { - $this->email = $email; - } - - public function getEmail() - { - return $this->email; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'name' => $this->getName(), - 'email' => $this->getEmail() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} - -/** - * The final request body object - */ -class Mail implements \JsonSerializable -{ - const VERSION = '1.0.0'; - - protected $namespace = 'SendGrid'; - - public $from; - public $personalization; - public $subject; - public $contents; - public $attachments; - public $template_id; - public $sections; - public $headers; - public $categories; - public $custom_args; - public $send_at; - public $batch_id; - public $asm; - public $ip_pool_name; - public $mail_settings; - public $tracking_settings; - public $reply_to; - - public function __construct($from, $subject, $to, $content) - { - $this->setFrom($from); - $this->setSubject($subject); - $personalization = new Personalization(); - $personalization->addTo($to); - $this->addPersonalization($personalization); - $this->addContent($content); - } - - public function setFrom($email) - { - $this->from = $email; - } - - public function getFrom() - { - return $this->from; - } - - public function addPersonalization($personalization) - { - $this->personalization[] = $personalization; - } - - public function getPersonalizations() - { - return $this->personalization; - } - - public function setSubject($subject) - { - $this->subject = $subject; - } - - public function getSubject() - { - return $this->subject; - } - - public function addContent($content) - { - $this->contents[] = $content; - } - - public function getContents() - { - return $this->contents; - } - - public function addAttachment($attachment) - { - $this->attachments[] = $attachment; - } - - public function getAttachments() - { - return $this->attachments; - } - - public function setTemplateId($template_id) - { - $this->template_id = $template_id; - } - - public function getTemplateId() - { - return $this->template_id; - } - - public function addSection($key, $value) - { - $this->sections[$key] = $value; - } - - public function getSections() - { - return $this->sections; - } - - public function addHeader($key, $value) - { - $this->headers[$key] = $value; - } - - public function getHeaders() - { - return $this->headers; - } - - public function addCategory($category) - { - $this->categories[] = $category; - } - - public function getCategories() - { - return $this->categories; - } - - public function addCustomArg($key, $value) - { - $this->custom_args[$key] = (string)$value; - } - - public function getCustomArgs() - { - return $this->custom_args; - } - - public function setSendAt($send_at) - { - $this->send_at = $send_at; - } - - public function getSendAt() - { - return $this->send_at; - } - - public function setBatchId($batch_id) - { - $this->batch_id = $batch_id; - } - - public function getBatchId() - { - return $this->batch_id; - } - - public function setASM($asm) - { - $this->asm = $asm; - } - - public function getASM() - { - return $this->asm; - } - - public function setIpPoolName($ip_pool_name) - { - $this->ip_pool_name = $ip_pool_name; - } - - public function getIpPoolName() - { - return $this->ip_pool_name; - } - - public function setMailSettings($mail_settings) - { - $this->mail_settings = $mail_settings; - } - - public function getMailSettings() - { - return $this->mail_settings; - } - - public function setTrackingSettings($tracking_settings) - { - $this->tracking_settings = $tracking_settings; - } - - public function getTrackingSettings() - { - return $this->tracking_settings; - } - - public function setReplyTo($reply_to) - { - $this->reply_to = $reply_to; - } - - public function getReplyTo() - { - return $this->reply_to; - } - - public function jsonSerialize() - { - return array_filter( - [ - 'from' => $this->getFrom(), - 'personalizations' => $this->getPersonalizations(), - 'subject' => $this->getSubject(), - 'content' => $this->getContents(), - 'attachments' => $this->getAttachments(), - 'template_id' => $this->getTemplateId(), - 'sections' => $this->getSections(), - 'headers' => $this->getHeaders(), - 'categories' => $this->getCategories(), - 'custom_args' => $this->getCustomArgs(), - 'send_at' => $this->getSendAt(), - 'batch_id' => $this->getBatchId(), - 'asm' => $this->getASM(), - 'ip_pool_name' => $this->getIpPoolName(), - 'mail_settings' => $this->getMailSettings(), - 'tracking_settings' => $this->getTrackingSettings(), - 'reply_to' => $this->getReplyTo() - ], - function ($value) { - return $value !== null; - } - ) ?: null; - } -} 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 @@ +<?php +/** + * This helper builds the Asm object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Attachment object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the BatchId object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Bcc object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the BccSettings object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the BypassListManagement object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Category object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Cc object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the ClickTracking object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Content object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the CustomArg object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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..88299f5 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/EmailAddress.php @@ -0,0 +1,222 @@ +<?php +/** + * This helper builds the EmailAddress object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Footer object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the From object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Ganalytics object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the GroupId object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the GroupsToDisplay object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Header object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Content object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the IpPoolName object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the request body for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the MailSettings object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper defines the content mime types for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the OpenTracking object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Personalization object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds theContent object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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/helpers/mail/README.md b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/README.md index fec01c6..87a0997 100644 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/helpers/mail/README.md +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/mail/README.md @@ -1,4 +1,4 @@ -**This helper allows you to quickly and easily build a Mail object for sending email through SendGrid.** +**This helper allows you to quickly and easily build a Mail object for sending email through Twilio SendGrid.** # Quick Start 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 @@ +<?php +/** + * This helper builds the ReplyTo object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the SandBoxMode object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Section object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the SendAt object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the SpamCheck object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Subject object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the SubscriptionTracking object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the Substitution object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the TemplateId object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the To object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +/** + * This helper builds the TrackingSettings object for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?php +namespace SendGrid\Mail; + +class TypeException extends \Exception +{ + +}
\ No newline at end of file diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/stats/Stats.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/stats/Stats.php new file mode 100644 index 0000000..39ae0ad --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/lib/stats/Stats.php @@ -0,0 +1,269 @@ +<?php +/** + * This helper retrieves stats from a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Mail + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @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 @@ +<?xml version="1.0"?> +<ruleset name="PSR2"> + <description>The PSR-2 coding standard.</description> + <arg name="tab-width" value="4"/> + + <!-- 2. General --> + + <!-- 2.1 Basic Coding Standard --> + + <!-- Include the whole PSR-1 standard --> + <rule ref="PSR1"/> + + <!-- 2.2 Files --> + + <!-- All PHP files MUST use the Unix LF (linefeed) line ending. --> + <rule ref="Generic.Files.LineEndings"> + <properties> + <property name="eolChar" value="\n"/> + </properties> + </rule> + + <!-- All PHP files MUST end with a single blank line. --> + <!-- checked in Files/EndFileNewlineSniff --> + + <!-- The closing ?> tag MUST be omitted from files containing only PHP. --> + <!-- checked in Files/ClosingTagSniff --> + + <!-- 2.3 Lines --> + + <!-- The soft limit on line length MUST be 120 characters; automated style checkers MUST warn but MUST NOT error at the soft limit. --> + <rule ref="Generic.Files.LineLength"> + <properties> + <property name="lineLimit" value="120"/> + <property name="absoluteLineLimit" value="0"/> + </properties> + </rule> + + <!-- There MUST NOT be trailing whitespace at the end of non-blank lines. --> + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile"> + <severity>0</severity> + </rule> + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile"> + <severity>0</severity> + </rule> + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines"> + <severity>0</severity> + </rule> + + <!-- There MUST NOT be more than one statement per line. --> + <rule ref="Generic.Formatting.DisallowMultipleStatements"/> + + <!-- 2.4 Indenting --> + + <!-- Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting. --> + <rule ref="Generic.WhiteSpace.ScopeIndent"> + <properties> + <property name="ignoreIndentationTokens" type="array"> + <element value="T_COMMENT"/> + <element value="T_DOC_COMMENT_OPEN_TAG"/> + </property> + </properties> + </rule> + <rule ref="Generic.WhiteSpace.DisallowTabIndent"/> + + <!-- 2.5 Keywords and True/False/Null --> + + <!-- PHP keywords MUST be in lower case. --> + <rule ref="Generic.PHP.LowerCaseKeyword"/> + + <!-- The PHP constants true, false, and null MUST be in lower case. --> + <rule ref="Generic.PHP.LowerCaseConstant"/> + + <!-- 3. Namespace and Use Declarations --> + + <!-- When present, there MUST be one blank line after the namespace declaration. --> + <!-- checked in Namespaces/NamespaceDeclarationSniff --> + + <!-- When present, all use declarations MUST go after the namespace declaration. + There MUST be one use keyword per declaration. + There MUST be one blank line after the use block. --> + <!-- checked in Namespaces/UseDeclarationSniff --> + + <!-- 4. Classes, Properties, and Methods --> + + <!-- 4.1. Extends and Implements --> + + <!-- The extends and implements keywords MUST be declared on the same line as the class name. + The opening brace for the class go MUST go on its own line; the closing brace for the class MUST go on the next line after the body. + Lists of implements MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one interface per line. --> + <!-- checked in Classes/ClassDeclarationSniff --> + + <!-- 4.2. Properties --> + + <!-- Visibility MUST be declared on all properties. + The var keyword MUST NOT be used to declare a property. + There MUST NOT be more than one property declared per statement. + Property names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility. --> + <!-- checked in Classes/PropertyDeclarationSniff --> + + <!-- 4.3 Methods --> + + <!-- Visibility MUST be declared on all methods. --> + <rule ref="Squiz.Scope.MethodScope"/> + <rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/> + + <!-- Method names SHOULD NOT be prefixed with a single underscore to indicate protected or private visibility. --> + <!-- checked in Methods/MethodDeclarationSniff --> + + <!-- Method names MUST NOT be declared with a space after the method name. The opening brace MUST go on its own line, and the closing brace MUST go on the next line following the body. There MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. --> + <!-- checked in Methods/FunctionClosingBraceSniff --> + <rule ref="Squiz.Functions.FunctionDeclaration"/> + <rule ref="Squiz.Functions.LowercaseFunctionKeywords"/> + + <!-- 4.4 Method Arguments --> + + <!-- In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma. --> + <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing"> + <properties> + <property name="equalsSpacing" value="1"/> + </properties> + </rule> + <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint"> + <severity>0</severity> + </rule> + + <!-- Method arguments with default values MUST go at the end of the argument list. --> + <rule ref="PEAR.Functions.ValidDefaultValue"/> + + <!-- Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line. When the argument list is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them. --> + <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/> + + <!-- 4.5 abstract, final, and static --> + + <!-- When present, the abstract and final declarations MUST precede the visibility declaration. + When present, the static declaration MUST come after the visibility declaration. --> + <!-- checked in Methods/MethodDeclarationSniff --> + + <!-- 4.6 Method and Function Calls --> + + <!-- When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis, there MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma. + Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line. --> + <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/> + <rule ref="PSR2.Methods.FunctionCallSignature.SpaceAfterCloseBracket"> + <severity>0</severity> + </rule> + <rule ref="PSR2.Methods.FunctionCallSignature.OpeningIndent"> + <severity>0</severity> + </rule> + + <!-- 5. Control Structures --> + + <!-- The general style rules for control structures are as follows: + There MUST be one space after the control structure keyword + There MUST NOT be a space after the opening parenthesis + There MUST NOT be a space before the closing parenthesis + There MUST be one space between the closing parenthesis and the opening brace + The structure body MUST be indented once + The closing brace MUST be on the next line after the body --> + <rule ref="Squiz.ControlStructures.ControlSignature"/> + <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" /> + <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" /> + <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/> + <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/> + <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/> + <rule ref="Squiz.ControlStructures.LowercaseDeclaration"/> + <!-- checked in ControlStructures/ControlStructureSpacingSniff --> + + <!-- exclude this message as it is already checked Generic.PHP.LowerCaseKeyword --> + <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower"> + <severity>0</severity> + </rule> + + <!-- The body of each structure MUST be enclosed by braces. This standardizes how the structures look, and reduces the likelihood of introducing errors as new lines get added to the body. --> + <rule ref="Generic.ControlStructures.InlineControlStructure"/> + + <!-- 5.1. if, elseif, else --> + + <!-- The keyword elseif SHOULD be used instead of else if so that all control keywords look like single words. --> + <!-- checked in ControlStructures/ElseIfDeclarationSniff --> + + <!-- 5.2. switch, case --> + + <!-- The case statement MUST be indented once from switch, and the break keyword (or other terminating keyword) MUST be indented at the same level as the case body. There MUST be a comment such as // no break when fall-through is intentional in a non-empty case body. --> + <!-- checked in ControlStructures/SwitchDeclarationSniff --> + + <!-- 6. Closures --> + + <!-- Closures MUST be declared with a space after the function keyword, and a space before and after the use keyword. + The opening brace MUST go on the same line, and the closing brace MUST go on the next line following the body. + There MUST NOT be a space after the opening parenthesis of the argument list or variable list, and there MUST NOT be a space before the closing parenthesis of the argument list or variable list. + In the argument list and variable list, there MUST NOT be a space before each comma, and there MUST be one space after each comma. + Closure arguments with default values MUST go at the end of the argument list. + Argument lists and variable lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument or variable per line. + When the ending list (whether or arguments or variables) is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them. --> + <!-- checked in Squiz.Functions.MultiLineFunctionDeclaration --> +</ruleset>
\ No newline at end of file diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/generate_upload_policy.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/generate_upload_policy.php deleted file mode 100755 index 94ede40..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/generate_upload_policy.php +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env php -<?php - -/* - * From: http://raamdev.com/2008/amazon-s3-hmac-signatures-without-pear-or-php5/ - */ - -/* - * Calculate HMAC-SHA1 according to RFC2104 - * See http://www.faqs.org/rfcs/rfc2104.html - */ -function hmacsha1($key, $data) -{ - $blocksize = 64; - $hashfunc = 'sha1'; - if (strlen($key) > $blocksize) { - $key = pack('H*', $hashfunc($key)); - } - $key = str_pad($key, $blocksize, chr(0x00)); - $ipad = str_repeat(chr(0x36), $blocksize); - $opad = str_repeat(chr(0x5c), $blocksize); - $hmac = pack( - 'H*', $hashfunc( - ($key ^ $opad).pack( - 'H*', $hashfunc( - ($key ^ $ipad).$data - ) - ) - ) - ); - return bin2hex($hmac); -} - -/* - * Used to encode a field for Amazon Auth - * (taken from the Amazon S3 PHP example library) - */ -function hex2b64($str) -{ - $raw = ''; - for ($i = 0; $i < strlen($str); $i += 2) { - $raw .= chr(hexdec(substr($str, $i, 2))); - } - return base64_encode($raw); -} - -if (count($argv) != 3) { - echo "Usage: " . $argv[0] . " <S3 Policy File> <S3 secret key>\n"; - exit(1); -} - -$policy = file_get_contents($argv[1]); -$secret = $argv[2]; - -/* - * Base64 encode the Policy Document and then - * create HMAC SHA-1 signature of the base64 encoded policy - * using the secret key. Finally, encode it for Amazon Authentication. - */ -$base64_policy = base64_encode($policy); -$signature = hex2b64(hmacsha1($secret, $base64_policy)); -echo "S3_POLICY=\"" . $base64_policy . "\"\nS3_SIGNATURE=\"" . $signature . "\"\n" -?> diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/package.sh b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/package.sh new file mode 100755 index 0000000..6d23743 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/package.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +rm -rf vendor composer.lock +composer install --no-dev +printf "<?php\nrequire __DIR__ . '/vendor/autoload.php';\n?>" > sendgrid-php.php +cd .. +zip -r sendgrid-php.zip sendgrid-php -x \*.git\* \*composer.json\* \*scripts\* \*test\* \*.travis.yml\* \*prism\* + +exit 0 diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3policy.json b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3policy.json deleted file mode 100755 index 735e0b1..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3policy.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "expiration": "2100-01-01T12:00:00.000Z", - "conditions": [ - {"acl": "public-read" }, - {"bucket": "sendgrid-open-source" }, - ["starts-with", "$key", "sendgrid-php/"], - ["content-length-range", 2048, 268435456], - ["eq", "$Content-Type", "application/zip"] - ] -} - diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3upload.sh b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3upload.sh deleted file mode 100755 index 5d4a605..0000000 --- a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/scripts/s3upload.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -# From: -# http://raamdev.com/2008/using-curl-to-upload-files-via-post-to-amazon-s3/ - -GIT_VERSION=`git rev-parse --short HEAD` - -rm -rf vendor composer.lock -composer install --no-dev -printf "<?php\nrequire __DIR__ . '/vendor/autoload.php';\n?>" > sendgrid-php.php -cd .. -zip -r sendgrid-php.zip sendgrid-php -x \*.git\* \*composer.json\* \*scripts\* \*test\* \*.travis.yml\* \*prism\* - -curl -X POST \ - -F "key=sendgrid-php/versions/sendgrid-php-$GIT_VERSION.zip" \ - -F "acl=public-read" \ - -F "AWSAccessKeyId=$S3_ACCESS_KEY" \ - -F "Policy=$S3_POLICY" \ - -F "Signature=$S3_SIGNATURE" \ - -F "Content-Type=application/zip" \ - -F "file=@./sendgrid-php.zip" \ - https://s3.amazonaws.com/$S3_BUCKET - -if [ "$TRAVIS_BRANCH" = "master" ] -then - curl -X POST \ - -F "key=sendgrid-php/sendgrid-php.zip" \ - -F "acl=public-read" \ - -F "AWSAccessKeyId=$S3_ACCESS_KEY" \ - -F "Policy=$S3_POLICY" \ - -F "Signature=$S3_SIGNATURE" \ - -F "Content-Type=application/zip" \ - -F "file=@./sendgrid-php.zip" \ - https://s3.amazonaws.com/$S3_BUCKET -fi - -exit 0 diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/BaseTestClass.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/BaseTestClass.php new file mode 100644 index 0000000..a3fe54e --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/BaseTestClass.php @@ -0,0 +1,70 @@ +<?php +/** + * This file contains the base class for testing the request object + * generation for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ +namespace SendGrid\Tests; + +use PHPUnit\Framework\TestCase; +use Swaggest\JsonDiff\JsonDiff; +use Swaggest\JsonDiff\JsonPatch; + +/** + * This class facilitates testing the request object + * generation for a /mail/send API call + * + * @package SendGrid\Mail + */ +class BaseTestClass extends TestCase +{ + // @var string Twilio SendGrid API Key + protected static $apiKey; + // @var SendGrid Twilio SendGrid client + protected static $sg; + + /** + * This method is run before the classes are initialised + * + * @return null + */ + public static function setUpBeforeClass() + { + self::$apiKey = "SENDGRID_API_KEY"; + $host = ['host' => 'http://localhost:4010']; + self::$sg = new \SendGrid(self::$apiKey, $host); + } + + /** + * Compares to JSON objects and returns True if equal, + * else return array of differences + * + * @param string $json1 A string representation of a JSON object + * @param string $json2 A string representation of a JSON object + * + * @return bool|array + */ + public static function compareJSONObjects($json1, $json2) + { + $diff = new JsonDiff( + json_decode($json1), + json_decode($json2), + JsonDiff::REARRANGE_ARRAYS + ); + $patch = $diff->getPatch(); + $patch_array = JsonPatch::export($patch); + if (empty($patch_array)) { + return true; + } else { + return $patch_array; + } + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/data/test.txt b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/data/test.txt new file mode 100644 index 0000000..ce01362 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/data/test.txt @@ -0,0 +1 @@ +hello diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Alerts/AlertsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Alerts/AlertsTest.php new file mode 100644 index 0000000..b330ee7 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Alerts/AlertsTest.php @@ -0,0 +1,52 @@ +<?php + +namespace SendGrid\Tests; + +class AlertsTest extends BaseTestClass +{ + public function testAlertsPostMethod() + { + $request_body = json_decode('{ + "email_to": "example@example.com", + "frequency": "daily", + "type": "stats_notification" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->alerts()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testAlertsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->alerts()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAlertsIdPatchMethod() + { + $request_body = json_decode('{ + "email_to": "example@example.com" +}'); + $alert_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->alerts()->_($alert_id)->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAlertsIdGetMethod() + { + $alert_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->alerts()->_($alert_id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAlertsIdDeleteMethod() + { + $alert_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->alerts()->_($alert_id)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/ApiKeys/ApiKeysTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/ApiKeys/ApiKeysTest.php new file mode 100644 index 0000000..0602185 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/ApiKeys/ApiKeysTest.php @@ -0,0 +1,74 @@ +<?php + +namespace SendGrid\Tests\ApiKeys; + +use SendGrid\Tests\BaseTestClass; + +class ApiKeysTest extends BaseTestClass +{ + public function testApiKeysPostMethod() + { + $request_body = json_decode('{ + "name": "My API Key", + "sample": "data", + "scopes": [ + "mail.send", + "alerts.create", + "alerts.read" + ] +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->api_keys()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testApiKeysGetMethod() + { + $query_params = json_decode('{"limit": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->api_keys()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testApiKeysIdPutMethod() + { + $request_body = json_decode('{ + "name": "A New Hope", + "scopes": [ + "user.profile.read", + "user.profile.update" + ] +}'); + $api_key_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->api_keys()->_($api_key_id)->put($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testApiKeysIdPatchMethod() + { + $request_body = json_decode('{ + "name": "A New Hope" +}'); + $api_key_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->api_keys()->_($api_key_id)->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testApiKeysIdGetMethod() + { + $api_key_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->api_keys()->_($api_key_id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testApiKeysIdDeleteMethod() + { + $api_key_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->api_keys()->_($api_key_id)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Asm/AsmGroupsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Asm/AsmGroupsTest.php new file mode 100644 index 0000000..b2887dc --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Asm/AsmGroupsTest.php @@ -0,0 +1,105 @@ +<?php + +namespace SendGrid\Tests\Asm; + +use SendGrid\Tests\BaseTestClass; + +class AsmGroupsTest extends BaseTestClass +{ + public function testAsmGroupsPostMethod() + { + $request_body = json_decode('{ + "description": "Suggestions for products our users might like.", + "is_default": true, + "name": "Product Suggestions" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->asm()->groups()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testAsmGroupsGetMethod() + { + $query_params = json_decode('{"id": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->asm()->groups()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAsmGroupsIdPatchMethod() + { + $request_body = json_decode('{ + "description": "Suggestions for items our users might like.", + "id": 103, + "name": "Item Suggestions" +}'); + $group_id = "test_url_param"; + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->asm()->groups()->_($group_id)->patch($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testAsmGroupsIdGetMethod() + { + $group_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->asm()->groups()->_($group_id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAsmGroupsIdDeleteMethod() + { + $group_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->asm()->groups()->_($group_id)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testAsmGroupsIdSuppressionPostMethod() + { + $request_body = json_decode('{ + "recipient_emails": [ + "test1@example.com", + "test2@example.com" + ] +}'); + $group_id = "test_url_param"; + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->asm()->groups()->_($group_id)->suppressions()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testAsmGroupsIdSuppressionGetMethod() + { + $group_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->asm()->groups()->_($group_id)->suppressions()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAsmGroupsIdSuppressionSearchPostMethod() + { + $request_body = json_decode('{ + "recipient_emails": [ + "exists1@example.com", + "exists2@example.com", + "doesnotexists@example.com" + ] +}'); + $group_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->asm()->groups()->_($group_id)->suppressions()->search() + ->post($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAsmGroupsIdSuppressionEmailDeleteMethod() + { + $group_id = "test_url_param"; + $email = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->asm()->groups()->_($group_id)->suppressions()->_($email) + ->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Asm/AsmSuppressionTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Asm/AsmSuppressionTest.php new file mode 100644 index 0000000..af96cc8 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Asm/AsmSuppressionTest.php @@ -0,0 +1,52 @@ +<?php + +namespace SendGrid\Tests\Asm; + +use SendGrid\Tests\BaseTestClass; + +class AsmSuppressionTest extends BaseTestClass +{ + public function testAsmSuppressionGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->asm()->suppressions()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAsmSuppressionGlobalPostMethod() + { + $request_body = json_decode('{ + "recipient_emails": [ + "test1@example.com", + "test2@example.com" + ] +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->asm()->suppressions()->global()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testAsmSuppressionGlobalEmailGetMethod() + { + $email = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->asm()->suppressions()->global()->_($email)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAsmSuppressionGlobalEmailDeleteMethod() + { + $email = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->asm()->suppressions()->global()->_($email)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testAsmSuppressionEmailGetMethod() + { + $email = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->asm()->suppressions()->_($email)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Campaigns/CampaignsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Campaigns/CampaignsTest.php new file mode 100644 index 0000000..56df198 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Campaigns/CampaignsTest.php @@ -0,0 +1,134 @@ +<?php + +namespace SendGrid\Tests\Campaigns; + +use SendGrid\Tests\BaseTestClass; + +class CampaignsTest extends BaseTestClass +{ + public function testCampaignsPostMethod() + { + $request_body = json_decode('{ + "categories": [ + "spring line" + ], + "custom_unsubscribe_url": "", + "html_content": "<html><head><title></title></head><body><p>Check out our spring line!</p></body></html>", + "ip_pool": "marketing", + "list_ids": [ + 110, + 124 + ], + "plain_content": "Check out our spring line!", + "segment_ids": [ + 110 + ], + "sender_id": 124451, + "subject": "New Products for Spring!", + "suppression_group_id": 42, + "title": "March Newsletter" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->campaigns()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testCampaignsGetMethod() + { + $query_params = json_decode('{"limit": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->campaigns()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testCampaignsIdPatchMethod() + { + $request_body = json_decode('{ + "categories": [ + "summer line" + ], + "html_content": "<html><head><title></title></head><body><p>Check out our summer line!</p></body></html>", + "plain_content": "Check out our summer line!", + "subject": "New Products for Summer!", + "title": "May Newsletter" +}'); + $campaign_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->campaigns()->_($campaign_id)->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testCampaignsIdGetMethod() + { + $campaign_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->campaigns()->_($campaign_id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testCampaignsIdDeleteMethod() + { + $campaign_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->campaigns()->_($campaign_id)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testCampaignsIdSchedulesPatchMethod() + { + $request_body = json_decode('{ + "send_at": 1489451436 +}'); + $campaign_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->campaigns()->_($campaign_id)->schedules()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testCampaignsIdSchedulesPostMethod() + { + $request_body = json_decode('{ + "send_at": 1489771528 +}'); + $campaign_id = "test_url_param"; + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->campaigns()->_($campaign_id)->schedules()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testCampaignsIdSchedulesGetMethod() + { + $campaign_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->campaigns()->_($campaign_id)->schedules()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testCampaignsIdSchedulesDeleteMethod() + { + $campaign_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->campaigns()->_($campaign_id)->schedules()->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testCampaignsIdSchedulesNowPostMethod() + { + $campaign_id = "test_url_param"; + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->campaigns()->_($campaign_id)->schedules()->now()->post(null, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testCampaignsIdSchedulesTestPostMethod() + { + $request_body = json_decode('{ + "to": "your.email@example.com" +}'); + $campaign_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->campaigns()->_($campaign_id)->schedules()->test() + ->post($request_body, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Categories/CategoriesTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Categories/CategoriesTest.php new file mode 100644 index 0000000..33442f4 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Categories/CategoriesTest.php @@ -0,0 +1,32 @@ +<?php + +namespace SendGrid\Tests\Categories; + +use SendGrid\Tests\BaseTestClass; + +class CategoriesTest extends BaseTestClass +{ + public function testCategoriesGetMethod() + { + $query_params = json_decode('{"category": "test_string", "limit": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->categories()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testCategoriesStatsGetMethod() + { + $query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "categories": "test_string"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->categories()->stats()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testCategoriesStatsSumsGetMethod() + { + $query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->categories()->stats()->sums()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Contacts/ContactDbTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Contacts/ContactDbTest.php new file mode 100644 index 0000000..c412950 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Contacts/ContactDbTest.php @@ -0,0 +1,424 @@ +<?php + +namespace SendGrid\Tests\Contacts; + +use SendGrid\Tests\BaseTestClass; + +class ContactDbTest extends BaseTestClass +{ + public function testContactDbCustomFieldsPostMethod() + { + $request_body = json_decode('{ + "name": "pet", + "type": "text" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->contactdb() + ->custom_fields() + ->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testContactDbCustomFieldsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->custom_fields() + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbCustomFieldsIdGetMethod() + { + $custom_field_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->custom_fields() + ->_($custom_field_id) + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbCustomFieldsIdDeleteMethod() + { + $custom_field_id = "test_url_param"; + $request_headers = ["X-Mock: 202"]; + $response = self::$sg->client->contactdb() + ->custom_fields() + ->_($custom_field_id) + ->delete(null, null, $request_headers); + $this->assertEquals(202, $response->statusCode()); + } + + public function testContactDbListsPostMethod() + { + $request_body = json_decode('{ + "name": "your list name" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->contactdb() + ->lists() + ->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testContactDbListsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->lists() + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbListsDeleteMethod() + { + $request_body = json_decode('[ + 1, + 2, + 3, + 4 +]'); + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->contactdb() + ->lists() + ->delete($request_body, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testContactDbListsIdPatchMethod() + { + $request_body = json_decode('{ + "name": "newlistname" +}'); + $query_params = json_decode('{"list_id": 1}'); + $list_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->lists() + ->_($list_id) + ->patch($request_body, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbListsIdGetMethod() + { + $query_params = json_decode('{"list_id": 1}'); + $list_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->lists() + ->_($list_id) + ->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbListsIdDeleteMethod() + { + $query_params = json_decode('{"delete_contacts": "true"}'); + $list_id = "test_url_param"; + $request_headers = ["X-Mock: 202"]; + $response = self::$sg->client->contactdb() + ->lists() + ->_($list_id) + ->delete(null, $query_params, $request_headers); + $this->assertEquals(202, $response->statusCode()); + } + + public function testContactDbListsIdRecipientsPostMethod() + { + $request_body = json_decode('[ + "recipient_id1", + "recipient_id2" +]'); + $list_id = "test_url_param"; + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->contactdb() + ->lists() + ->_($list_id) + ->recipients() + ->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testContactDbListsIdRecipientsGetMethod() + { + $query_params = json_decode('{"page": 1, "page_size": 1, "list_id": 1}'); + $list_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->lists() + ->_($list_id) + ->recipients() + ->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbListsIdRecipientsIdPostMethod() + { + $list_id = "test_url_param"; + $recipient_id = "test_url_param"; + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->contactdb() + ->lists() + ->_($list_id) + ->recipients() + ->_($recipient_id) + ->post(null, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testContactDbListsIdRecipientsIdDeleteMethod() + { + $query_params = json_decode('{"recipient_id": 1, "list_id": 1}'); + $list_id = "test_url_param"; + $recipient_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->contactdb() + ->lists() + ->_($list_id) + ->recipients() + ->_($recipient_id) + ->delete(null, $query_params, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testContactDbRecipientsPatchMethod() + { + $request_body = json_decode('[ + { + "email": "jones@example.com", + "first_name": "Guy", + "last_name": "Jones" + } +]'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->contactdb() + ->recipients() + ->patch($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testContactDbRecipientsPostMethod() + { + $request_body = json_decode('[ + { + "age": 25, + "email": "example@example.com", + "first_name": "", + "last_name": "User" + }, + { + "age": 25, + "email": "example2@example.com", + "first_name": "Example", + "last_name": "User" + } +]'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->contactdb() + ->recipients() + ->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testContactDbRecipientsGetMethod() + { + $query_params = json_decode('{"page": 1, "page_size": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->recipients() + ->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbRecipientsDeleteMethod() + { + $request_body = json_decode('[ + "recipient_id1", + "recipient_id2" +]'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->recipients() + ->delete($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbRecipientsBillableCountGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->recipients() + ->billable_count() + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbRecipientsCountMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->recipients() + ->count() + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbRecipientsSearchGetMethod() + { + $query_params = json_decode('{"{field_name}": "test_string"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->recipients() + ->search() + ->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbRecipientsIdGetMethod() + { + $recipient_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->recipients() + ->_($recipient_id) + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbRecipientsIdDeleteMethod() + { + $recipient_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->contactdb() + ->recipients() + ->_($recipient_id) + ->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testContactDbRecipientsIdListsGetMethod() + { + $recipient_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->recipients() + ->_($recipient_id) + ->lists() + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbReservedFieldsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->reserved_fields() + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbSegmentsPostMethod() + { + $request_body = json_decode('{ + "conditions": [ + { + "and_or": "", + "field": "last_name", + "operator": "eq", + "value": "Miller" + }, + { + "and_or": "and", + "field": "last_clicked", + "operator": "gt", + "value": "01/02/2015" + }, + { + "and_or": "or", + "field": "clicks.campaign_identifier", + "operator": "eq", + "value": "513" + } + ], + "list_id": 4, + "name": "Last Name Miller" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->segments() + ->post($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbSegmentsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->segments() + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbSegmentsIdPatchMethod() + { + $request_body = json_decode('{ + "conditions": [ + { + "and_or": "", + "field": "last_name", + "operator": "eq", + "value": "Miller" + } + ], + "list_id": 5, + "name": "The Millers" +}'); + $query_params = json_decode('{"segment_id": "test_string"}'); + $segment_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->segments() + ->_($segment_id) + ->patch($request_body, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbSegmentsIdGetMethod() + { + $query_params = json_decode('{"segment_id": 1}'); + $segment_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->segments() + ->_($segment_id) + ->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testContactDbSegmentsIdDeleteMethod() + { + $query_params = json_decode('{"delete_contacts": "true"}'); + $segment_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->contactdb() + ->segments() + ->_($segment_id) + ->delete(null, $query_params, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testContactDbSegmentsIdRecipientsGetMethod() + { + $query_params = json_decode('{"page": 1, "page_size": 1}'); + $segment_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->contactdb() + ->segments() + ->_($segment_id) + ->recipients() + ->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Ip/IpPoolsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Ip/IpPoolsTest.php new file mode 100644 index 0000000..17bb8e9 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Ip/IpPoolsTest.php @@ -0,0 +1,72 @@ +<?php + +namespace SendGrid\Tests\Ip; + +use SendGrid\Tests\BaseTestClass; + +class IpPoolsTest extends BaseTestClass +{ + public function testIpPoolsPostMethod() + { + $request_body = json_decode('{ + "name": "marketing" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->ips()->pools()->post($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testIpPoolsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->ips()->pools()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testIpPoolsPoolNamePutMethod() + { + $request_body = json_decode('{ + "name": "new_pool_name" +}'); + $pool_name = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->ips()->pools()->_($pool_name)->put($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testIpPoolsPoolNameGetMethod() + { + $pool_name = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->ips()->pools()->_($pool_name)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testIpPoolsPoolNameDeleteMethod() + { + $pool_name = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->ips()->pools()->_($pool_name)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testIpPoolsPoolNameIpsPostMethod() + { + $request_body = json_decode('{ + "ip": "0.0.0.0" +}'); + $pool_name = "test_url_param"; + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->ips()->pools()->_($pool_name)->ips()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testIpPoolsPoolNameIpsIdDeleteMethod() + { + $pool_name = "test_url_param"; + $ip = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->ips()->pools()->_($pool_name)->ips()->_($ip)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Ip/IpsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Ip/IpsTest.php new file mode 100644 index 0000000..345daeb --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Ip/IpsTest.php @@ -0,0 +1,31 @@ +<?php + +namespace SendGrid\Tests\Ip; + +use SendGrid\Tests\BaseTestClass; + +class IpsTest extends BaseTestClass +{ + public function testIpsGetMethod() + { + $query_params = json_decode('{"subuser": "test_string", "ip": "test_string", "limit": 1, "exclude_whitelabels": "true", "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->ips()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testIpsAssignedGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->ips()->assigned()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testIpsIpAddressGetMethod() + { + $ip_address = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->ips()->_($ip_address)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Ip/IpsWarmupTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Ip/IpsWarmupTest.php new file mode 100644 index 0000000..9e4945f --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Ip/IpsWarmupTest.php @@ -0,0 +1,41 @@ +<?php + +namespace SendGrid\Tests\Ip; + +use SendGrid\Tests\BaseTestClass; + +class IpsWarmupTest extends BaseTestClass +{ + public function testIpsWarmupGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->ips()->warmup()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testIpsWarmupPostMethod() + { + $request_body = json_decode('{ + "ip": "0.0.0.0" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->ips()->warmup()->post($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testIpsWarmupIpAddressGetMethod() + { + $ip_address = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->ips()->warmup()->_($ip_address)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testIpsWarmupIpAddressDeleteMethod() + { + $ip_address = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->ips()->warmup()->_($ip_address)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailBatchTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailBatchTest.php new file mode 100644 index 0000000..506ced5 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailBatchTest.php @@ -0,0 +1,23 @@ +<?php + +namespace SendGrid\Tests\Mail; + +use SendGrid\Tests\BaseTestClass; + +class MailBatchTest extends BaseTestClass +{ + public function testMailBatchPostMethod() + { + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->mail()->batch()->post(null, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testMailBatchIdGetMethod() + { + $batch_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail()->batch()->_($batch_id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailSendTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailSendTest.php new file mode 100644 index 0000000..30e299a --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailSendTest.php @@ -0,0 +1,153 @@ +<?php + +namespace SendGrid\Tests\Mail; + +use SendGrid\Tests\BaseTestClass; + +class MailSendTest extends BaseTestClass +{ + public function testMailSendPostMethod() + { + $request_body = json_decode('{ + "asm": { + "group_id": 1, + "groups_to_display": [ + 1, + 2, + 3 + ] + }, + "attachments": [ + { + "content": "[BASE64 encoded content block here]", + "content_id": "ii_139db99fdb5c3704", + "disposition": "inline", + "filename": "file1.jpg", + "name": "file1", + "type": "jpg" + } + ], + "batch_id": "[YOUR BATCH ID GOES HERE]", + "categories": [ + "category1", + "category2" + ], + "content": [ + { + "type": "text/html", + "value": "<html><p>Hello, world!</p><img src=[CID GOES HERE] /></html>" + } + ], + "custom_args": { + "New Argument 1": "New Value 1", + "activationAttempt": "1", + "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]" + }, + "from": { + "email": "sam.smith@example.com", + "name": "Sam Smith" + }, + "headers": {}, + "ip_pool_name": "[YOUR POOL NAME GOES HERE]", + "mail_settings": { + "bcc": { + "email": "ben.doe@example.com", + "enable": true + }, + "bypass_list_management": { + "enable": true + }, + "footer": { + "enable": true, + "html": "<p>Thanks</br>The Twilio SendGrid Team</p>", + "text": "Thanks,/n The Twilio SendGrid Team" + }, + "sandbox_mode": { + "enable": false + }, + "spam_check": { + "enable": true, + "post_to_url": "http://example.com/compliance", + "threshold": 3 + } + }, + "personalizations": [ + { + "bcc": [ + { + "email": "sam.doe@example.com", + "name": "Sam Doe" + } + ], + "cc": [ + { + "email": "jane.doe@example.com", + "name": "Jane Doe" + } + ], + "custom_args": { + "New Argument 1": "New Value 1", + "activationAttempt": "1", + "customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]" + }, + "headers": { + "X-Accept-Language": "en", + "X-Mailer": "MyApp" + }, + "send_at": 1409348513, + "subject": "Hello, World!", + "substitutions": { + "id": "substitutions", + "type": "object" + }, + "to": [ + { + "email": "john.doe@example.com", + "name": "John Doe" + } + ] + } + ], + "reply_to": { + "email": "sam.smith@example.com", + "name": "Sam Smith" + }, + "sections": { + "section": { + ":sectionName1": "section 1 text", + ":sectionName2": "section 2 text" + } + }, + "send_at": 1409348513, + "subject": "Hello, World!", + "template_id": "[YOUR TEMPLATE ID GOES HERE]", + "tracking_settings": { + "click_tracking": { + "enable": true, + "enable_text": true + }, + "ganalytics": { + "enable": true, + "utm_campaign": "[NAME OF YOUR REFERRER SOURCE]", + "utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]", + "utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]", + "utm_name": "[NAME OF YOUR CAMPAIGN]", + "utm_term": "[IDENTIFY PAID KEYWORDS HERE]" + }, + "open_tracking": { + "enable": true, + "substitution_tag": "%opentrack" + }, + "subscription_tracking": { + "enable": true, + "html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.", + "substitution_tag": "<%click here%>", + "text": "If you would like to unsubscribe and stop receiving these emails <% click here %>." + } + } +}'); + $request_headers = ["X-Mock: 202"]; + $response = self::$sg->client->mail()->send()->post($request_body, null, $request_headers); + $this->assertEquals(202, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailSettingsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailSettingsTest.php new file mode 100644 index 0000000..aa4065a --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailSettingsTest.php @@ -0,0 +1,183 @@ +<?php + +namespace SendGrid\Tests\Mail; + +use SendGrid\Tests\BaseTestClass; + +class MailSettingsTest extends BaseTestClass +{ + public function testMailSettingsGetMethod() + { + $query_params = json_decode('{"limit": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsAddressWhitelistPatchMethod() + { + $request_body = json_decode('{ + "enabled": true, + "list": [ + "email1@example.com", + "example.com" + ] +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->address_whitelist()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsAddressWhitelistGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->address_whitelist()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsBccPatchMethod() + { + $request_body = json_decode('{ + "email": "email@example.com", + "enabled": false +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->bcc()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsBccGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->bcc()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsBouncePurgePatchMethod() + { + $request_body = json_decode('{ + "enabled": true, + "hard_bounces": 5, + "soft_bounces": 5 +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->bounce_purge()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsBouncePurgeGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->bounce_purge()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsFooterPatchMethod() + { + $request_body = json_decode('{ + "enabled": true, + "html_content": "...", + "plain_content": "..." +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->footer()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsFooterGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->footer()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsForwardBouncePatchMethod() + { + $request_body = json_decode('{ + "email": "example@example.com", + "enabled": true +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->forward_bounce()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsForwardBounceGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->forward_bounce()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsForwardSpamPatchMethod() + { + $request_body = json_decode('{ + "email": "", + "enabled": false +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->forward_spam()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsForwardSpamGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->forward_spam()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsPlainContentPatchMethod() + { + $request_body = json_decode('{ + "enabled": false +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->plain_content()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsPlainContentGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->plain_content()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsSpamCheckPatchMethod() + { + $request_body = json_decode('{ + "enabled": true, + "max_score": 5, + "url": "url" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->spam_check()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsSpamCheckGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->spam_check()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsTemplatePatchMethod() + { + $request_body = json_decode('{ + "enabled": true, + "html_content": "<% body %>" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->template()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testMailSettingsTemplateGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mail_settings()->template()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailboxProvidersTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailboxProvidersTest.php new file mode 100644 index 0000000..8fba4d0 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Mail/MailboxProvidersTest.php @@ -0,0 +1,18 @@ +<?php + +namespace SendGrid\Tests\Mail; + +use SendGrid\Tests\BaseTestClass; + +class MailboxProvidersTest extends BaseTestClass +{ + public function testMailboxProvidersStatsGetMethod() + { + $query_params = json_decode('{"end_date": "2016-04-01", "mailbox_providers": "test_string", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->mailbox_providers() + ->stats() + ->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Scopes/ScopesTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Scopes/ScopesTest.php new file mode 100644 index 0000000..edeb675 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Scopes/ScopesTest.php @@ -0,0 +1,15 @@ +<?php + +namespace SendGrid\Tests\Scopes; + +use SendGrid\Tests\BaseTestClass; + +class ScopesTest extends BaseTestClass +{ + public function testScopesGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->scopes()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/SenderAuthentication/DomainAuthenticationTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/SenderAuthentication/DomainAuthenticationTest.php new file mode 100644 index 0000000..8cd7437 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/SenderAuthentication/DomainAuthenticationTest.php @@ -0,0 +1,124 @@ +<?php + +namespace SendGrid\Tests\Whitelabel; + +use SendGrid\Tests\BaseTestClass; + +class WhitelabelDomainsTest extends BaseTestClass +{ + public function testWhitelabelDomainsPostMethod() + { + $request_body = json_decode('{ + "automatic_security": false, + "custom_spf": true, + "default": true, + "domain": "example.com", + "ips": [ + "192.168.1.1", + "192.168.1.2" + ], + "subdomain": "news", + "username": "john@example.com" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->whitelabel()->domains()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testWhitelabelDomainsGetMethod() + { + $query_params = json_decode('{"username": "test_string", "domain": "test_string", "exclude_subusers": "true", "limit": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->domains()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelDomainsDefaultGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->domains()->default()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelDomainsSubUserGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->domains()->subuser()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelDomainsSubUserDeleteMethod() + { + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->whitelabel()->domains()->subuser()->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testWhitelabelDomainsIdPatchMethod() + { + $request_body = json_decode('{ + "custom_spf": true, + "default": false +}'); + $domain_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->domains()->_($domain_id)->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelDomainsIdGetMethod() + { + $domain_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->domains()->_($domain_id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelDomainsIdDeleteMethod() + { + $domain_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->whitelabel()->domains()->_($domain_id)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testWhitelabelDomainsIdSubUserPostMethod() + { + $request_body = json_decode('{ + "username": "jane@example.com" +}'); + $domain_id = "test_url_param"; + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->whitelabel()->domains()->_($domain_id)->subuser() + ->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testWhitelabelDomainsIdIpsPostMethod() + { + $request_body = json_decode('{ + "ip": "192.168.0.1" +}'); + $id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->domains()->_($id)->ips()->post($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelDomainsIdIpsDeleteMethod() + { + $id = "test_url_param"; + $ip = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->domains()->_($id)->ips()->_($ip)->delete(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelDomainsIdValidatePostMethod() + { + $id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->domains()->_($id)->validate()->post(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/SenderAuthentication/LinkBrandingTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/SenderAuthentication/LinkBrandingTest.php new file mode 100644 index 0000000..9493c8f --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/SenderAuthentication/LinkBrandingTest.php @@ -0,0 +1,99 @@ +<?php + +namespace SendGrid\Tests\Whitelabel; + +use SendGrid\Tests\BaseTestClass; + +class WhitelabelLinksTest extends BaseTestClass +{ + public function testWhitelabelLinksPostMethod() + { + $request_body = json_decode('{ + "default": true, + "domain": "example.com", + "subdomain": "mail" +}'); + $query_params = json_decode('{"limit": 1, "offset": 1}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->whitelabel()->links()->post($request_body, $query_params, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testWhitelabelLinksGetMethod() + { + $query_params = json_decode('{"limit": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->links()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelLinksDefaultGetMethod() + { + $query_params = json_decode('{"domain": "test_string"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->links()->default()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelLinksSubUserGetMethod() + { + $query_params = json_decode('{"username": "test_string"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->links()->subuser()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelLinksSubUserDeleteMethod() + { + $query_params = json_decode('{"username": "test_string"}'); + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->whitelabel()->links()->subuser()->delete(null, $query_params, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testWhitelabelLinksIdPatchMethod() + { + $request_body = json_decode('{ + "default": true +}'); + $id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->links()->_($id)->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelLinksIdGetMethod() + { + $id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->links()->_($id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelLinksIdDeleteMethod() + { + $id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->whitelabel()->links()->_($id)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testWhitelabelLinksIdValidatePostMethod() + { + $id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->links()->_($id)->validate()->post(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelLinksIdSubUserPostMethod() + { + $request_body = json_decode('{ + "username": "jane@example.com" +}'); + $link_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->links()->_($link_id)->subuser()->post($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/SenderAuthentication/ReverseDNSTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/SenderAuthentication/ReverseDNSTest.php new file mode 100644 index 0000000..96b2bd7 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/SenderAuthentication/ReverseDNSTest.php @@ -0,0 +1,52 @@ +<?php + +namespace SendGrid\Tests\Whitelabel; + +use SendGrid\Tests\BaseTestClass; + +class WhitelabelIpsTest extends BaseTestClass +{ + public function testWhitelabelIpsPostMethod() + { + $request_body = json_decode('{ + "domain": "example.com", + "ip": "192.168.1.1", + "subdomain": "email" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->whitelabel()->ips()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testWhitelabelIpsGetMethod() + { + $query_params = json_decode('{"ip": "test_string", "limit": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->ips()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelIpsIdGetMethod() + { + $id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->ips()->_($id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testWhitelabelIpsIdDeleteMethod() + { + $id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->whitelabel()->ips()->_($id)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testWhitelabelIpsIdValidatePostMethod() + { + $id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->whitelabel()->ips()->_($id)->validate()->post(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Senders/SendersTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Senders/SendersTest.php new file mode 100644 index 0000000..82471bd --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Senders/SendersTest.php @@ -0,0 +1,99 @@ +<?php + +namespace SendGrid\Tests\Senders; + +use SendGrid\Tests\BaseTestClass; + +class SendersTest extends BaseTestClass +{ + public function testSendersPostMethod() + { + $request_body = json_decode('{ + "address": "123 Elm St.", + "address_2": "Apt. 456", + "city": "Denver", + "country": "United States", + "from": { + "email": "from@example.com", + "name": "Example INC" + }, + "nickname": "My Sender ID", + "reply_to": { + "email": "replyto@example.com", + "name": "Example INC" + }, + "state": "Colorado", + "zip": "80202" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->senders() + ->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testSendersGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->senders() + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSendersIdPatchMethod() + { + $request_body = json_decode('{ + "address": "123 Elm St.", + "address_2": "Apt. 456", + "city": "Denver", + "country": "United States", + "from": { + "email": "from@example.com", + "name": "Example INC" + }, + "nickname": "My Sender ID", + "reply_to": { + "email": "replyto@example.com", + "name": "Example INC" + }, + "state": "Colorado", + "zip": "80202" +}'); + $sender_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->senders() + ->_($sender_id) + ->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSendersIdGetMethod() + { + $sender_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->senders() + ->_($sender_id) + ->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSendersIdDeleteMethod() + { + $sender_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->senders() + ->_($sender_id) + ->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testSendersIdResendVerificationPostMethod() + { + $sender_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->senders() + ->_($sender_id) + ->resend_verification() + ->post(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Settings/AccessSettingsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Settings/AccessSettingsTest.php new file mode 100644 index 0000000..576766a --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Settings/AccessSettingsTest.php @@ -0,0 +1,76 @@ +<?php + +namespace SendGrid\Tests\Settings; + +use SendGrid\Tests\BaseTestClass; + +class AccessSettingsTest extends BaseTestClass +{ + public function testAccessSettingsActivityGetMethod() + { + $query_params = [ + 'limit' => 1 + ]; + $request_headers = ['X-Mock: 200']; + $response = self::$sg->client->access_settings()->activity()->get(null, $query_params, $request_headers); + + $this->assertEquals(200, $response->statusCode()); + } + + public function testAccessSettingsWhitelistPostMethod() + { + $request_body = json_decode('{ + "ips": [ + { + "ip": "192.168.1.1" + }, + { + "ip": "192.*.*.*" + }, + { + "ip": "192.168.1.3/32" + } + ] +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->access_settings()->whitelist()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testAccessSettingsWhitelistGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->access_settings()->whitelist()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAccessSettingsWhitelistDeleteMethod() + { + $request_body = json_decode('{ + "ids": [ + 1, + 2, + 3 + ] +}'); + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->access_settings()->whitelist()->delete($request_body, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testAccessSettingsWhitelistRuleIdGetMethod() + { + $rule_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->access_settings()->whitelist()->_($rule_id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testAccessSettingsWhitelistRuleIdDeleteMethod() + { + $rule_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->access_settings()->whitelist()->_($rule_id)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Settings/PartnerSettingsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Settings/PartnerSettingsTest.php new file mode 100644 index 0000000..d4c525f --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Settings/PartnerSettingsTest.php @@ -0,0 +1,35 @@ +<?php + +namespace SendGrid\Tests\Settings; + +use SendGrid\Tests\BaseTestClass; + +class PartnerSettingsTest extends BaseTestClass +{ + public function testPartnerSettingsGetMethod() + { + $query_params = json_decode('{"limit": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->partner_settings()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testPartnerSettingsNewRelicPatchMethod() + { + $request_body = json_decode('{ + "enable_subuser_statistics": true, + "enabled": true, + "license_key": "" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->partner_settings()->new_relic()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testPartnerSettingsNewRelicGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->partner_settings()->new_relic()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Settings/TrackingSettingsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Settings/TrackingSettingsTest.php new file mode 100644 index 0000000..07c41f0 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Settings/TrackingSettingsTest.php @@ -0,0 +1,94 @@ +<?php + +namespace SendGrid\Tests\Settings; + +use SendGrid\Tests\BaseTestClass; + +class TrackingSettingsTest extends BaseTestClass +{ + public function testTrackingSettingsGetMethod() + { + $query_params = json_decode('{"limit": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->tracking_settings()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTrackingSettingsClickPatchMethod() + { + $request_body = json_decode('{ + "enabled": true +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->tracking_settings()->click()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTrackingSettingsClickGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->tracking_settings()->click()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTrackingSettingsGoogleAnalyticsPatchMethod() + { + $request_body = json_decode('{ + "enabled": true, + "utm_campaign": "website", + "utm_content": "", + "utm_medium": "email", + "utm_source": "sendgrid.com", + "utm_term": "" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->tracking_settings()->google_analytics()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTrackingSettingsGoogleAnalyticsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->tracking_settings()->google_analytics()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTrackingSettingsOpenPatchMethod() + { + $request_body = json_decode('{ + "enabled": true +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->tracking_settings()->open()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTrackingSettingsOpenGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->tracking_settings()->open()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTrackingSettingsSubscriptionPatchMethod() + { + $request_body = json_decode('{ + "enabled": true, + "html_content": "html content", + "landing": "landing page html", + "plain_content": "text content", + "replace": "replacement tag", + "url": "url" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->tracking_settings()->subscription()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTrackingSettingsSubscriptionGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->tracking_settings()->subscription()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/BrowserStatsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/BrowserStatsTest.php new file mode 100644 index 0000000..685cfe0 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/BrowserStatsTest.php @@ -0,0 +1,16 @@ +<?php + +namespace SendGrid\Tests\Stats; + +use SendGrid\Tests\BaseTestClass; + +class BrowserStatsTest extends BaseTestClass +{ + public function testBrowserStatsGetMethod() + { + $query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "browsers": "test_string", "limit": "test_string", "offset": "test_string", "start_date": "2016-01-01"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->browsers()->stats()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/ClientsStatsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/ClientsStatsTest.php new file mode 100644 index 0000000..633fd62 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/ClientsStatsTest.php @@ -0,0 +1,25 @@ +<?php + +namespace SendGrid\Tests\Stats; + +use SendGrid\Tests\BaseTestClass; + +class ClientsStatsTest extends BaseTestClass +{ + public function testClientsStatsGetMethod() + { + $query_params = json_decode('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->clients()->stats()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testClientsClientTypeStatsGetMethod() + { + $query_params = json_decode('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}'); + $client_type = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->clients()->_($client_type)->stats()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/DevicesStatsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/DevicesStatsTest.php new file mode 100644 index 0000000..08b6131 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/DevicesStatsTest.php @@ -0,0 +1,16 @@ +<?php + +namespace SendGrid\Tests\Stats; + +use SendGrid\Tests\BaseTestClass; + +class DevicesStatsTest extends BaseTestClass +{ + public function testDevicesStatsGetMethod() + { + $query_params = json_decode('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->devices()->stats()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/GeoStatsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/GeoStatsTest.php new file mode 100644 index 0000000..b006f93 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/GeoStatsTest.php @@ -0,0 +1,16 @@ +<?php + +namespace SendGrid\Tests\Stats; + +use SendGrid\Tests\BaseTestClass; + +class GeoStatsTest extends BaseTestClass +{ + public function testGeoStatsGetMethod() + { + $query_params = json_decode('{"end_date": "2016-04-01", "country": "US", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->geo()->stats()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/StatsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/StatsTest.php new file mode 100644 index 0000000..3646122 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Stats/StatsTest.php @@ -0,0 +1,16 @@ +<?php + +namespace SendGrid\Tests\Stats; + +use SendGrid\Tests\BaseTestClass; + +class StatsTest extends BaseTestClass +{ + public function testStatsGetMethod() + { + $query_params = json_decode('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->stats()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Subusers/SubUsersTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Subusers/SubUsersTest.php new file mode 100644 index 0000000..1774f90 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Subusers/SubUsersTest.php @@ -0,0 +1,155 @@ +<?php + +namespace SendGrid\Tests\Subusers; + +use SendGrid\Tests\BaseTestClass; + +class SubUsersTest extends BaseTestClass +{ + public function testSubUsersGetMethod() + { + $query_params = json_decode('{"username": "test_string", "limit": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSubUsersPostMethod() + { + $request_body = json_decode('{ + "email": "John@example.com", + "ips": [ + "1.1.1.1", + "2.2.2.2" + ], + "password": "johns_password", + "username": "John@example.com" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->post($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSubUsersReputationGetMethod() + { + $query_params = json_decode('{"usernames": "test_string"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->reputations()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSubUsersStatsGetMethod() + { + $query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "subusers": "test_string"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->stats()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSubUsersStatsMonthlyGetMethod() + { + $query_params = json_decode('{"subuser": "test_string", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "date": "test_string", "sort_by_direction": "asc"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->stats()->monthly()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSubUsersStatsSumsGetMethod() + { + $query_params = json_decode('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->stats()->sums()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSubUsersNamePatchMethod() + { + $request_body = json_decode('{ + "disabled": false +}'); + $subuser_name = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->subusers()->_($subuser_name)->patch($request_body, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testSubUsersNameDeleteMethod() + { + $subuser_name = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->subusers()->_($subuser_name)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testSubUsersNameIpsPutMethod() + { + $request_body = json_decode('[ + "127.0.0.1" +]'); + $subuser_name = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->_($subuser_name)->ips()->put($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSubUsersNameMonitorPutMethod() + { + $request_body = json_decode('{ + "email": "example@example.com", + "frequency": 500 +}'); + $subuser_name = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->_($subuser_name)->monitor()->put( + $request_body, + null, + $request_headers + ); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSubUsersNameMonitorPostMethod() + { + $request_body = json_decode('{ + "email": "example@example.com", + "frequency": 50000 +}'); + $subuser_name = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->_($subuser_name)->monitor()->post( + $request_body, + null, + $request_headers + ); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSubUsersNameMonitorGetMethod() + { + $subuser_name = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->_($subuser_name)->monitor()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSubUsersNameMonitorDeleteMethod() + { + $subuser_name = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->subusers()->_($subuser_name)->monitor()->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testSubUsersNameStatsMonthlyGetMethod() + { + $query_params = json_decode('{"date": "test_string", "sort_by_direction": "asc", "limit": 1, "sort_by_metric": "test_string", "offset": 1}'); + $subuser_name = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->subusers()->_($subuser_name)->stats()->monthly()->get( + null, + $query_params, + $request_headers + ); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionBlocksTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionBlocksTest.php new file mode 100644 index 0000000..e0c90e2 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionBlocksTest.php @@ -0,0 +1,46 @@ +<?php + +namespace SendGrid\Tests\Suppression; + +use SendGrid\Tests\BaseTestClass; + +class SuppressionBlocksTest extends BaseTestClass +{ + public function testSuppressionBlocksGetMethod() + { + $query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->suppression()->blocks()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSuppressionBlocksDeleteMethod() + { + $request_body = json_decode('{ + "delete_all": false, + "emails": [ + "example1@example.com", + "example2@example.com" + ] +}'); + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->suppression()->blocks()->delete($request_body, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testSuppressionBlocksEmailGetMethod() + { + $email = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->suppression()->blocks()->_($email)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSuppressionBlocksEmailDeleteMethod() + { + $email = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->suppression()->blocks()->_($email)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionBouncesTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionBouncesTest.php new file mode 100644 index 0000000..b440de3 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionBouncesTest.php @@ -0,0 +1,47 @@ +<?php + +namespace SendGrid\Tests\Suppression; + +use SendGrid\Tests\BaseTestClass; + +class SuppressionBouncesTest extends BaseTestClass +{ + public function testSuppressionBouncesGetMethod() + { + $query_params = json_decode('{"start_time": 1, "end_time": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->suppression()->bounces()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSuppressionBouncesDeleteMethod() + { + $request_body = json_decode('{ + "delete_all": true, + "emails": [ + "example@example.com", + "example2@example.com" + ] +}'); + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->suppression()->bounces()->delete($request_body, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testSuppressionBouncesEmailGetMethod() + { + $email = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->suppression()->bounces()->_($email)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSuppressionBouncesEmailDeleteMethod() + { + $query_params = json_decode('{"email_address": "example@example.com"}'); + $email = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->suppression()->bounces()->_($email)->delete(null, $query_params, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionInvalidEmailsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionInvalidEmailsTest.php new file mode 100644 index 0000000..040a21f --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionInvalidEmailsTest.php @@ -0,0 +1,46 @@ +<?php + +namespace SendGrid\Tests\Suppression; + +use SendGrid\Tests\BaseTestClass; + +class SuppressionInvalidEmailsTest extends BaseTestClass +{ + public function testSuppressionInvalidEmailsGetMethod() + { + $query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->suppression()->invalid_emails()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSuppressionInvalidEmailsDeleteMethod() + { + $request_body = json_decode('{ + "delete_all": false, + "emails": [ + "example1@example.com", + "example2@example.com" + ] +}'); + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->suppression()->invalid_emails()->delete($request_body, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testSuppressionInvalidEmailsEmailGetMethod() + { + $email = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->suppression()->invalid_emails()->_($email)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSuppressionBouncesEmailDeleteMethod() + { + $email = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->suppression()->invalid_emails()->_($email)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionSpamReportsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionSpamReportsTest.php new file mode 100644 index 0000000..fc640fe --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionSpamReportsTest.php @@ -0,0 +1,46 @@ +<?php + +namespace SendGrid\Tests\Suppression; + +use SendGrid\Tests\BaseTestClass; + +class SuppressionSpamReportsTest extends BaseTestClass +{ + public function testSuppressionSpamReportsGetMethod() + { + $query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->suppression()->spam_reports()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSuppressionSpamReportsDeleteMethod() + { + $request_body = json_decode('{ + "delete_all": false, + "emails": [ + "example1@example.com", + "example2@example.com" + ] +}'); + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->suppression()->spam_reports()->delete($request_body, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testSuppressionSpamReportsEmailGetMethod() + { + $email = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->suppression()->spam_reports()->_($email)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testSuppressionSpamReportsEmailDeleteMethod() + { + $email = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->suppression()->spam_reports()->_($email)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionUnsubscribesTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionUnsubscribesTest.php new file mode 100644 index 0000000..0c20423 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Suppression/SuppressionUnsubscribesTest.php @@ -0,0 +1,16 @@ +<?php + +namespace SendGrid\Tests\Suppression; + +use SendGrid\Tests\BaseTestClass; + +class SuppressionUnsubscribesTest extends BaseTestClass +{ + public function testSuppressionUnsubscribesGetMethod() + { + $query_params = json_decode('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->suppression()->unsubscribes()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Templates/TemplatesTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Templates/TemplatesTest.php new file mode 100644 index 0000000..8dc71f0 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Templates/TemplatesTest.php @@ -0,0 +1,114 @@ +<?php + +namespace SendGrid\Tests\Templates; + +use SendGrid\Tests\BaseTestClass; + +class TemplatesTest extends BaseTestClass +{ + public function testTemplatesPostMethod() + { + $request_body = json_decode('{ + "name": "example_name" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->templates()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testTemplatesGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->templates()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTemplatesIdPatchMethod() + { + $request_body = json_decode('{ + "name": "new_example_name" +}'); + $template_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->templates()->_($template_id)->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTemplatesIdGetMethod() + { + $template_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->templates()->_($template_id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTemplatesIdDeleteMethod() + { + $template_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->templates()->_($template_id)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testTemplatesIdVersionsPostMethod() + { + $request_body = json_decode('{ + "active": 1, + "html_content": "<%body%>", + "name": "example_version_name", + "plain_content": "<%body%>", + "subject": "<%subject%>", + "template_id": "ddb96bbc-9b92-425e-8979-99464621b543" +}'); + $template_id = "test_url_param"; + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->templates()->_($template_id)->versions()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testTemplatesIdVersionsIdPatchMethod() + { + $request_body = json_decode('{ + "active": 1, + "html_content": "<%body%>", + "name": "updated_example_name", + "plain_content": "<%body%>", + "subject": "<%subject%>" +}'); + $template_id = "test_url_param"; + $version_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->templates()->_($template_id)->versions()->_($version_id) + ->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTemplatesIdVersionsIdGetMethod() + { + $template_id = "test_url_param"; + $version_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->templates()->_($template_id)->versions()->_($version_id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testTemplatesIdVersionsIdDeleteMethod() + { + $template_id = "test_url_param"; + $version_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->templates()->_($template_id)->versions()->_($version_id) + ->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testTemplatesIdVersionsIdActivatePostMethod() + { + $template_id = "test_url_param"; + $version_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->templates()->_($template_id)->versions()->_($version_id)->activate() + ->post(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Users/UserTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Users/UserTest.php new file mode 100644 index 0000000..45f789e --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/Users/UserTest.php @@ -0,0 +1,274 @@ +<?php + +namespace SendGrid\Tests\Users; + +use SendGrid\Tests\BaseTestClass; + +class UserTest extends BaseTestClass +{ + public function testUserMethod() + { + $query_params = json_decode('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->stats()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserAccountGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->account()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserCreditsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->credits()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserEmailPutMethod() + { + $request_body = json_decode('{ + "email": "example@example.com" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->email()->put($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserEmailGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->email()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserPasswordPutMethod() + { + $request_body = json_decode('{ + "new_password": "new_password", + "old_password": "old_password" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->password()->put($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserProfilePatchMethod() + { + $request_body = json_decode('{ + "city": "Orange", + "first_name": "Example", + "last_name": "User" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->profile()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserProfileGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->profile()->get(null, null, $request_headers); + $this->assertEquals($response->statusCode(), 200); + } + + public function testUserScheduledSendsPostMethod() + { + $request_body = json_decode('{ + "batch_id": "YOUR_BATCH_ID", + "status": "pause" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->user()->scheduled_sends()->post($request_body, null, $request_headers); + $this->assertEquals(201, $response->statusCode()); + } + + public function testUserScheduledSendsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->scheduled_sends()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserScheduledSendsBatchIdPatchMethod() + { + $request_body = json_decode('{ + "status": "pause" +}'); + $batch_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->user()->scheduled_sends()->_($batch_id)->patch( + $request_body, + null, + $request_headers + ); + $this->assertEquals(204, $response->statusCode()); + } + + public function testUserScheduledSendsBatchIdGetMethod() + { + $batch_id = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->scheduled_sends()->_($batch_id)->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserScheduledSendsBatchIdDeleteMethod() + { + $batch_id = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->user()->scheduled_sends()->_($batch_id)->delete(null, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testUserSettingsEnforcedTlsPatchMethod() + { + $request_body = json_decode('{ + "require_tls": true, + "require_valid_cert": false +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->settings()->enforced_tls()->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserSettingsEnforcedTlsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->settings()->enforced_tls()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserUsernamePutMethod() + { + $request_body = json_decode('{ + "username": "test_username" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->username()->put($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserUsernameGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->username()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserWebhooksEventSettingsPatchMethod() + { + $request_body = json_decode('{ + "bounce": true, + "click": true, + "deferred": true, + "delivered": true, + "dropped": true, + "enabled": true, + "group_resubscribe": true, + "group_unsubscribe": true, + "open": true, + "processed": true, + "spam_report": true, + "unsubscribe": true, + "url": "url" +}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->webhooks()->event()->settings()->patch( + $request_body, + null, + $request_headers + ); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserWebhooksEventSettingsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->webhooks()->event()->settings()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserWebhooksEventTestPostMethod() + { + $request_body = json_decode('{ + "url": "url" +}'); + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->user()->webhooks()->event()->test()->post($request_body, null, $request_headers); + $this->assertEquals(204, $response->statusCode()); + } + + public function testUserWebhooksParseSettingsPostMethod() + { + $request_body = json_decode('{ + "hostname": "myhostname.com", + "send_raw": false, + "spam_check": true, + "url": "http://email.myhosthame.com" +}'); + $request_headers = ["X-Mock: 201"]; + $response = self::$sg->client->user()->webhooks()->parse()->settings()->post( + $request_body, + null, + $request_headers + ); + $this->assertEquals(201, $response->statusCode()); + } + + public function testUserWebhooksParseSettingsGetMethod() + { + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->webhooks()->parse()->settings()->get(null, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserWebhooksParseHostnamePatchMethod() + { + $request_body = json_decode('{ + "send_raw": true, + "spam_check": false, + "url": "http://newdomain.com/parse" +}'); + $hostname = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->webhooks()->parse()->settings()->_($hostname) + ->patch($request_body, null, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserWebhooksParseHostnameGetMethod() + { + $hostname = "test_url_param"; + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->webhooks()->parse()->settings()->_($hostname)->get( + null, + null, + $request_headers + ); + $this->assertEquals(200, $response->statusCode()); + } + + public function testUserWebhooksParseHostnameDeleteMethod() + { + $hostname = "test_url_param"; + $request_headers = ["X-Mock: 204"]; + $response = self::$sg->client->user()->webhooks()->parse()->settings()->_($hostname)->delete( + null, + null, + $request_headers + ); + $this->assertEquals(204, $response->statusCode()); + } + + public function testUserWebhooksParseStatsGetMethod() + { + $query_params = json_decode('{"aggregated_by": "day", "limit": "test_string", "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": "test_string"}'); + $request_headers = ["X-Mock: 200"]; + $response = self::$sg->client->user()->webhooks()->parse()->stats()->get(null, $query_params, $request_headers); + $this->assertEquals(200, $response->statusCode()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/helpers/contacts/RecipientsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/helpers/contacts/RecipientsTest.php new file mode 100644 index 0000000..b82764e --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/helpers/contacts/RecipientsTest.php @@ -0,0 +1,31 @@ +<?php +namespace SendGrid\Tests; + +use SendGrid\Tests\BaseTestClass; +use SendGrid\Contacts\RecipientForm; +use SendGrid\Contacts\Recipient; + +class RecipientsTestRecipient extends BaseTestClass +{ + public function testRecipientsForm() + { + $form = (string) new RecipientForm('http://www.example.com/recipientFormSubmit'); + $this->assertEquals( + $form, '<form action="http://www.example.com/recipientFormSubmit" method="post"> + First Name: <input type="text" name="first-name"><br> + Last Name: <input type="text" name="last-name"><br> + E-mail: <input type="text" name="email"><br> + <input type="submit"> +</form>' + ); + } + public function testRecipientsFormSubmit() + { + $firstName = 'Test'; + $lastName = 'Tester'; + $email = 'test@test.com'; + $recipient = new Recipient($firstName, $lastName, $email); + $json = json_encode($recipient); + $this->assertEquals($json, '{"email":"test@test.com","first_name":"Test","last_name":"Tester"}'); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/helpers/stats/StatsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/helpers/stats/StatsTest.php new file mode 100644 index 0000000..a30226d --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/integration/helpers/stats/StatsTest.php @@ -0,0 +1,238 @@ +<?php +namespace SendGrid\Tests; + +use SendGrid\Tests\BaseTestClass; +use SendGrid\Stats\Stats; + +class StatsTest extends BaseTestClass +{ + /** + * @param array $expectedGlobal + * @param array $expectedCategory + * @param array $expectedSubuser + * @param array $expectedSum + * @param array $expectedSubuserMonthly + * @dataProvider validValues + */ + public function testGetValues( + $expectedGlobal, + $expectedCategory, + $expectedSubuser, + $expectedSum, + $expectedSubuserMonthly + ) { + $userStats = new Stats($expectedGlobal['start_date'], $expectedGlobal['end_date'], $expectedGlobal['aggregated_by']); + $this->assertEquals($expectedGlobal, $userStats->getGlobal()); + $this->assertEquals($expectedCategory, $userStats->getCategory($expectedCategory['categories'])); + $this->assertEquals($expectedSubuser, $userStats->getSubuser($expectedSubuser['subusers'])); + $this->assertEquals($expectedSum, $userStats->getSum( + $expectedSum['sort_by_metric'], + $expectedSum['sort_by_direction'], + $expectedSum['limit'], + $expectedSum['offset'] + )); + $this->assertEquals($expectedSubuserMonthly, $userStats->getSubuserMonthly( + $expectedSubuserMonthly['subuser'], + $expectedSubuserMonthly['sort_by_metric'], + $expectedSubuserMonthly['sort_by_direction'], + $expectedSubuserMonthly['limit'], + $expectedSubuserMonthly['offset'] + )); + } + + /** + * @param array $expectedGlobal + * @param array $expectedCategory + * @param array $expectedSubuser + * @param array $expectedSum + * @param array $expectedSubuserMonthly + * @dataProvider invalidValues + * @expectedException Exception + */ + public function testGetValuesFail( + $expectedGlobal, + $expectedCategory, + $expectedSubuser, + $expectedSum, + $expectedSubuserMonthly + ) { + $this->testGetValues( + $expectedGlobal, + $expectedCategory, + $expectedSubuser, + $expectedSum, + $expectedSubuserMonthly + ); + } + + public function validValues() + { + return [ + [ + $this->getExpectedGlobal('1980-01-01', null, null), + $this->getExpectedCategory('1980-01-01', null, null, ['cat1', 'cat2']), + $this->getExpectedSubuser('1980-01-01', null, null, ['user1', 'user2']), + $this->getExpectedSum('1980-01-01', null, null, 'delivered', 'desc', 5, 0), + $this->getExpectedSubuserMonthly('1980-01-01', 'user1', 'delivered', 'desc', 5, 0), + ], + [ + $this->getExpectedGlobal('1980-01-01', '2017-01-01', null), + $this->getExpectedCategory('1980-01-01', '2017-01-01', null, ['cat1']), + $this->getExpectedSubuser('1980-01-01', '2017-01-01', null, ['user1']), + $this->getExpectedSum('1980-01-01', '2017-01-01', null, 'delivered', 'asc', 10, 2), + $this->getExpectedSubuserMonthly('1980-01-01', 'user1', 'delivered', 'asc', 10, 2), + ], + [ + $this->getExpectedGlobal('1980-01-01', '2017-01-01', 'day'), + $this->getExpectedCategory('1980-01-01', '2017-01-01', 'day', ['cat1']), + $this->getExpectedSubuser('1980-01-01', '2017-01-01', 'day', ['user1']), + $this->getExpectedSum('1980-01-01', '2017-01-01', 'day', 'delivered', 'asc', 50, 6), + $this->getExpectedSubuserMonthly('1980-01-01', 'user1', 'delivered', 'asc', 50, 6), + ], + ]; + } + + public function invalidValues() + { + return [ + [ + $this->getExpectedGlobal(null, null, null), + null, + null, + null, + null + ], + [ + $this->getExpectedGlobal('1980-01-0145', null, null), + null, + null, + null, + null + ], + [ + $this->getExpectedGlobal('1980-01-01', '1980-01-0145', null), + null, + null, + null, + null + ], + [ + $this->getExpectedGlobal('1980-01-01', '1980-01-02', 'asdf'), + null, + null, + null, + null + ], + [ + $this->getExpectedGlobal('1980-01-01', '2017-01-01', 'day'), + $this->getExpectedCategory('1980-01-01', '2017-01-01', 'day', null), + null, + null, + null + ], + [ + $this->getExpectedGlobal('1980-01-01', '2017-01-01', 'day'), + $this->getExpectedCategory('1980-01-01', '2017-01-01', 'day', null), + null, + null, + null + ], + [ + $this->getExpectedGlobal('1980-01-01', '2017-01-01', 'day'), + $this->getExpectedCategory('1980-01-01', '2017-01-01', 'day', []), + null, + null, + null + ], + [ + $this->getExpectedGlobal('1980-01-01', '2017-01-01', 'day'), + $this->getExpectedCategory('1980-01-01', '2017-01-01', 'day', ['a' => 'b']), + null, + null, + null + ], + [ + $this->getExpectedGlobal('1980-01-01', '2017-01-01', 'day'), + $this->getExpectedCategory('1980-01-01', '2017-01-01', 'day', ['cat1']), + $this->getExpectedSubuser('1980-01-01', '2017-01-01', 'day', null), + $this->getExpectedSum('1980-01-01', '2017-01-01', 'day', 'delivered', null, 50, 6), + null + ], + [ + $this->getExpectedGlobal('1980-01-01', '2017-01-01', 'day'), + $this->getExpectedCategory('1980-01-01', '2017-01-01', 'day', ['cat1']), + $this->getExpectedSubuser('1980-01-01', '2017-01-01', 'day', null), + $this->getExpectedSum('1980-01-01', '2017-01-01', 'day', 'delivered', 'asdf', 50, 6), + null + ], + [ + $this->getExpectedGlobal('1980-01-01', '2017-01-01', 'day'), + $this->getExpectedCategory('1980-01-01', '2017-01-01', 'day', ['cat1']), + $this->getExpectedSubuser('1980-01-01', '2017-01-01', 'day', null), + $this->getExpectedSum('1980-01-01', '2017-01-01', 'day', 'delivered', 'asc', null, 'asdf'), + null + ], + [ + $this->getExpectedGlobal('1980-01-01', '2017-01-01', 'day'), + $this->getExpectedCategory('1980-01-01', '2017-01-01', 'day', ['cat1']), + $this->getExpectedSubuser('1980-01-01', '2017-01-01', 'day', ['user1']), + $this->getExpectedSum('1980-01-01', '2017-01-01', 'day', 'delivered', 'asc', 50, 6), + $this->getExpectedSubuserMonthly('1980-01-01', 'user1', 'delivered', 'asc', 50, null), + ], + ]; + } + + public function getExpectedGlobal($startDate, $endDate, $aggregatedBy) + { + return [ + 'start_date' => $startDate, + 'end_date' => $endDate, + 'aggregated_by' => $aggregatedBy, + ]; + } + + public function getExpectedCategory($startDate, $endDate, $aggregatedBy, $categories) + { + return [ + 'start_date' => $startDate, + 'end_date' => $endDate, + 'aggregated_by' => $aggregatedBy, + 'categories' => $categories + ]; + } + + public function getExpectedSubuser($startDate, $endDate, $aggregatedBy, $subusers) + { + return [ + 'start_date' => $startDate, + 'end_date' => $endDate, + 'aggregated_by' => $aggregatedBy, + 'subusers' => $subusers + ]; + } + + public function getExpectedSum($startDate, $endDate, $aggregatedBy, $sortByMetric, $sortByDirection, $limit, $offset) + { + return [ + 'start_date' => $startDate, + 'end_date' => $endDate, + 'aggregated_by' => $aggregatedBy, + 'sort_by_metric' => $sortByMetric, + 'sort_by_direction' => $sortByDirection, + 'limit' => $limit, + 'offset' => $offset + ]; + } + + public function getExpectedSubuserMonthly($date, $subuser, $sortByMetric, $sortByDirection, $limit, $offset) + { + return [ + 'date' => $date, + 'subuser' => $subuser, + 'sort_by_metric' => $sortByMetric, + 'sort_by_direction' => $sortByDirection, + 'limit' => $limit, + 'offset' => $offset + ]; + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/phpunit.xml.dist b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/phpunit.xml.dist new file mode 100644 index 0000000..c80a65f --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/phpunit.xml.dist @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpunit colors="true" bootstrap="../vendor/autoload.php"> + <testsuites> + <testsuite name="All"> + <directory>.</directory> + </testsuite> + </testsuites> +</phpunit> diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/prism.sh b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/prism.sh new file mode 100755 index 0000000..4537445 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/prism.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +get_latest_release() { + curl --silent "https://api.github.com/repos/stoplightio/prism/releases/latest" | # Get latest release from GitHub api + grep '"tag_name":' | # Get tag line + sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value +} +set -eu + +install () { + +echo "Installing Prism..." + +UNAME=$(uname) +ARCH=$(uname -m) +if [ "$UNAME" != "Linux" ] && [ "$UNAME" != "Darwin" ] && [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "i686" ]; then + echo "Sorry, OS/Architecture not supported: ${UNAME}/${ARCH}. Download binary from https://github.com/stoplightio/prism/releases" + exit 1 +fi + +if [ "$UNAME" = "Darwin" ] ; then + OSX_ARCH=$(uname -m) + if [ "${OSX_ARCH}" = "x86_64" ] ; then + PLATFORM="darwin_amd64" + fi +elif [ "$UNAME" = "Linux" ] ; then + LINUX_ARCH=$(uname -m) + if [ "${LINUX_ARCH}" = "i686" ] ; then + PLATFORM="linux_386" + elif [ "${LINUX_ARCH}" = "x86_64" ] ; then + PLATFORM="linux_amd64" + fi +fi + +mkdir -p ../prism/bin +LATEST=$(get_latest_release) +# URL="https://github.com/stoplightio/prism/releases/download/$LATEST/prism_$PLATFORM" +URL="https://github.com/stoplightio/prism/releases/download/v2.0.17/prism_$PLATFORM" +DEST=../prism/bin/prism + +# if [ -z $LATEST ] ; then +# echo "Error requesting. Download binary from ${URL}" +# exit 1 +# else +curl -L $URL -o $DEST +chmod +x $DEST +# fi +} + +run () { + echo "Running prism..." + cd ../prism/bin + ./prism mock --spec https://raw.githubusercontent.com/sendgrid/sendgrid-oai/master/oai_stoplight.json +} + +if [ -f ../prism/bin/prism ]; then + echo "Prism is already installed." + run +else + echo "Prism is not installed." + install + run +fi diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/AttachmentsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/AttachmentsTest.php new file mode 100644 index 0000000..007eba8 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/AttachmentsTest.php @@ -0,0 +1,45 @@ +<?php +/** + * This file tests attachments. + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ +namespace SendGrid\Tests; + +use PHPUnit\Framework\TestCase; +use SendGrid\Mail\Attachment; + +/** + * This file tests attachments. + * + * @package SendGrid\Tests + */ +class AttachmentsTests extends TestCase +{ + public function testWillEncodeNonBase64String() { + + $attachment = new Attachment(); + $testString = 'Twilio Sendgrid is awesome!'; + + $attachment->setContent($testString); + + $this->assertEquals(base64_encode($testString), $attachment->getContent()); + } + + public function testWillNotEncodeBase64String() { + + $attachment = new Attachment(); + $testString = base64_encode('Twilio Sendgrid is awesome!'); + + $attachment->setContent($testString); + + $this->assertEquals($testString, $attachment->getContent()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/DynamicTemplateTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/DynamicTemplateTest.php new file mode 100644 index 0000000..d07d97d --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/DynamicTemplateTest.php @@ -0,0 +1,415 @@ +<?php +/** + * This file tests the dynamic/transactional template functionality for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Tests; + +// Test each use case that uses substitutions + +/** + * This class tests the dynamic/transactional template functionality for a /mail/send API call + * + * @package SendGrid\Tests + */ +class DynamicTemplateTest extends BaseTestClass +{ + + private $REQUEST_OBJECT_LEGACY = <<<'JSON' +{ + "content": [ + { + "type": "text/plain", + "value": "and easy to do anywhere, even with PHP" + }, + { + "type": "text/html", + "value": "<strong>and easy to do anywhere, even with PHP</strong>" + }, + { + "type": "text/calendar", + "value": "Party Time!!" + }, + { + "type": "text/calendar2", + "value": "Party Time 2!!" + } + ], + "from": { + "email": "test@example.com", + "name": "DX" + }, + "subject": "Sending with Twilio SendGrid is Fun and Global 2", + "personalizations": [ + { + "bcc": [ + { + "email": "test+7@example.com", + "name": "Example User7" + }, + { + "email": "test+8@example.com", + "name": "Example User8" + }, + { + "email": "test+9@example.com", + "name": "Example User9" + } + ], + "cc": [ + { + "email": "test+4@example.com", + "name": "Example User4" + }, + { + "email": "test+5@example.com", + "name": "Example User5" + }, + { + "email": "test+6@example.com", + "name": "Example User6" + } + ], + "substitutions": { + "%city1%": "Denver", + "%city2%": "Orange", + "%name1%": "Example Name 1", + "%name2%": "Example Name 2" + }, + "to": [ + { + "email": "test@example.com", + "name": "Example User" + }, + { + "email": "test+1@example.com", + "name": "Example User1" + }, + { + "email": "test+2@example.com", + "name": "Example User2" + }, + { + "email": "test+3@example.com", + "name": "Example User3" + } + ] + } + ], + "template_id": "13b8f94f-bcae-4ec6-b752-70d6cb59f932" +} +JSON; + + private $REQUEST_OBJECT = <<<'JSON' +{ + "content": [ + { + "type": "text/plain", + "value": "and easy to do anywhere, even with PHP" + }, + { + "type": "text/html", + "value": "<strong>and easy to do anywhere, even with PHP</strong>" + }, + { + "type": "text/calendar", + "value": "Party Time!!" + }, + { + "type": "text/calendar2", + "value": "Party Time 2!!" + } + ], + "from": { + "email": "test@example.com", + "name": "DX" + }, + "subject": "Sending with Twilio SendGrid is Fun and Global 2", + "personalizations": [ + { + "bcc": [ + { + "email": "test+7@example.com", + "name": "Example User7" + }, + { + "email": "test+8@example.com", + "name": "Example User8" + }, + { + "email": "test+9@example.com", + "name": "Example User9" + } + ], + "cc": [ + { + "email": "test+4@example.com", + "name": "Example User4" + }, + { + "email": "test+5@example.com", + "name": "Example User5" + }, + { + "email": "test+6@example.com", + "name": "Example User6" + } + ], + "dynamic_template_data": { + "%city1%": "Denver", + "%city2%": "Orange", + "%name1%": "Example Name 1", + "%name2%": "Example Name 2" + }, + "to": [ + { + "email": "test@example.com", + "name": "Example User" + }, + { + "email": "test+1@example.com", + "name": "Example User1" + }, + { + "email": "test+2@example.com", + "name": "Example User2" + }, + { + "email": "test+3@example.com", + "name": "Example User3" + } + ] + } + ], + "template_id": "d-13b8f94f-bcae-4ec6-b752-70d6cb59f932" +} +JSON; + + /** + * Test all parameters without using objects + */ + public function testKitchenSinkExampleWithoutObjectsAndLegacyTemplate() + { + $email = new \SendGrid\Mail\Mail(); + + // For a detailed description of each of these settings, + // please see the + // [documentation](https://sendgrid.com/docs/API_Reference/api_v3.html). + $email->setSubject("Sending with Twilio SendGrid is Fun 2"); + + $email->addTo("test@example.com", "Example User"); + $email->addTo("test+1@example.com", "Example User1"); + $toEmails = [ + "test+2@example.com" => "Example User2", + "test+3@example.com" => "Example User3" + ]; + $email->addTos($toEmails); + + $email->addCc("test+4@example.com", "Example User4"); + $ccEmails = [ + "test+5@example.com" => "Example User5", + "test+6@example.com" => "Example User6" + ]; + $email->addCcs($ccEmails); + + $email->addBcc("test+7@example.com", "Example User7"); + $bccEmails = [ + "test+8@example.com" => "Example User8", + "test+9@example.com" => "Example User9" + ]; + $email->addBccs($bccEmails); + + $email->addSubstitution("%name1%", "Example Name 1"); + $email->addSubstitution("%city1%", "Denver"); + $substitutions = [ + "%name2%" => "Example Name 2", + "%city2%" => "Orange" + ]; + $email->addSubstitutions($substitutions); + + // The values below this comment are global to entire message + + $email->setFrom("test@example.com", "DX"); + + $email->setGlobalSubject("Sending with Twilio SendGrid is Fun and Global 2"); + + $email->addContent( + "text/plain", + "and easy to do anywhere, even with PHP" + ); + $email->addContent( + "text/html", + "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $contents = [ + "text/calendar" => "Party Time!!", + "text/calendar2" => "Party Time 2!!" + ]; + $email->addContents($contents); + + $email->setTemplateId("d-13b8f94f-bcae-4ec6-b752-70d6cb59f932"); + + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT); + $this->assertTrue($isEqual); + } + + /** + * Test all parameters without using objects with Dynamic Templates + */ + public function testKitchenSinkExampleWithoutObjectsAndDynamicTemplate() + { + $email = new \SendGrid\Mail\Mail(); + + // For a detailed description of each of these settings, + // please see the + // [documentation](https://sendgrid.com/docs/API_Reference/api_v3.html). + $email->setSubject("Sending with Twilio SendGrid is Fun 2"); + + $email->addTo("test@example.com", "Example User"); + $email->addTo("test+1@example.com", "Example User1"); + $toEmails = [ + "test+2@example.com" => "Example User2", + "test+3@example.com" => "Example User3" + ]; + $email->addTos($toEmails); + + $email->addCc("test+4@example.com", "Example User4"); + $ccEmails = [ + "test+5@example.com" => "Example User5", + "test+6@example.com" => "Example User6" + ]; + $email->addCcs($ccEmails); + + $email->addBcc("test+7@example.com", "Example User7"); + $bccEmails = [ + "test+8@example.com" => "Example User8", + "test+9@example.com" => "Example User9" + ]; + $email->addBccs($bccEmails); + + $email->addSubstitution("%name1%", "Example Name 1"); + $email->addSubstitution("%city1%", "Denver"); + $substitutions = [ + "%name2%" => "Example Name 2", + "%city2%" => "Orange" + ]; + $email->addSubstitutions($substitutions); + + // The values below this comment are global to entire message + + $email->setFrom("test@example.com", "DX"); + + $email->setGlobalSubject("Sending with Twilio SendGrid is Fun and Global 2"); + + $email->addContent( + "text/plain", + "and easy to do anywhere, even with PHP" + ); + $email->addContent( + "text/html", + "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $contents = [ + "text/calendar" => "Party Time!!", + "text/calendar2" => "Party Time 2!!" + ]; + $email->addContents($contents); + + $email->setTemplateId("d-13b8f94f-bcae-4ec6-b752-70d6cb59f932"); + + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT); + $this->assertTrue($isEqual); + } + + /** + * Test all parameters using objects + */ + public function testKitchenSinkExampleWithObjectsAndLegacyTemplate() + { + $email = new \SendGrid\Mail\Mail(); + + // For a detailed description of each of these settings, + // please see the + // [documentation](https://sendgrid.com/docs/API_Reference/api_v3.html). + $email->setSubject( + new \SendGrid\Mail\Subject("Sending with Twilio SendGrid is Fun 2") + ); + + $email->addTo(new \SendGrid\Mail\To("test@example.com", "Example User")); + $email->addTo(new \SendGrid\Mail\To("test+1@example.com", "Example User1")); + $toEmails = [ + new \SendGrid\Mail\To("test+2@example.com", "Example User2"), + new \SendGrid\Mail\To("test+3@example.com", "Example User3") + ]; + $email->addTos($toEmails); + + $email->addCc(new \SendGrid\Mail\Cc("test+4@example.com", "Example User4")); + $ccEmails = [ + new \SendGrid\Mail\Cc("test+5@example.com", "Example User5"), + new \SendGrid\Mail\Cc("test+6@example.com", "Example User6") + ]; + $email->addCcs($ccEmails); + + $email->addBcc( + new \SendGrid\Mail\Bcc("test+7@example.com", "Example User7") + ); + $bccEmails = [ + new \SendGrid\Mail\Bcc("test+8@example.com", "Example User8"), + new \SendGrid\Mail\Bcc("test+9@example.com", "Example User9") + ]; + $email->addBccs($bccEmails); + + $email->addSubstitution( + new \SendGrid\Mail\Substitution("%name1%", "Example Name 1") + ); + $email->addSubstitution( + new \SendGrid\Mail\Substitution("%city1%", "Denver") + ); + $substitutions = [ + new \SendGrid\Mail\Substitution("%name2%", "Example Name 2"), + new \SendGrid\Mail\Substitution("%city2%", "Orange") + ]; + $email->addSubstitutions($substitutions); + + // The values below this comment are global to entire message + + $email->setFrom(new \SendGrid\Mail\From("test@example.com", "DX")); + + $email->setGlobalSubject( + new \SendGrid\Mail\Subject("Sending with Twilio SendGrid is Fun and Global 2") + ); + + $plainTextContent = new \SendGrid\Mail\PlainTextContent( + "and easy to do anywhere, even with PHP" + ); + $htmlContent = new \SendGrid\Mail\HtmlContent( + "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $email->addContent($plainTextContent); + $email->addContent($htmlContent); + $contents = [ + new \SendGrid\Mail\Content("text/calendar", "Party Time!!"), + new \SendGrid\Mail\Content("text/calendar2", "Party Time 2!!") + ]; + $email->addContents($contents); + + $email->setTemplateId( + new \SendGrid\Mail\TemplateId("13b8f94f-bcae-4ec6-b752-70d6cb59f932") + ); + + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT_LEGACY); + $this->assertTrue($isEqual); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/FilesExistTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/FilesExistTest.php new file mode 100644 index 0000000..0ce586c --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/FilesExistTest.php @@ -0,0 +1,48 @@ +<?php +/** + * This file tests the existence of necessary files in this repo + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Tests; + +use PHPUnit\Framework\TestCase; + +/** + * This class tests the existence of necessary files in this repo + * + * @package SendGrid\Tests + */ +class FilesExistTest extends TestCase +{ + /** + * This method tests that the required files exist in the repo + */ + public function testFilesArePresentInRepo() + { + $rootDir = __DIR__ . '/../..'; + $this->assertFileExists("$rootDir/docker/Dockerfile"); + //$this->assertFileExists("$rootDir/docker/docker-compose.yml"); + $this->assertFileExists("$rootDir/.codeclimate.yml"); + $this->assertFileExists("$rootDir/.env.sample"); + $this->assertFileExists("$rootDir/.github/ISSUE_TEMPLATE"); + $this->assertFileExists("$rootDir/.github/PULL_REQUEST_TEMPLATE"); + $this->assertFileExists("$rootDir/.gitignore"); + $this->assertFileExists("$rootDir/.travis.yml"); + $this->assertFileExists("$rootDir/CHANGELOG.md"); + $this->assertFileExists("$rootDir/CODE_OF_CONDUCT.md"); + $this->assertFileExists("$rootDir/LICENSE.md"); + $this->assertFileExists("$rootDir/README.md"); + $this->assertFileExists("$rootDir/TROUBLESHOOTING.md"); + $this->assertFileExists("$rootDir/USAGE.md"); + $this->assertFileExists("$rootDir/USE_CASES.md"); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/KitchenSinkTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/KitchenSinkTest.php new file mode 100644 index 0000000..28d047a --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/KitchenSinkTest.php @@ -0,0 +1,1229 @@ +<?php +/** + * This file tests the request object generation for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Tests; + +/** + * This class tests the request object generation for a /mail/send API call + * + * @package SendGrid\Tests + */ +class KitchenSinkTest extends BaseTestClass +{ + + private $REQUEST_OBJECT_DYNAMIC = <<<'JSON' +{ + "asm": { + "group_id": 1, + "groups_to_display": [ + 1, + 2, + 3, + 4 + ] + }, + "attachments": [ + { + "content": "YmFzZTY0IGVuY29kZWQgY29udGVudDE=", + "content_id": "Banner", + "disposition": "inline", + "filename": "banner.png", + "type": "image/png" + }, + { + "content": "YmFzZTY0IGVuY29kZWQgY29udGVudDI=", + "content_id": "Banner 3", + "disposition": "attachment", + "filename": "image/jpeg", + "type": "banner2.jpeg" + }, + { + "content": "YmFzZTY0IGVuY29kZWQgY29udGVudDM=", + "content_id": "Banner 3", + "disposition": "inline", + "filename": "image/gif", + "type": "banner3.gif" + } + ], + "batch_id": "MWQxZmIyODYtNjE1Ni0xMWU1LWI3ZTUtMDgwMDI3OGJkMmY2LWEzMmViMjYxMw", + "categories": [ + "Category 1", + "Category 2", + "Category 3" + ], + "content": [ + { + "type": "text/plain", + "value": "and easy to do anywhere, even with PHP" + }, + { + "type": "text/html", + "value": "<strong>and easy to do anywhere, even with PHP</strong>" + }, + { + "type": "text/calendar", + "value": "Party Time!!" + }, + { + "type": "text/calendar2", + "value": "Party Time 2!!" + } + ], + "from": { + "email": "test@example.com", + "name": "DX" + }, + "headers": { + "X-Day": "Monday", + "X-Month": "January", + "X-Year": "2017" + }, + "ip_pool_name": "23", + "mail_settings": { + "bcc": { + "email": "bcc@example.com", + "enable": true + }, + "bypass_list_management": { + "enable": true + }, + "footer": { + "enable": true, + "html": "<strong>Footer</strong>", + "text": "Footer" + }, + "sandbox_mode": { + "enable": true + }, + "spam_check": { + "enable": true, + "post_to_url": "http://mydomain.com", + "threshold": 1 + } + }, + "personalizations": [ + { + "bcc": [ + { + "email": "test+7@example.com", + "name": "Example User7" + }, + { + "email": "test+8@example.com", + "name": "Example User8" + }, + { + "email": "test+9@example.com", + "name": "Example User9" + } + ], + "cc": [ + { + "email": "test+4@example.com", + "name": "Example User4" + }, + { + "email": "test+5@example.com", + "name": "Example User5" + }, + { + "email": "test+6@example.com", + "name": "Example User6" + } + ], + "custom_args": { + "category": "name", + "marketing1": "false", + "marketing2": "true", + "transactional1": "true", + "transactional2": "false" + }, + "headers": { + "X-Test1": "Test1", + "X-Test2": "Test2", + "X-Test3": "Test3", + "X-Test4": "Test4" + }, + "send_at": 1461775051, + "dynamic_template_data": { + "object": { + "key1": "Key 1", + "key2": "Key 2" + }, + "boolean": false, + "array": [ + "index0", + "index1" + ], + "number": 1 + }, + "to": [ + { + "email": "test@example.com", + "name": "Example User" + }, + { + "email": "test+1@example.com", + "name": "Example User1" + }, + { + "email": "test+2@example.com", + "name": "Example User2" + }, + { + "email": "test+3@example.com", + "name": "Example User3" + } + ] + } + ], + "reply_to": { + "email": "dx+replyto2@example.com", + "name": "DX Team Reply To 2" + }, + "sections": { + "%section1%": "Substitution for Section 1 Tag", + "%section3%": "Substitution for Section 3 Tag", + "%section4%": "Substitution for Section 4 Tag" + }, + "subject": "Sending with Twilio SendGrid is Fun and Global 2", + "template_id": "d-13b8f94fbcae4ec6b75270d6cb59f932", + "tracking_settings": { + "click_tracking": { + "enable": true, + "enable_text": true + }, + "ganalytics": { + "enable": true, + "utm_campaign": "utm_campaign", + "utm_content": "utm_content", + "utm_medium": "utm_medium", + "utm_source": "utm_source", + "utm_term": "utm_term" + }, + "open_tracking": { + "enable": true, + "substitution_tag": "--sub--" + }, + "subscription_tracking": { + "enable": true, + "html": "<bold>subscribe</bold>", + "substitution_tag": "%%sub%%", + "text": "subscribe" + } + } +} +JSON; + + private $REQUEST_OBJECT = <<<'JSON' +{ + "asm": { + "group_id": 1, + "groups_to_display": [ + 1, + 2, + 3, + 4 + ] + }, + "attachments": [ + { + "content": "YmFzZTY0IGVuY29kZWQgY29udGVudDE=", + "content_id": "Banner", + "disposition": "inline", + "filename": "banner.png", + "type": "image/png" + }, + { + "content": "YmFzZTY0IGVuY29kZWQgY29udGVudDI=", + "content_id": "Banner 3", + "disposition": "attachment", + "filename": "image/jpeg", + "type": "banner2.jpeg" + }, + { + "content": "YmFzZTY0IGVuY29kZWQgY29udGVudDM=", + "content_id": "Banner 3", + "disposition": "inline", + "filename": "image/gif", + "type": "banner3.gif" + } + ], + "batch_id": "MWQxZmIyODYtNjE1Ni0xMWU1LWI3ZTUtMDgwMDI3OGJkMmY2LWEzMmViMjYxMw", + "categories": [ + "Category 1", + "Category 2", + "Category 3" + ], + "content": [ + { + "type": "text/plain", + "value": "and easy to do anywhere, even with PHP" + }, + { + "type": "text/html", + "value": "<strong>and easy to do anywhere, even with PHP</strong>" + }, + { + "type": "text/calendar", + "value": "Party Time!!" + }, + { + "type": "text/calendar2", + "value": "Party Time 2!!" + } + ], + "from": { + "email": "test@example.com", + "name": "DX" + }, + "headers": { + "X-Day": "Monday", + "X-Month": "January", + "X-Year": "2017" + }, + "ip_pool_name": "23", + "mail_settings": { + "bcc": { + "email": "bcc@example.com", + "enable": true + }, + "bypass_list_management": { + "enable": true + }, + "footer": { + "enable": true, + "html": "<strong>Footer</strong>", + "text": "Footer" + }, + "sandbox_mode": { + "enable": true + }, + "spam_check": { + "enable": true, + "post_to_url": "http://mydomain.com", + "threshold": 1 + } + }, + "personalizations": [ + { + "bcc": [ + { + "email": "test+7@example.com", + "name": "Example User7" + }, + { + "email": "test+8@example.com", + "name": "Example User8" + }, + { + "email": "test+9@example.com", + "name": "Example User9" + } + ], + "cc": [ + { + "email": "test+4@example.com", + "name": "Example User4" + }, + { + "email": "test+5@example.com", + "name": "Example User5" + }, + { + "email": "test+6@example.com", + "name": "Example User6" + } + ], + "custom_args": { + "category": "name", + "marketing1": "false", + "marketing2": "true", + "transactional1": "true", + "transactional2": "false" + }, + "headers": { + "X-Test1": "Test1", + "X-Test2": "Test2", + "X-Test3": "Test3", + "X-Test4": "Test4" + }, + "send_at": 1461775051, + "substitutions": { + "%city1%": "Denver", + "%city2%": "Orange", + "%name1%": "Example Name 1", + "%name2%": "Example Name 2" + }, + "to": [ + { + "email": "test@example.com", + "name": "Example User" + }, + { + "email": "test+1@example.com", + "name": "Example User1" + }, + { + "email": "test+2@example.com", + "name": "Example User2" + }, + { + "email": "test+3@example.com", + "name": "Example User3" + } + ] + } + ], + "reply_to": { + "email": "dx+replyto2@example.com", + "name": "DX Team Reply To 2" + }, + "sections": { + "%section1%": "Substitution for Section 1 Tag", + "%section3%": "Substitution for Section 3 Tag", + "%section4%": "Substitution for Section 4 Tag" + }, + "subject": "Sending with Twilio SendGrid is Fun and Global 2", + "template_id": "13b8f94f-bcae-4ec6-b752-70d6cb59f932", + "tracking_settings": { + "click_tracking": { + "enable": true, + "enable_text": true + }, + "ganalytics": { + "enable": true, + "utm_campaign": "utm_campaign", + "utm_content": "utm_content", + "utm_medium": "utm_medium", + "utm_source": "utm_source", + "utm_term": "utm_term" + }, + "open_tracking": { + "enable": true, + "substitution_tag": "--sub--" + }, + "subscription_tracking": { + "enable": true, + "html": "<bold>subscribe</bold>", + "substitution_tag": "%%sub%%", + "text": "subscribe" + } + } +} +JSON; + + /** + * Test all parameters without using objects + */ + public function testKitchenSinkExampleWithoutObjects() + { + $email = new \SendGrid\Mail\Mail(); + + // For a detailed description of each of these settings, + // please see the + // [documentation](https://sendgrid.com/docs/API_Reference/api_v3.html). + $email->setSubject("Sending with Twilio SendGrid is Fun 2"); + + $email->addTo("test@example.com", "Example User"); + $email->addTo("test+1@example.com", "Example User1"); + $toEmails = [ + "test+2@example.com" => "Example User2", + "test+3@example.com" => "Example User3" + ]; + $email->addTos($toEmails); + + $email->addCc("test+4@example.com", "Example User4"); + $ccEmails = [ + "test+5@example.com" => "Example User5", + "test+6@example.com" => "Example User6" + ]; + $email->addCcs($ccEmails); + + $email->addBcc("test+7@example.com", "Example User7"); + $bccEmails = [ + "test+8@example.com" => "Example User8", + "test+9@example.com" => "Example User9" + ]; + $email->addBccs($bccEmails); + + $email->addHeader("X-Test1", "Test1"); + $email->addHeader("X-Test2", "Test2"); + $headers = [ + "X-Test3" => "Test3", + "X-Test4" => "Test4", + ]; + $email->addHeaders($headers); + + $email->addSubstitution("%name1%", "Example Name 1"); + $email->addSubstitution("%city1%", "Denver"); + $substitutions = [ + "%name2%" => "Example Name 2", + "%city2%" => "Orange" + ]; + $email->addSubstitutions($substitutions); + + $email->addCustomArg("marketing1", "false"); + $email->addCustomArg("transactional1", "true"); + $email->addCustomArg("category", "name"); + $customArgs = [ + "marketing2" => "true", + "transactional2" => "false", + "category" => "name" + ]; + $email->addCustomArgs($customArgs); + + $email->setSendAt(1461775051); + + // The values below this comment are global to entire message + + $email->setFrom("test@example.com", "DX"); + + $email->setGlobalSubject("Sending with Twilio SendGrid is Fun and Global 2"); + + $email->addContent( + "text/plain", + "and easy to do anywhere, even with PHP" + ); + $email->addContent( + "text/html", + "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $contents = [ + "text/calendar" => "Party Time!!", + "text/calendar2" => "Party Time 2!!" + ]; + $email->addContents($contents); + + $email->addAttachment( + "base64 encoded content1", + "image/png", + "banner.png", + "inline", + "Banner" + ); + $attachments = [ + [ + "base64 encoded content2", + "banner2.jpeg", + "image/jpeg", + "attachment", + "Banner 3" + ], + [ + "base64 encoded content3", + "banner3.gif", + "image/gif", + "inline", + "Banner 3" + ] + ]; + $email->addAttachments($attachments); + + $email->setTemplateId("13b8f94f-bcae-4ec6-b752-70d6cb59f932"); + + $email->addGlobalHeader("X-Day", "Monday"); + $globalHeaders = [ + "X-Month" => "January", + "X-Year" => "2017" + ]; + $email->addGlobalHeaders($globalHeaders); + + $email->addSection("%section1%", "Substitution for Section 1 Tag"); + $sections = [ + "%section3%" => "Substitution for Section 3 Tag", + "%section4%" => "Substitution for Section 4 Tag" + ]; + $email->addSections($sections); + + $email->addCategory("Category 1"); + $categories = [ + "Category 2", + "Category 3" + ]; + $email->addCategories($categories); + + $email->setBatchId( + "MWQxZmIyODYtNjE1Ni0xMWU1LWI3ZTUtMDgwMDI3OGJkMmY2LWEzMmViMjYxMw" + ); + + $email->setReplyTo("dx+replyto2@example.com", "DX Team Reply To 2"); + + $email->setAsm(1, [1, 2, 3, 4]); + + $email->setIpPoolName("23"); + + // Mail Settings + $email->setBccSettings(true, "bcc@example.com"); + $email->enableBypassListManagement(); + //$email->disableBypassListManagement(); + $email->setFooter(true, "Footer", "<strong>Footer</strong>"); + $email->enableSandBoxMode(); + //$email->disableSandBoxMode(); + $email->setSpamCheck(true, 1, "http://mydomain.com"); + + // Tracking Settings + $email->setClickTracking(true, true); + $email->setOpenTracking(true, "--sub--"); + $email->setSubscriptionTracking( + true, + "subscribe", + "<bold>subscribe</bold>", + "%%sub%%" + ); + $email->setGanalytics( + true, + "utm_source", + "utm_medium", + "utm_term", + "utm_content", + "utm_campaign" + ); + + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT); + $this->assertTrue($isEqual); + } + + /** + * Test all parameters without using objects with dynamic templates + */ + public function testKitchenSinkExampleWithoutObjectsWithDynamicTemplates() + { + $email = new \SendGrid\Mail\Mail(); + + // For a detailed description of each of these settings, + // please see the + // [documentation](https://sendgrid.com/docs/API_Reference/api_v3.html). + $email->setSubject("Sending with Twilio SendGrid is Fun 2"); + + $email->addTo("test@example.com", "Example User"); + $email->addTo("test+1@example.com", "Example User1"); + $toEmails = [ + "test+2@example.com" => "Example User2", + "test+3@example.com" => "Example User3" + ]; + $email->addTos($toEmails); + + $email->addCc("test+4@example.com", "Example User4"); + $ccEmails = [ + "test+5@example.com" => "Example User5", + "test+6@example.com" => "Example User6" + ]; + $email->addCcs($ccEmails); + + $email->addBcc("test+7@example.com", "Example User7"); + $bccEmails = [ + "test+8@example.com" => "Example User8", + "test+9@example.com" => "Example User9" + ]; + $email->addBccs($bccEmails); + + $email->addHeader("X-Test1", "Test1"); + $email->addHeader("X-Test2", "Test2"); + $headers = [ + "X-Test3" => "Test3", + "X-Test4" => "Test4", + ]; + $email->addHeaders($headers); + + $email->addDynamicTemplateData('object', [ + 'key1' => 'Key 1', + 'key2' => 'Key 2', + ]); + $email->addDynamicTemplateData('boolean', false); + $email->addDynamicTemplateData('array', [ + 'index0', + 'index1', + ]); + $email->addDynamicTemplateData('number', 1); + + $email->addCustomArg("marketing1", "false"); + $email->addCustomArg("transactional1", "true"); + $email->addCustomArg("category", "name"); + $customArgs = [ + "marketing2" => "true", + "transactional2" => "false", + "category" => "name" + ]; + $email->addCustomArgs($customArgs); + + $email->setSendAt(1461775051); + + // The values below this comment are global to entire message + + $email->setFrom("test@example.com", "DX"); + + $email->setGlobalSubject("Sending with Twilio SendGrid is Fun and Global 2"); + + $email->addContent( + "text/plain", + "and easy to do anywhere, even with PHP" + ); + $email->addContent( + "text/html", + "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $contents = [ + "text/calendar" => "Party Time!!", + "text/calendar2" => "Party Time 2!!" + ]; + $email->addContents($contents); + + $email->addAttachment( + "base64 encoded content1", + "image/png", + "banner.png", + "inline", + "Banner" + ); + $attachments = [ + [ + "base64 encoded content2", + "banner2.jpeg", + "image/jpeg", + "attachment", + "Banner 3" + ], + [ + "base64 encoded content3", + "banner3.gif", + "image/gif", + "inline", + "Banner 3" + ] + ]; + $email->addAttachments($attachments); + + $email->setTemplateId("d-13b8f94fbcae4ec6b75270d6cb59f932"); + + $email->addGlobalHeader("X-Day", "Monday"); + $globalHeaders = [ + "X-Month" => "January", + "X-Year" => "2017" + ]; + $email->addGlobalHeaders($globalHeaders); + + $email->addSection("%section1%", "Substitution for Section 1 Tag"); + $sections = [ + "%section3%" => "Substitution for Section 3 Tag", + "%section4%" => "Substitution for Section 4 Tag" + ]; + $email->addSections($sections); + + $email->addCategory("Category 1"); + $categories = [ + "Category 2", + "Category 3" + ]; + $email->addCategories($categories); + + $email->setBatchId( + "MWQxZmIyODYtNjE1Ni0xMWU1LWI3ZTUtMDgwMDI3OGJkMmY2LWEzMmViMjYxMw" + ); + + $email->setReplyTo("dx+replyto2@example.com", "DX Team Reply To 2"); + + $email->setAsm(1, [1, 2, 3, 4]); + + $email->setIpPoolName("23"); + + // Mail Settings + $email->setBccSettings(true, "bcc@example.com"); + $email->enableBypassListManagement(); + //$email->disableBypassListManagement(); + $email->setFooter(true, "Footer", "<strong>Footer</strong>"); + $email->enableSandBoxMode(); + //$email->disableSandBoxMode(); + $email->setSpamCheck(true, 1, "http://mydomain.com"); + + // Tracking Settings + $email->setClickTracking(true, true); + $email->setOpenTracking(true, "--sub--"); + $email->setSubscriptionTracking( + true, + "subscribe", + "<bold>subscribe</bold>", + "%%sub%%" + ); + $email->setGanalytics( + true, + "utm_source", + "utm_medium", + "utm_term", + "utm_content", + "utm_campaign" + ); + + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT_DYNAMIC); + $this->assertTrue($isEqual); + } + + + /** + * Test all parameters using objects + */ + public function testKitchenSinkExampleWithObjects() + { + $email = new \SendGrid\Mail\Mail(); + + // For a detailed description of each of these settings, + // please see the + // [documentation](https://sendgrid.com/docs/API_Reference/api_v3.html). + $email->setSubject( + new \SendGrid\Mail\Subject("Sending with Twilio SendGrid is Fun 2") + ); + + $email->addTo(new \SendGrid\Mail\To("test@example.com", "Example User")); + $email->addTo(new \SendGrid\Mail\To("test+1@example.com", "Example User1")); + $toEmails = [ + new \SendGrid\Mail\To("test+2@example.com", "Example User2"), + new \SendGrid\Mail\To("test+3@example.com", "Example User3") + ]; + $email->addTos($toEmails); + + $email->addCc(new \SendGrid\Mail\Cc("test+4@example.com", "Example User4")); + $ccEmails = [ + new \SendGrid\Mail\Cc("test+5@example.com", "Example User5"), + new \SendGrid\Mail\Cc("test+6@example.com", "Example User6") + ]; + $email->addCcs($ccEmails); + + $email->addBcc( + new \SendGrid\Mail\Bcc("test+7@example.com", "Example User7") + ); + $bccEmails = [ + new \SendGrid\Mail\Bcc("test+8@example.com", "Example User8"), + new \SendGrid\Mail\Bcc("test+9@example.com", "Example User9") + ]; + $email->addBccs($bccEmails); + + $email->addHeader(new \SendGrid\Mail\Header("X-Test1", "Test1")); + $email->addHeader(new \SendGrid\Mail\Header("X-Test2", "Test2")); + $headers = [ + new \SendGrid\Mail\Header("X-Test3", "Test3"), + new \SendGrid\Mail\Header("X-Test4", "Test4") + ]; + $email->addHeaders($headers); + + $email->addSubstitution( + new \SendGrid\Mail\Substitution("%name1%", "Example Name 1") + ); + $email->addSubstitution( + new \SendGrid\Mail\Substitution("%city1%", "Denver") + ); + $substitutions = [ + new \SendGrid\Mail\Substitution("%name2%", "Example Name 2"), + new \SendGrid\Mail\Substitution("%city2%", "Orange") + ]; + $email->addSubstitutions($substitutions); + + $email->addCustomArg(new \SendGrid\Mail\CustomArg("marketing1", "false")); + $email->addCustomArg(new \SendGrid\Mail\CustomArg("transactional1", "true")); + $email->addCustomArg(new \SendGrid\Mail\CustomArg("category", "name")); + $customArgs = [ + new \SendGrid\Mail\CustomArg("marketing2", "true"), + new \SendGrid\Mail\CustomArg("transactional2", "false"), + new \SendGrid\Mail\CustomArg("category", "name") + ]; + $email->addCustomArgs($customArgs); + + $email->setSendAt(new \SendGrid\Mail\SendAt(1461775051)); + + // The values below this comment are global to entire message + + $email->setFrom(new \SendGrid\Mail\From("test@example.com", "DX")); + + $email->setGlobalSubject( + new \SendGrid\Mail\Subject("Sending with Twilio SendGrid is Fun and Global 2") + ); + + $plainTextContent = new \SendGrid\Mail\PlainTextContent( + "and easy to do anywhere, even with PHP" + ); + $htmlContent = new \SendGrid\Mail\HtmlContent( + "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $email->addContent($plainTextContent); + $email->addContent($htmlContent); + $contents = [ + new \SendGrid\Mail\Content("text/calendar", "Party Time!!"), + new \SendGrid\Mail\Content("text/calendar2", "Party Time 2!!") + ]; + $email->addContents($contents); + + $email->addAttachment( + new \SendGrid\Mail\Attachment( + "base64 encoded content1", + "image/png", + "banner.png", + "inline", + "Banner" + ) + ); + $attachments = [ + new \SendGrid\Mail\Attachment( + "base64 encoded content2", + "banner2.jpeg", + "image/jpeg", + "attachment", + "Banner 3" + ), + new \SendGrid\Mail\Attachment( + "base64 encoded content3", + "banner3.gif", + "image/gif", + "inline", + "Banner 3" + ) + ]; + $email->addAttachments($attachments); + + $email->setTemplateId( + new \SendGrid\Mail\TemplateId("13b8f94f-bcae-4ec6-b752-70d6cb59f932") + ); + + $email->addGlobalHeader(new \SendGrid\Mail\Header("X-Day", "Monday")); + $globalHeaders = [ + new \SendGrid\Mail\Header("X-Month", "January"), + new \SendGrid\Mail\Header("X-Year", "2017") + ]; + $email->addGlobalHeaders($globalHeaders); + + $email->addSection( + new \SendGrid\Mail\Section( + "%section1%", + "Substitution for Section 1 Tag" + ) + ); + + $sections = [ + new \SendGrid\Mail\Section( + "%section3%", + "Substitution for Section 3 Tag" + ), + new \SendGrid\Mail\Section( + "%section4%", + "Substitution for Section 4 Tag" + ) + ]; + $email->addSections($sections); + + $email->addCategory(new \SendGrid\Mail\Category("Category 1")); + $categories = [ + new \SendGrid\Mail\Category("Category 2"), + new \SendGrid\Mail\Category("Category 3") + ]; + $email->addCategories($categories); + + $email->setBatchId( + new \SendGrid\Mail\BatchId( + "MWQxZmIyODYtNjE1Ni0xMWU1LWI3ZTUtMDgwMDI3OGJkMmY2LWEzMmViMjYxMw" + ) + ); + + $email->setReplyTo( + new \SendGrid\Mail\ReplyTo( + "dx+replyto2@example.com", + "DX Team Reply To 2" + ) + ); + + $asm = new \SendGrid\Mail\Asm( + new \SendGrid\Mail\GroupId(1), + new \SendGrid\Mail\GroupsToDisplay([1, 2, 3, 4]) + ); + $email->setAsm($asm); + + $email->setIpPoolName(new \SendGrid\Mail\IpPoolName("23")); + + $mail_settings = new \SendGrid\Mail\MailSettings(); + $mail_settings->setBccSettings( + new \SendGrid\Mail\BccSettings(true, "bcc@example.com") + ); + $mail_settings->setBypassListManagement( + new \SendGrid\Mail\BypassListManagement(true) + ); + $mail_settings->setFooter( + new \SendGrid\Mail\Footer(true, "Footer", "<strong>Footer</strong>") + ); + $mail_settings->setSandBoxMode(new \SendGrid\Mail\SandBoxMode(true)); + $mail_settings->setSpamCheck( + new \SendGrid\Mail\SpamCheck(true, 1, "http://mydomain.com") + ); + $email->setMailSettings($mail_settings); + + $tracking_settings = new \SendGrid\Mail\TrackingSettings(); + $tracking_settings->setClickTracking( + new \SendGrid\Mail\ClickTracking(true, true) + ); + $tracking_settings->setOpenTracking( + new \SendGrid\Mail\OpenTracking(true, "--sub--") + ); + $tracking_settings->setSubscriptionTracking( + new \SendGrid\Mail\SubscriptionTracking( + true, + "subscribe", + "<bold>subscribe</bold>", + "%%sub%%" + ) + ); + $tracking_settings->setGanalytics( + new \SendGrid\Mail\Ganalytics( + true, + "utm_source", + "utm_medium", + "utm_term", + "utm_content", + "utm_campaign" + ) + ); + $email->setTrackingSettings($tracking_settings); + + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT); + $this->assertTrue($isEqual); + } + + /** + * Test all parameters using objects with dynamic templates + */ + public function testKitchenSinkExampleWithObjectsWithDynamicTemplate() + { + $email = new \SendGrid\Mail\Mail(); + + // For a detailed description of each of these settings, + // please see the + // [documentation](https://sendgrid.com/docs/API_Reference/api_v3.html). + $email->setSubject( + new \SendGrid\Mail\Subject("Sending with Twilio SendGrid is Fun 2") + ); + + $email->addTo(new \SendGrid\Mail\To("test@example.com", "Example User")); + $email->addTo(new \SendGrid\Mail\To("test+1@example.com", "Example User1")); + $toEmails = [ + new \SendGrid\Mail\To("test+2@example.com", "Example User2"), + new \SendGrid\Mail\To("test+3@example.com", "Example User3") + ]; + $email->addTos($toEmails); + + $email->addCc(new \SendGrid\Mail\Cc("test+4@example.com", "Example User4")); + $ccEmails = [ + new \SendGrid\Mail\Cc("test+5@example.com", "Example User5"), + new \SendGrid\Mail\Cc("test+6@example.com", "Example User6") + ]; + $email->addCcs($ccEmails); + + $email->addBcc( + new \SendGrid\Mail\Bcc("test+7@example.com", "Example User7") + ); + $bccEmails = [ + new \SendGrid\Mail\Bcc("test+8@example.com", "Example User8"), + new \SendGrid\Mail\Bcc("test+9@example.com", "Example User9") + ]; + $email->addBccs($bccEmails); + + $email->addHeader(new \SendGrid\Mail\Header("X-Test1", "Test1")); + $email->addHeader(new \SendGrid\Mail\Header("X-Test2", "Test2")); + $headers = [ + new \SendGrid\Mail\Header("X-Test3", "Test3"), + new \SendGrid\Mail\Header("X-Test4", "Test4") + ]; + $email->addHeaders($headers); + + $email->addDynamicTemplateData( + new \SendGrid\Mail\Substitution('object', [ + 'key1' => 'Key 1', + 'key2' => 'Key 2', + ]) + ); + $email->addDynamicTemplateData( + new \SendGrid\Mail\Substitution('boolean', false) + ); + $email->addDynamicTemplateDatas([ + new \SendGrid\Mail\Substitution('array', [ + 'index0', + 'index1', + ]), + new \SendGrid\Mail\Substitution('number', 1), + ]); + + $email->addCustomArg(new \SendGrid\Mail\CustomArg("marketing1", "false")); + $email->addCustomArg(new \SendGrid\Mail\CustomArg("transactional1", "true")); + $email->addCustomArg(new \SendGrid\Mail\CustomArg("category", "name")); + $customArgs = [ + new \SendGrid\Mail\CustomArg("marketing2", "true"), + new \SendGrid\Mail\CustomArg("transactional2", "false"), + new \SendGrid\Mail\CustomArg("category", "name") + ]; + $email->addCustomArgs($customArgs); + + $email->setSendAt(new \SendGrid\Mail\SendAt(1461775051)); + + // The values below this comment are global to entire message + + $email->setFrom(new \SendGrid\Mail\From("test@example.com", "DX")); + + $email->setGlobalSubject( + new \SendGrid\Mail\Subject("Sending with Twilio SendGrid is Fun and Global 2") + ); + + $plainTextContent = new \SendGrid\Mail\PlainTextContent( + "and easy to do anywhere, even with PHP" + ); + $htmlContent = new \SendGrid\Mail\HtmlContent( + "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $email->addContent($plainTextContent); + $email->addContent($htmlContent); + $contents = [ + new \SendGrid\Mail\Content("text/calendar", "Party Time!!"), + new \SendGrid\Mail\Content("text/calendar2", "Party Time 2!!") + ]; + $email->addContents($contents); + + $email->addAttachment( + new \SendGrid\Mail\Attachment( + "base64 encoded content1", + "image/png", + "banner.png", + "inline", + "Banner" + ) + ); + $attachments = [ + new \SendGrid\Mail\Attachment( + "base64 encoded content2", + "banner2.jpeg", + "image/jpeg", + "attachment", + "Banner 3" + ), + new \SendGrid\Mail\Attachment( + "base64 encoded content3", + "banner3.gif", + "image/gif", + "inline", + "Banner 3" + ) + ]; + $email->addAttachments($attachments); + + $email->setTemplateId( + new \SendGrid\Mail\TemplateId("d-13b8f94fbcae4ec6b75270d6cb59f932") + ); + + $email->addGlobalHeader(new \SendGrid\Mail\Header("X-Day", "Monday")); + $globalHeaders = [ + new \SendGrid\Mail\Header("X-Month", "January"), + new \SendGrid\Mail\Header("X-Year", "2017") + ]; + $email->addGlobalHeaders($globalHeaders); + + $email->addSection( + new \SendGrid\Mail\Section( + "%section1%", + "Substitution for Section 1 Tag" + ) + ); + + $sections = [ + new \SendGrid\Mail\Section( + "%section3%", + "Substitution for Section 3 Tag" + ), + new \SendGrid\Mail\Section( + "%section4%", + "Substitution for Section 4 Tag" + ) + ]; + $email->addSections($sections); + + $email->addCategory(new \SendGrid\Mail\Category("Category 1")); + $categories = [ + new \SendGrid\Mail\Category("Category 2"), + new \SendGrid\Mail\Category("Category 3") + ]; + $email->addCategories($categories); + + $email->setBatchId( + new \SendGrid\Mail\BatchId( + "MWQxZmIyODYtNjE1Ni0xMWU1LWI3ZTUtMDgwMDI3OGJkMmY2LWEzMmViMjYxMw" + ) + ); + + $email->setReplyTo( + new \SendGrid\Mail\ReplyTo( + "dx+replyto2@example.com", + "DX Team Reply To 2" + ) + ); + + $asm = new \SendGrid\Mail\Asm( + new \SendGrid\Mail\GroupId(1), + new \SendGrid\Mail\GroupsToDisplay([1, 2, 3, 4]) + ); + $email->setAsm($asm); + + $email->setIpPoolName(new \SendGrid\Mail\IpPoolName("23")); + + $mail_settings = new \SendGrid\Mail\MailSettings(); + $mail_settings->setBccSettings( + new \SendGrid\Mail\BccSettings(true, "bcc@example.com") + ); + $mail_settings->setBypassListManagement( + new \SendGrid\Mail\BypassListManagement(true) + ); + $mail_settings->setFooter( + new \SendGrid\Mail\Footer(true, "Footer", "<strong>Footer</strong>") + ); + $mail_settings->setSandBoxMode(new \SendGrid\Mail\SandBoxMode(true)); + $mail_settings->setSpamCheck( + new \SendGrid\Mail\SpamCheck(true, 1, "http://mydomain.com") + ); + $email->setMailSettings($mail_settings); + + $tracking_settings = new \SendGrid\Mail\TrackingSettings(); + $tracking_settings->setClickTracking( + new \SendGrid\Mail\ClickTracking(true, true) + ); + $tracking_settings->setOpenTracking( + new \SendGrid\Mail\OpenTracking(true, "--sub--") + ); + $tracking_settings->setSubscriptionTracking( + new \SendGrid\Mail\SubscriptionTracking( + true, + "subscribe", + "<bold>subscribe</bold>", + "%%sub%%" + ) + ); + $tracking_settings->setGanalytics( + new \SendGrid\Mail\Ganalytics( + true, + "utm_source", + "utm_medium", + "utm_term", + "utm_content", + "utm_campaign" + ) + ); + $email->setTrackingSettings($tracking_settings); + + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT_DYNAMIC); + $this->assertTrue($isEqual); + } +}
\ No newline at end of file diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/MailGetContentsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/MailGetContentsTest.php new file mode 100644 index 0000000..cda8337 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/MailGetContentsTest.php @@ -0,0 +1,38 @@ +<?php + +namespace SendGrid\Tests; + +use PHPUnit\Framework\TestCase; +use SendGrid\Mail\Mail; +use SendGrid\Mail\Content; +use SendGrid\Mail\EmailAddress; +use SendGrid\Mail\From; + +/** + * This class tests the getContents() function in SendGrid\Mail\Mail + * + * @package SendGrid\Tests + */ +class MailGetContentsTest extends TestCase +{ + + /** + * This method tests that array from Mail getContents() returns with + * text/plain Content object first when Mail instantiated with text/html + * content before text/plain + * + * @return null + */ + public function testWillReturnPlainContentFirst() + { + $email = new \SendGrid\Mail\Mail(); + $email->setFrom("test@example.com", null); + $email->setSubject("Hello World from the Twilio SendGrid PHP Library"); + $email->addTo("test@example.com", "Test Person"); + + $email->addContent("text/html", "<p>some text here</p>"); + $email->addContent("text/plain", "some text here"); + + $this->assertEquals('text/plain', $email->getContents()[0]->getType()); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/MailHelperTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/MailHelperTest.php new file mode 100644 index 0000000..7a3487f --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/MailHelperTest.php @@ -0,0 +1,84 @@ +<?php +/** + * This file tests email address encoding + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Tests; + +use SendGrid\Mail\EmailAddress as EmailAddress; + +/** + * This class tests email address encoding + * + * @package SendGrid\Tests + */ +class MailTest_Mail extends \PHPUnit\Framework\TestCase +{ + /** + * This method tests various types of unencoded emails + * + * @expectedException \SendGrid\Mail\TypeException + */ + public function testEmailName() + { + $email = new EmailAddress('test@example.com', 'John Doe'); + $json = json_encode($email->jsonSerialize()); + $this->assertEquals($json, '{"name":"John Doe","email":"test@example.com"}'); + + $email->setName(''); + $json = json_encode($email->jsonSerialize()); + $this->assertEquals($json, '{"email":"test@example.com"}'); + + $email->setName(null); + $json = json_encode($email->jsonSerialize()); + $this->assertEquals($json, '{"email":"test@example.com"}'); + + $email->setName('Doe, John'); + $json = json_encode($email->jsonSerialize()); + $this->assertEquals( + $json, + '{"name":"\\"Doe, John\\"","email":"test@example.com"}' + ); + + $email->setName('Doe; John'); + $json = json_encode($email->jsonSerialize()); + $this->assertEquals( + $json, + '{"name":"\\"Doe; John\\"","email":"test@example.com"}' + ); + + $email->setName('John "Billy" O\'Keeffe'); + $json = json_encode($email->jsonSerialize()); + $this->assertEquals( + $json, + '{"name":"John \\"Billy\\" O\'Keeffe","email":"test@example.com"}' + ); + + $email->setName('O\'Keeffe, John "Billy"'); + $json = json_encode($email->jsonSerialize()); + $this->assertEquals( + $json, + '{"name":"\\"O\'Keeffe, John \\\\\\"Billy\\\\\\"\\"","email":"test@example.com"}' + ); + } + + /** + * This method tests TypeException for wrong email address + * + * @expectedException \SendGrid\Mail\TypeException + */ + public function testEmailAddress() + { + $email = new EmailAddress(); + $email->setEmailAddress('test@example.com@wrong'); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/MultipleEmailToMultipleRecipientsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/MultipleEmailToMultipleRecipientsTest.php new file mode 100644 index 0000000..e168fd5 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/MultipleEmailToMultipleRecipientsTest.php @@ -0,0 +1,517 @@ +<?php +/** + * This file tests the request object generation for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Tests; + +/** + * This class tests the request object generation for a /mail/send API call + * + * @package SendGrid\Tests + */ +class MultipleEmailToMulipleRecipientsTest extends BaseTestClass +{ + + private $REQUEST_OBJECT = <<<'JSON' +{ + "content": [ + { + "type": "text/plain", + "value": "Hello -name-, your github is -github- sent at -time-" + }, + { + "type": "text/html", + "value": "<strong>Hello -name-, your github is <a href=\"-github-\">here</a></strong> sent at -time-" + } + ], + "from": { + "email": "test@example.com", + "name": "Example User" + }, + "personalizations": [ + { + "subject": "Subject 1 -name-", + "substitutions": { + "-github-": "http://github.com/example_user1", + "-name-": "Example User 1", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test1@example.com", + "name": "Example User1" + } + ] + }, + { + "subject": "Subject 2 -name-", + "substitutions": { + "-github-": "http://github.com/example_user2", + "-name-": "Example User 2", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test2@example.com", + "name": "Example User2" + } + ] + }, + { + "substitutions": { + "-github-": "http://github.com/example_user3", + "-name-": "Example User 3", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test3@example.com", + "name": "Example User3" + } + ] + } + ], + "subject": "Hi -name-!" +} +JSON; + + private $REQUEST_OBJECT_2 = <<<'JSON' +{ + "content": [ + { + "type": "text/plain", + "value": "Hello -name-, your github is -github- sent at -time-" + }, + { + "type": "text/html", + "value": "<strong>Hello -name-, your github is <a href=\"-github-\">here</a></strong> sent at -time-" + } + ], + "from": { + "email": "test@example.com", + "name": "Example User" + }, + "personalizations": [ + { + "subject": "Subject 1 -name-", + "substitutions": { + "-github-": "http://github.com/example_user1", + "-name-": "Example User 1", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test1@example.com", + "name": "Example User1" + } + ] + }, + { + "subject": "Subject 2 -name-", + "substitutions": { + "-github-": "http://github.com/example_user2", + "-name-": "Example User 2", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test2@example.com", + "name": "Example User2" + } + ] + }, + { + "substitutions": { + "-github-": "http://github.com/example_user3", + "-name-": "Example User 3", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test3@example.com", + "name": "Example User3" + } + ] + } + ] +} +JSON; + + private $REQUEST_OBJECT_3 = <<<'JSON' +{ + "content": [ + { + "type": "text/plain", + "value": "Hello -name-, your github is -github- sent at -time-" + }, + { + "type": "text/html", + "value": "<strong>Hello -name-, your github is <a href=\"-github-\">here</a></strong> sent at -time-" + } + ], + "from": { + "email": "test@example.com", + "name": "Example User" + }, + "personalizations": [ + { + "subject": "Subject 1 -name-", + "dynamic_template_data": { + "-github-": "http://github.com/example_user1", + "-name-": "Example User 1", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test1@example.com", + "name": "Example User1" + } + ] + }, + { + "subject": "Subject 2 -name-", + "dynamic_template_data": { + "-github-": "http://github.com/example_user2", + "-name-": "Example User 2", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test2@example.com", + "name": "Example User2" + } + ] + }, + { + "dynamic_template_data": { + "-github-": "http://github.com/example_user3", + "-name-": "Example User 3", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test3@example.com", + "name": "Example User3" + } + ] + } + ], + "template_id": "d-13b8f94f-bcae-4ec6-b752-70d6cb59f932", + "subject": "Hi -name-!" +} +JSON; + + private $REQUEST_OBJECT_4 = <<<'JSON' +{ + "content": [ + { + "type": "text/plain", + "value": "Hello -name-, your github is -github- sent at -time-" + }, + { + "type": "text/html", + "value": "<strong>Hello -name-, your github is <a href=\"-github-\">here</a></strong> sent at -time-" + } + ], + "from": { + "email": "test@example.com", + "name": "Example User" + }, + "personalizations": [ + { + "subject": "Subject 1 -name-", + "dynamic_template_data": { + "-github-": "http://github.com/example_user1", + "-name-": "Example User 1", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test1@example.com", + "name": "Example User1" + } + ] + }, + { + "subject": "Subject 2 -name-", + "dynamic_template_data": { + "-github-": "http://github.com/example_user2", + "-name-": "Example User 2", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test2@example.com", + "name": "Example User2" + } + ] + }, + { + "dynamic_template_data": { + "-github-": "http://github.com/example_user3", + "-name-": "Example User 3", + "-time-": "2018-05-03 23:10:29" + }, + "to": [ + { + "email": "test+test3@example.com", + "name": "Example User3" + } + ] + } + ], + "template_id": "d-13b8f94f-bcae-4ec6-b752-70d6cb59f932" +} +JSON; + + /** + * Test when we have individual subjects for each Personalization object + */ + public function testWithIndividualSubjects() + { + $from = new \SendGrid\Mail\From("test@example.com", "Example User"); + $tos = [ + new \SendGrid\Mail\To( + "test+test1@example.com", + "Example User1", + [ + '-name-' => 'Example User 1', + '-github-' => 'http://github.com/example_user1' + ], + "Subject 1 -name-" + ), + new \SendGrid\Mail\To( + "test+test2@example.com", + "Example User2", + [ + '-name-' => 'Example User 2', + '-github-' => 'http://github.com/example_user2' + ], + "Subject 2 -name-" + ), + new \SendGrid\Mail\To( + "test+test3@example.com", + "Example User3", + [ + '-name-' => 'Example User 3', + '-github-' => 'http://github.com/example_user3' + ] + ) + ]; + $subject = new \SendGrid\Mail\Subject("Hi -name-!"); // default subject + $globalSubstitutions = [ + '-time-' => "2018-05-03 23:10:29" + ]; + $plainTextContent = new \SendGrid\Mail\PlainTextContent( + "Hello -name-, your github is -github- sent at -time-" + ); + $htmlContent = new \SendGrid\Mail\HtmlContent( + "<strong>Hello -name-, your github is <a href=\"-github-\">here</a></strong> sent at -time-" + ); + $email = new \SendGrid\Mail\Mail( + $from, + $tos, + $subject, // or array of subjects, these take precendence + $plainTextContent, + $htmlContent, + $globalSubstitutions + ); + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT); + $this->assertTrue($isEqual); + } + + /** + * Test when we have individual subjects using dynamic templates for each Personalization object + */ + public function testWithIndividualSubjectsDynamicTemplates() + { + $from = new \SendGrid\Mail\From("test@example.com", "Example User"); + $tos = [ + new \SendGrid\Mail\To( + "test+test1@example.com", + "Example User1", + [ + '-name-' => 'Example User 1', + '-github-' => 'http://github.com/example_user1' + ], + "Subject 1 -name-" + ), + new \SendGrid\Mail\To( + "test+test2@example.com", + "Example User2", + [ + '-name-' => 'Example User 2', + '-github-' => 'http://github.com/example_user2' + ], + "Subject 2 -name-" + ), + new \SendGrid\Mail\To( + "test+test3@example.com", + "Example User3", + [ + '-name-' => 'Example User 3', + '-github-' => 'http://github.com/example_user3' + ] + ) + ]; + $subject = new \SendGrid\Mail\Subject("Hi -name-!"); // default subject + $globalSubstitutions = [ + '-time-' => "2018-05-03 23:10:29" + ]; + $plainTextContent = new \SendGrid\Mail\PlainTextContent( + "Hello -name-, your github is -github- sent at -time-" + ); + $htmlContent = new \SendGrid\Mail\HtmlContent( + "<strong>Hello -name-, your github is <a href=\"-github-\">here</a></strong> sent at -time-" + ); + $email = new \SendGrid\Mail\Mail( + $from, + $tos, + $subject, // or array of subjects, these take precendence + $plainTextContent, + $htmlContent, + $globalSubstitutions + ); + $email->setTemplateId("d-13b8f94f-bcae-4ec6-b752-70d6cb59f932"); + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT_3); + $this->assertTrue($isEqual); + } + + /** + * Test when we pass in an array of subjects + * + * @expectedException \SendGrid\Mail\TypeException + */ + public function testWithCollectionOfSubjects() + { + $from = new \SendGrid\Mail\From("test@example.com", "Example User"); + $tos = [ + new \SendGrid\Mail\To( + "test+test1@example.com", + "Example User1", + [ + '-name-' => 'Example User 1', + '-github-' => 'http://github.com/example_user1' + ], + "Example User1 -name-" + ), + new \SendGrid\Mail\To( + "test+test2@example.com", + "Example User2", + [ + '-name-' => 'Example User 2', + '-github-' => 'http://github.com/example_user2' + ], + "Example User2 -name-" + ), + new \SendGrid\Mail\To( + "test+test3@example.com", + "Example User3", + [ + '-name-' => 'Example User 3', + '-github-' => 'http://github.com/example_user3' + ] + ) + ]; + $subject = [ + "Subject 1 -name-", + "Subject 2 -name-" + ]; + $globalSubstitutions = [ + '-time-' => "2018-05-03 23:10:29" + ]; + $plainTextContent = new \SendGrid\Mail\PlainTextContent( + "Hello -name-, your github is -github- sent at -time-" + ); + $htmlContent = new \SendGrid\Mail\HtmlContent( + "<strong>Hello -name-, your github is <a href=\"-github-\">here</a></strong> sent at -time-" + ); + $email = new \SendGrid\Mail\Mail( + $from, + $tos, + $subject, // or array of subjects, these take precendence + $plainTextContent, + $htmlContent, + $globalSubstitutions + ); + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT_2); + $this->assertTrue($isEqual); + } + + /** + * Test when we pass in an array of subjects + * + * @expectedException \SendGrid\Mail\TypeException + */ + public function testWithCollectionOfSubjectsDynamic() + { + $from = new \SendGrid\Mail\From("test@example.com", "Example User"); + $tos = [ + new \SendGrid\Mail\To( + "test+test1@example.com", + "Example User1", + [ + '-name-' => 'Example User 1', + '-github-' => 'http://github.com/example_user1' + ], + "Example User1 -name-" + ), + new \SendGrid\Mail\To( + "test+test2@example.com", + "Example User2", + [ + '-name-' => 'Example User 2', + '-github-' => 'http://github.com/example_user2' + ], + "Example User2 -name-" + ), + new \SendGrid\Mail\To( + "test+test3@example.com", + "Example User3", + [ + '-name-' => 'Example User 3', + '-github-' => 'http://github.com/example_user3' + ] + ) + ]; + $subject = [ + "Subject 1 -name-", + "Subject 2 -name-" + ]; + $globalSubstitutions = [ + '-time-' => "2018-05-03 23:10:29" + ]; + $plainTextContent = new \SendGrid\Mail\PlainTextContent( + "Hello -name-, your github is -github- sent at -time-" + ); + $htmlContent = new \SendGrid\Mail\HtmlContent( + "<strong>Hello -name-, your github is <a href=\"-github-\">here</a></strong> sent at -time-" + ); + $email = new \SendGrid\Mail\Mail( + $from, + $tos, + $subject, // or array of subjects, these take precendence + $plainTextContent, + $htmlContent, + $globalSubstitutions + ); + $email->setTemplateId("d-13b8f94f-bcae-4ec6-b752-70d6cb59f932"); + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT_2); + $this->assertTrue($isEqual); + } + +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/SendGridTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/SendGridTest.php new file mode 100644 index 0000000..274e7aa --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/SendGridTest.php @@ -0,0 +1,88 @@ +<?php +/** + * This file tests the SendGrid Client + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Tests; + +/** + * This class tests the Twilio SendGrid Client + * + * @package SendGrid\Tests + */ +class SendGridTest extends BaseTestClass +{ + /** + * Test if the version is correct + */ + public function testVersionIsCorrect() + { + $this->assertEquals(\SendGrid::VERSION, '7.3.0'); + $version = json_decode( + file_get_contents(__DIR__ . '/../../composer.json') + )->version; + $this->assertEquals( + $version, + \SendGrid::VERSION + ); + } + + /** + * Test that we can connect to the Twilio SendGrid API + */ + public function testCanConnectToSendGridApi() + { + $sg = new \SendGrid(self::$apiKey); + $headers = [ + 'Authorization: Bearer ' . self::$apiKey, + 'User-Agent: sendgrid/' . $sg->version . ';php', + 'Accept: application/json' + ]; + + $this->assertEquals( + $sg->client->getHost(), + 'https://api.sendgrid.com', + '/v3' + ); + $this->assertEquals( + $sg->client->getHeaders(), + $headers + ); + $this->assertEquals($sg->client->getVersion(), '/v3'); + + $sg2 = new \SendGrid(self::$apiKey, ['host' => 'https://api.test.com']); + $this->assertEquals($sg2->client->getHost(), 'https://api.test.com'); + + $sg3 = new \SendGrid(self::$apiKey, ['curl' => ['foo' => 'bar']]); + $this->assertEquals(['foo' => 'bar'], $sg3->client->getCurlOptions()); + + $sg4 = new \SendGrid( + self::$apiKey, + ['curl' => [CURLOPT_PROXY => '127.0.0.1:8000']] + ); + $this->assertEquals( + $sg4->client->getCurlOptions(), + [10004 => '127.0.0.1:8000'] + ); + + $subuser = 'abcxyz@this.is.a.test.subuser'; + $headers[] = 'On-Behalf-Of: ' . $subuser; + $sg5 = new \SendGrid( + self::$apiKey, + ['impersonateSubuser' => $subuser] + ); + $this->assertSame( + $headers, + $sg5->client->getHeaders() + ); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/SingleEmailToASingleRecipientTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/SingleEmailToASingleRecipientTest.php new file mode 100644 index 0000000..ad9053d --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/SingleEmailToASingleRecipientTest.php @@ -0,0 +1,98 @@ +<?php +/** + * This file tests the request object generation for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Tests; + +/** + * This class tests the request object generation for a /mail/send API call + * + * @package SendGrid\Tests + */ +class SingleEmailToASingleRecipientTest extends BaseTestClass +{ + + private $REQUEST_OBJECT = <<<'JSON' +{ + "personalizations": [ + { + "to": [ + { + "email": "test@example.com", + "name": "Example User" + } + ] + } + ], + "subject": "Sending with Twilio SendGrid is Fun", + "from": { + "email": "test@example.com", + "name": "Example User" + }, + "content": [ + { + "type": "text/plain", + "value": "and easy to do anywhere, even with PHP" + }, + { + "type": "text/html", + "value": "<strong>and easy to do anywhere, even with PHP</strong>" + } + ] +} +JSON; + + /** + * Test all parameters using objects + */ + public function testWithObjects() + { + $from = new \SendGrid\Mail\From("test@example.com", "Example User"); + $subject = new \SendGrid\Mail\Subject("Sending with Twilio SendGrid is Fun"); + $to = new \SendGrid\Mail\To("test@example.com", "Example User"); + $plainTextContent = new \SendGrid\Mail\PlainTextContent( + "and easy to do anywhere, even with PHP" + ); + $htmlContent = new \SendGrid\Mail\HtmlContent( + "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $email = new \SendGrid\Mail\Mail( + $from, + $to, + $subject, + $plainTextContent, + $htmlContent + ); + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT); + $this->assertTrue($isEqual); + } + + /** + * Test all parameters without using objects + */ + public function testWithoutObjects() + { + $email = new \SendGrid\Mail\Mail(); + $email->setFrom("test@example.com", "Example User"); + $email->setSubject("Sending with Twilio SendGrid is Fun"); + $email->addTo("test@example.com", "Example User"); + $email->addContent("text/plain", "and easy to do anywhere, even with PHP"); + $email->addContent( + "text/html", "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT); + $this->assertTrue($isEqual); + } +} diff --git a/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/SingleEmailToMultipleRecipientsTest.php b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/SingleEmailToMultipleRecipientsTest.php new file mode 100644 index 0000000..40b1b83 --- /dev/null +++ b/Postman/Postman-Mail/sendgrid/vendor/sendgrid/sendgrid/test/unit/SingleEmailToMultipleRecipientsTest.php @@ -0,0 +1,117 @@ +<?php +/** + * This file tests the request object generation for a /mail/send API call + * + * PHP Version - 5.6, 7.0, 7.1, 7.2 + * + * @package SendGrid\Tests + * @author Elmer Thomas <dx@sendgrid.com> + * @copyright 2018-19 Twilio SendGrid + * @license https://opensource.org/licenses/MIT The MIT License + * @version GIT: <git_id> + * @link http://packagist.org/packages/sendgrid/sendgrid + */ + +namespace SendGrid\Tests; + + +/** + * This class tests the request object generation for a /mail/send API call + * + * @package SendGrid\Tests + */ +class SingleEmailToMulipleRecipientsTest extends BaseTestClass +{ + + private $REQUEST_OBJECT = <<<'JSON' +{ + "personalizations": [ + { + "to": [ + { + "email": "test+test1@example.com", + "name": "Example User1" + }, + { + "email": "test+test2@example.com", + "name": "Example User2" + }, + { + "email": "test+test3@example.com", + "name": "Example User3" + } + ] + } + ], + "subject": "Sending with Twilio SendGrid is Fun", + "content": [ + { + "type": "text/plain", + "value": "and easy to do anywhere, even with PHP" + }, + { + "type": "text/html", + "value": "<strong>and easy to do anywhere, even with PHP</strong>" + } + ], + "from": { + "email": "test@example.com", + "name": "Example User" + } +} +JSON; + + + /** + * Test when we are using objects + */ + public function testWithObjects() + { + $from = new \SendGrid\Mail\From("test@example.com", "Example User"); + $tos = [ + new \SendGrid\Mail\To("test+test1@example.com", "Example User1"), + new \SendGrid\Mail\To("test+test2@example.com", "Example User2"), + new \SendGrid\Mail\To("test+test3@example.com", "Example User3") + ]; + $subject = new \SendGrid\Mail\Subject("Sending with Twilio SendGrid is Fun"); + $plainTextContent = new \SendGrid\Mail\PlainTextContent( + "and easy to do anywhere, even with PHP" + ); + $htmlContent = new \SendGrid\Mail\HtmlContent( + "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $email = new \SendGrid\Mail\Mail( + $from, + $tos, + $subject, + $plainTextContent, + $htmlContent + ); + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT); + $this->assertTrue($isEqual); + } + + /** + * Test when we are not using objects + */ + public function testWithoutObjects() + { + $email = new \SendGrid\Mail\Mail(); + $email->setFrom("test@example.com", "Example User"); + $tos = [ + "test+test1@example.com" => "Example User1", + "test+test2@example.com" => "Example User2", + "test+test3@example.com" => "Example User3" + ]; + $email->addTos($tos); + $email->setSubject("Sending with Twilio SendGrid is Fun"); + $email->addContent("text/plain", "and easy to do anywhere, even with PHP"); + $email->addContent( + "text/html", "<strong>and easy to do anywhere, even with PHP</strong>" + ); + $json = json_encode($email->jsonSerialize()); + $isEqual = BaseTestClass::compareJSONObjects($json, $this->REQUEST_OBJECT); + $this->assertTrue($isEqual); + } +} diff --git a/Postman/PostmanEmailLogs.php b/Postman/PostmanEmailLogs.php new file mode 100644 index 0000000..c7b6175 --- /dev/null +++ b/Postman/PostmanEmailLogs.php @@ -0,0 +1,111 @@ +<?php + +class PostmanEmailLogs { + + private $db; + + public $db_name = 'post_smtp_logs'; + + private static $fields = array( + 'success', + 'from_header', + 'to_header', + 'cc_header', + 'bcc_header', + 'reply_to_header', + 'transport_uri', + 'original_to', + 'original_subject', + 'original_message', + 'original_headers', + 'session_transcript' + ); + + private static $instance; + + public static function get_instance() { + if ( ! self::$instance ) { + self::$instanc = new static(); + } + + return self::$instance; + } + + private function __construct() { + global $wpdb; + + $this->db = $wpdb; + } + + function install_table() { + + global $wpdb; + + $sql = "CREATE TABLE `{$wpdb->prefix}_{$this->db_name}` (
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
"; + + foreach ($this->fields as $field ) { + if ( $field == 'original_message' || $field == 'session_transcript' ) { + $sql .= "`" . $field . "` longtext DEFAULT NULL,"; + continue; + } + $sql .= "`" . $field . "` varchar(255) DEFAULT NULL,"; + } + $sql .= "PRIMARY KEY (`id`)) ENGINE=InnoDB CHARSET={$wpdb->charset} COLLATE={$wpdb->collate};
"; + + dbDelta( $sql ); + } + + public static function get_data( $post_id ) { + $fields = array(); + foreach ( self::$fields as $field ) { + $fields[$field][0] = get_post_meta( $post_id, $field, true ); + } + + return $fields; + } + + public static function get_fields() { + return self::$fields; + } + + function migrate_data() { + $args = array( + 'post_type' => 'postman_sent_mail', + 'posts_per_page' => -1, + ); + + $logs = new WP_Query($args); + + $failed_records = 0; + foreach ( $logs->posts as $log ) { + + foreach ($this->fields as $key ) { + $value = $this->get_meta( $log->ID, $key, true ); + + if ( $this->add_meta( $log->ID, $key, $value ) ) { + delete_post_meta( $log->ID, $key ); + } else { + $failed_records++; + } + } + } + } + + function load() { + $this->db->select(); + } + + /** + * @param array $data + */ + function save( $data ) { + $this->db->query( $this->db->prepare( + " + INSERT INTO $this->db_name + ( " . implode( ',', array_keys( $data ) ) . " ) + VALUES ( " . str_repeat( '%s', count( $data ) ) . " )", array_values( $data ) + ) ); + } + +}
\ No newline at end of file diff --git a/Postman/extra/donation.php b/Postman/extra/donation.php new file mode 100644 index 0000000..61fc3a9 --- /dev/null +++ b/Postman/extra/donation.php @@ -0,0 +1,19 @@ +<?php +$postman_dismiss_donation = get_option('postman_dismiss_donation'); + +if ( empty( $postman_dismiss_donation ) || isset( $in_wizard ) ) : ?> + <div class="updated settings-error notice is-dismissible post-smtp-donation"> + <p style="font-size: 1.1em;">It is hard to continue development and support for this free plugin without contributions from users like you.<br> + If you enjoy using <strong>Post SMTP</strong> and find it useful, please consider making a donation.<br> + Your donation will help encourage and support the plugin's continued development and better user support.</p> + <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> + <input type="hidden" name="cmd" value="_s-xclick" /> + <input type="hidden" name="hosted_button_id" value="4B3PJANHBA7MG" /> + <input type="image" src="https://www.paypalobjects.com/en_US/IL/i/btn/btn_donateCC_LG.gif" border="0" name="submit" title="PayPal - The safer, easier way to pay online!" alt="Donate with PayPal button" /> + <img alt="" border="0" src="https://www.paypal.com/en_IL/i/scr/pixel.gif" width="1" height="1" /> + </form> + <button style="z-index: 100;" data-security="<?php echo wp_create_nonce('postsmtp'); ?>" type="button" class="notice-dismiss donation-dismiss"> + <span class="screen-reader-text">Dismiss this notice.</span> + </button> + </div> +<?php endif; ?>
\ No newline at end of file diff --git a/style/images/mailer-type.gif b/style/images/mailer-type.gif Binary files differnew file mode 100644 index 0000000..903449b --- /dev/null +++ b/style/images/mailer-type.gif |