├── .github
└── PULL_REQUEST_TEMPLATE.md
├── .php_cs
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── composer.json
├── git_push.sh
├── lib
├── Api
│ ├── AllowlistsApi.php
│ ├── ExportsApi.php
│ ├── InboundApi.php
│ ├── IpsApi.php
│ ├── MessagesApi.php
│ ├── MetadataApi.php
│ ├── RejectsApi.php
│ ├── SendersApi.php
│ ├── SubaccountsApi.php
│ ├── TagsApi.php
│ ├── TemplatesApi.php
│ ├── UrlsApi.php
│ ├── UsersApi.php
│ ├── WebhooksApi.php
│ └── WhitelistsApi.php
├── ApiClient.php
├── ApiException.php
├── Configuration.php
├── HeaderSelector.php
└── ObjectSerializer.php
└── phpunit.xml.dist
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Note: This repository is auto-generated, and does not accept pull requests.
2 |
3 | To make changes or open issues for this SDK, use the [code generation repository](https://github.com/mailchimp/mailchimp-client-lib-codegen).
4 |
--------------------------------------------------------------------------------
/.php_cs:
--------------------------------------------------------------------------------
1 | setUsingCache(true)
5 | ->setRules([
6 | '@PSR2' => true,
7 | 'ordered_imports' => true,
8 | 'phpdoc_order' => true,
9 | 'array_syntax' => [ 'syntax' => 'short' ],
10 | 'strict_comparison' => true,
11 | 'strict_param' => true,
12 | 'no_trailing_whitespace' => false,
13 | 'no_trailing_whitespace_in_comment' => false,
14 | 'braces' => false,
15 | 'single_blank_line_at_eof' => false,
16 | 'blank_line_after_namespace' => false,
17 | ])
18 | ->setFinder(
19 | PhpCsFixer\Finder::create()
20 | ->exclude('test')
21 | ->exclude('tests')
22 | ->in(__DIR__)
23 | );
24 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 | sudo: false
3 | php:
4 | - 5.4
5 | - 5.5
6 | - 5.6
7 | - 7.0
8 | - hhvm
9 | before_install: "composer install"
10 | script: "vendor/bin/phpunit"
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## Transactional
4 |
5 | ### 1.0.56
6 | * Adding DMARC and DKIM2 fields to the API reference
7 |
8 | ### 1.0.55
9 | * Updating github actions bot user email
10 |
11 | ### 1.0.54
12 | * Fixing a problem with Github auth token that was preventing builds from being created.
13 |
14 | ### 1.0.53
15 | * Fixed broken ruby SDK test, updated PHP SDK to send form data via JSON
16 |
17 | ### 1.0.52
18 | * Added the `is_broken_template` response to the /template endpoints that include it
19 |
20 | ### 1.0.51
21 | * Fixed `/messages/send-template` documentation where incorrectly referenced the template name usage.
22 |
23 | ### 1.0.50
24 | * Added a response parameter to /messages/send and /messages/send-template called 'queued_response' that details why an email was queued.
25 |
26 | ### 1.0.48
27 | * Allowing users to schedule messages (using messages/send, messages/send-template, messages/send-raw and messages/reschedule APIs) within a year from the date of scheduling.
28 |
29 | ### 1.0.46
30 | * Added a little more granularity to the `set_timeout` method to the Client class in the Ruby SDK; now supports `read`, `write` and `connect` parameters, which will default to the `timeout` param if unspecified, or 300 seconds if `timeout` is unspecified.
31 |
32 | ### 1.0.45
33 | * Added a `set_timeout` method to the Client class in the Ruby SDK
34 |
35 | ### 1.0.44
36 | * Added a `set_timeout` method to the Client class in the Python SDK
37 |
38 | ### 1.0.43
39 | * Added a `setTimeout` method to the Configuration class in the PHP SDK.
40 |
41 | ### 1.0.42
42 | * Added a `setDefaultTimeoutMs` method to the node client. This allows users to override the default timeout for API requests, which is set to 5 minutes by default.
43 |
44 | ### 1.0.41
45 | * Updated the "reject_reasons" response for /messages/send and /messages/send-template to correctly use "hard-bounce" and "soft-bounce" instead of the previously stated "hard_bounce" and "soft_bounce".
46 |
47 | ### 1.0.40
48 | * Added the new /allowlists/ series of endpoints and the /exports/allowlist endpoint to the API reference
49 |
50 | ### 1.0.39
51 | * Fixes the output directory for the Changelog for the php client library
52 |
53 | ### 1.0.38
54 | * A change was made to `mailchimp-transactional-php` - the API client will now always return an `Exception`, instead of an `Exception` or a string, when the API returns an error. Having to parse the response as a string was found to be a bit clunky.
55 |
56 | ### 1.0.37
57 | * Added a changelog, which will be used to describe changes to both transactional and marketing client libraries.
58 |
59 | ## Marketing
60 |
61 | ### 3.0.72
62 | * Updated the `PATCH /automations/.../emails/.../` documentation to state the required `workflow_type`
63 |
64 | ### 3.0.70
65 | * Added more granularity for the `timeout` field in the Ruby Marketing SDK; now supports `read_timeout`, `write_timeout` and `connect_timeout` fields which will default to the `timeout` value.
66 |
67 | ### 3.0.69
68 | * Added handling for a `timeout` field in the config block passed to the client constructor in the Ruby Marketing SDK.
69 |
70 | ### 3.0.68
71 | * Added handling for a `'timeout'` field in `set_config()` in the Python Marketing SDK.
72 |
73 | ### 3.0.67
74 | * Added a `setTimeout()` method to the configuration class in the PHP Marketing SDK, to allow manually setting the timeout for Guzzle requests.
75 |
76 | ### 3.0.65
77 | * Added a new API endpoint, `/3.0/account-exports`, allowing users to programatically export their account information
78 |
79 | ### 3.0.64
80 | * Fixes the output directory for the Changelog for the php client library
81 |
82 | ### 3.0.63
83 | * Added a changelog, which will be used to describe changes to both transactional and marketing client libraries.
84 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Mailchimp Client Library License Agreement
2 |
3 | IMPORTANT- PLEASE READ CAREFULLY BEFORE OPENING, INSTALLING, COPYING OR USING THE CLIENT LIBRARY. This Client Library License Agreement (“Agreement”) is a legal document by and between you (hereinafter referred to as “You” “Your” or “Licensee”) and The Rocket Science Group LLC (“Mailchimp”) (each a “Party” and collectively, “Parties”) for the client library, including any upgrades, modified versions, updates, additions, and copies of the foregoing, including the software and related documentation (the “Mailchimp Client Library”).
4 |
5 | BY OPENING, INSTALLING, COPYING OR USING THE MAILCHIMP CLIENT LIBRARY OR ANY PORTION THEREOF, YOU AGREE TO ALL THE TERMS OF THIS AGREEMENT. IF YOU ARE AGREEING TO THIS AGREEMENT AS AN INDIVIDUAL, “YOU” “YOUR” AND “LICENSEE” REFERS TO YOU INDIVIDUALLY. IF YOU ARE AGREEING TO THIS AGREEMENT AS A REPRESENTATIVE OF A LEGAL ENTITY, YOU REPRESENT THAT YOU HAVE THE AUTHORITY TO BIND THAT ENTITY AND “YOU” “YOUR” AND “LICENSEE” REFERS TO THAT LEGAL ENTITY AND ALL THE USERS ACCESSING THE SOFTWARE BY, THROUGH OR ON BEHALF OF THAT LEGAL ENTITY. IF YOU DO NOT AGREE WITH ALL OF THE TERMS OF THIS AGREEMENT, DO NOT (AND ENSURE THAT YOUR END USERS DO NOT) OPEN, INSTALL, COPY OR USE THE MAILCHIMP CLIENT LIBRARY.
6 |
7 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8 | 1. Definitions.
9 | “License” shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 10 of these Terms and Conditions for Use, Reproduction and Distribution.
10 | “Legal Entity” shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, “control” means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
11 | “You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License.
12 | “Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
13 | “Object” form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
14 | “Work” shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
15 | “Derivative Works” shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
16 | “Contribution” shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Mailchimp for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, “submitted” means any form of electronic, verbal, or written communication sent to Mailchimp or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, Mailchimp for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as “Not a Contribution.”
17 | “Contributor” shall mean Mailchimp and any individual or Legal Entity on behalf of whom a Contribution has been received by Mailchimp and subsequently incorporated within the Work.
18 |
19 | 2. Grant of Copyright License. Subject to the terms and conditions of this Agreement, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
20 |
21 | 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
22 |
23 | 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
24 | a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
25 | b) You must cause any modified files to carry prominent notices stating that You changed the files; and
26 | c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
27 | d) If the Work includes a “NOTICE” text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
28 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
29 |
30 | 5. Submission of Contributions. Any Contribution submitted for inclusion in the Work by You to Mailchimp shall be made under the terms and conditions of the Individual Contributor License Agreement or the Software Grant and Corporate Contributor License Agreement, as applicable.
31 |
32 | 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of Mailchimp, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
33 |
34 | 7. Export controls. The Mailchimp Client Library is subject to united states export laws and regulations. You must comply with all domestic and international export laws and regulations that apply to the Mailchimp Client Library. These laws include restrictions on destinations, end-users and end use.
35 |
36 | 8. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
37 |
38 | 9. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
39 |
40 | 10. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
41 |
42 | Copyright 2020, The Rocket Science Group LLC
43 |
44 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
45 |
46 | You should include a copy of the License, typically in a file called LICENSE, in your work, and consider also including a NOTICE file.
47 |
48 | To apply the License to specific files in your work, attach the following boilerplate declaration, with the fields enclosed by brackets “[]” replaced with your own identifying information. (Don’t include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same “printed page” as the copyright notice for easier identification within third-party archives.
49 | Copyright [yyyy] [name of copyright owner]
50 |
51 | Licensed under the Mailchimp Client Library License Agreement (the “License”); you may not use this file except in compliance with the License. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either or express or implied.
52 | See the License for the specific language governing permissions and
53 | limitations under the License.
54 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | # Mailchimp Transactional — PHP
8 |
9 | The official PHP client library for the Mailchimp Transactional API (v1)
10 |
11 | ## Installation
12 |
13 | **Option 1:** Install via Packagist
14 | ```
15 | composer require mailchimp/transactional
16 | ```
17 |
18 | Or add the following to `composer.json`
19 | ```
20 | {
21 | "require": {
22 | "mailchimp/transactional": "*"
23 | }
24 | }
25 | ```
26 |
27 | Install all composer dependencies using:
28 | ```
29 | composer install
30 | ```
31 |
32 | **Option 2:** Install Manually
33 |
34 | Clone the repo
35 | ```
36 | git clone git@github.com:mailchimp/mailchimp-transactional-php.git
37 | ```
38 |
39 | In the project root, install all dependencies
40 | ```
41 | composer install
42 | ```
43 |
44 | Manually include `vendor/autoload.php` in your implementation
45 | ```php
46 | require_once('/path/to/MailchimpTransactional/vendor/autoload.php');
47 | ```
48 |
49 | ## Quick Start
50 |
51 | ### Note that this SDK requires PHP 7.2 or above.
52 |
53 | ```php
54 | require_once('/path/to/MailchimpTransactional/vendor/autoload.php');
55 |
56 | $mailchimp = new MailchimpTransactional\ApiClient();
57 | $mailchimp->setApiKey('YOUR_API_KEY');
58 |
59 | $response = $mailchimp->users->ping();
60 | print_r($response);
61 | ```
62 |
63 | ## Sending Requests
64 | All requests are sent via POST and accept a single argument as the request body parameter.
65 | ```php
66 | $mailchimp->templates->publish([ 'name' => 'My Template']);
67 | ```
68 |
69 | ## Output Formats
70 | Optionally, you can set the default response format for **all requests** to one of the following:
71 | - `json` *(default)*
72 | - `xml`
73 | - `php`
74 | - `yaml`
75 |
76 | ```php
77 | $mailchimp->setDefaultOutputFormat('xml');
78 | ```
79 |
80 | You can also set the response format for a **single request** by passing in a special `outputFormat` param to the request body.
81 | ```php
82 | $mailchimp->senders->list([ 'outputFormat' => 'php']);
83 | ```
84 |
85 | ## PRs and Issues
86 | This repo is autogenerated from https://github.com/mailchimp/mailchimp-client-lib-codegen -- please submit PRs or issues there!
87 |
88 | ## API Endpoints
89 |
90 | All URIs are relative to *https://mandrillapp.com/api/1.0*
91 |
92 | | Method | Endpoint |
93 | | ---------- | -------- |
94 | | **allowlists.add** | /allowlists/add |
95 | | **allowlists.delete** | /allowlists/delete |
96 | | **allowlists.list** | /allowlists/list |
97 | | **exports.activity** | /exports/activity |
98 | | **exports.allowlist** | /exports/allowlist |
99 | | **exports.info** | /exports/info |
100 | | **exports.list** | /exports/list |
101 | | **exports.rejects** | /exports/rejects |
102 | | **exports.whitelist** | /exports/whitelist |
103 | | **inbound.addDomain** | /inbound/add-domain |
104 | | **inbound.addRoute** | /inbound/add-route |
105 | | **inbound.checkDomain** | /inbound/check-domain |
106 | | **inbound.deleteDomain** | /inbound/delete-domain |
107 | | **inbound.deleteRoute** | /inbound/delete-route |
108 | | **inbound.domains** | /inbound/domains |
109 | | **inbound.routes** | /inbound/routes |
110 | | **inbound.sendRaw** | /inbound/send-raw |
111 | | **inbound.updateRoute** | /inbound/update-route |
112 | | **ips.cancelWarmup** | /ips/cancel-warmup |
113 | | **ips.checkCustomDns** | /ips/check-custom-dns |
114 | | **ips.createPool** | /ips/create-pool |
115 | | **ips.delete** | /ips/delete |
116 | | **ips.deletePool** | /ips/delete-pool |
117 | | **ips.info** | /ips/info |
118 | | **ips.list** | /ips/list |
119 | | **ips.listPools** | /ips/list-pools |
120 | | **ips.poolInfo** | /ips/pool-info |
121 | | **ips.provision** | /ips/provision |
122 | | **ips.setCustomDns** | /ips/set-custom-dns |
123 | | **ips.setPool** | /ips/set-pool |
124 | | **ips.startWarmup** | /ips/start-warmup |
125 | | **messages.cancelScheduled** | /messages/cancel-scheduled |
126 | | **messages.content** | /messages/content |
127 | | **messages.info** | /messages/info |
128 | | **messages.listScheduled** | /messages/list-scheduled |
129 | | **messages.parse** | /messages/parse |
130 | | **messages.reschedule** | /messages/reschedule |
131 | | **messages.search** | /messages/search |
132 | | **messages.searchTimeSeries** | /messages/search-time-series |
133 | | **messages.send** | /messages/send |
134 | | **messages.sendRaw** | /messages/send-raw |
135 | | **messages.sendTemplate** | /messages/send-template |
136 | | **metadata.add** | /metadata/add |
137 | | **metadata.delete** | /metadata/delete |
138 | | **metadata.list** | /metadata/list |
139 | | **metadata.update** | /metadata/update |
140 | | **rejects.add** | /rejects/add |
141 | | **rejects.delete** | /rejects/delete |
142 | | **rejects.list** | /rejects/list |
143 | | **senders.addDomain** | /senders/add-domain |
144 | | **senders.checkDomain** | /senders/check-domain |
145 | | **senders.domains** | /senders/domains |
146 | | **senders.info** | /senders/info |
147 | | **senders.list** | /senders/list |
148 | | **senders.timeSeries** | /senders/time-series |
149 | | **senders.verifyDomain** | /senders/verify-domain |
150 | | **subaccounts.add** | /subaccounts/add |
151 | | **subaccounts.delete** | /subaccounts/delete |
152 | | **subaccounts.info** | /subaccounts/info |
153 | | **subaccounts.list** | /subaccounts/list |
154 | | **subaccounts.pause** | /subaccounts/pause |
155 | | **subaccounts.resume** | /subaccounts/resume |
156 | | **subaccounts.update** | /subaccounts/update |
157 | | **tags.allTimeSeries** | /tags/all-time-series |
158 | | **tags.delete** | /tags/delete |
159 | | **tags.info** | /tags/info |
160 | | **tags.list** | /tags/list |
161 | | **tags.timeSeries** | /tags/time-series |
162 | | **templates.add** | /templates/add |
163 | | **templates.delete** | /templates/delete |
164 | | **templates.info** | /templates/info |
165 | | **templates.list** | /templates/list |
166 | | **templates.publish** | /templates/publish |
167 | | **templates.render** | /templates/render |
168 | | **templates.timeSeries** | /templates/time-series |
169 | | **templates.update** | /templates/update |
170 | | **urls.addTrackingDomain** | /urls/add-tracking-domain |
171 | | **urls.checkTrackingDomain** | /urls/check-tracking-domain |
172 | | **urls.list** | /urls/list |
173 | | **urls.search** | /urls/search |
174 | | **urls.timeSeries** | /urls/time-series |
175 | | **urls.trackingDomains** | /urls/tracking-domains |
176 | | **users.info** | /users/info |
177 | | **users.ping** | /users/ping |
178 | | **users.ping2** | /users/ping2 |
179 | | **users.senders** | /users/senders |
180 | | **webhooks.add** | /webhooks/add |
181 | | **webhooks.delete** | /webhooks/delete |
182 | | **webhooks.info** | /webhooks/info |
183 | | **webhooks.list** | /webhooks/list |
184 | | **webhooks.update** | /webhooks/update |
185 | | **whitelists.add** | /whitelists/add |
186 | | **whitelists.delete** | /whitelists/delete |
187 | | **whitelists.list** | /whitelists/list |
188 |
189 |
190 | ## Additional Libraries
191 |
192 | Mailchimp Transactional libraries are available in the following languages:
193 |
194 |
208 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mailchimp/transactional",
3 | "version": "1.0.59",
4 | "description": "",
5 | "keywords": [
6 | "swagger",
7 | "php",
8 | "sdk",
9 | "api"
10 | ],
11 | "homepage": "http://swagger.io",
12 | "license": "proprietary",
13 | "authors": [
14 | {
15 | "name": "Mailchimp",
16 | "homepage": "https://github.com/mailchimp/mailchimp-transactional-php"
17 | }
18 | ],
19 | "require": {
20 | "php": ">=7.2",
21 | "ext-curl": "*",
22 | "ext-json": "*",
23 | "ext-mbstring": "*",
24 | "guzzlehttp/guzzle": "^6.4 || ^7.2"
25 | },
26 | "require-dev": {
27 | "phpunit/phpunit": "^7",
28 | "squizlabs/php_codesniffer": "~2.6",
29 | "friendsofphp/php-cs-fixer": "~2.12"
30 | },
31 | "autoload": {
32 | "psr-4": {
33 | "MailchimpTransactional\\" : "lib/"
34 | }
35 | },
36 | "autoload-dev": {
37 | "psr-4": { "MailchimpTransactional\\" : "test/" }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/git_push.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3 | #
4 | # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
5 |
6 | git_user_id=$1
7 | git_repo_id=$2
8 | release_note=$3
9 |
10 | if [ "$git_user_id" = "" ]; then
11 | git_user_id="GIT_USER_ID"
12 | echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
13 | fi
14 |
15 | if [ "$git_repo_id" = "" ]; then
16 | git_repo_id="GIT_REPO_ID"
17 | echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
18 | fi
19 |
20 | if [ "$release_note" = "" ]; then
21 | release_note="Minor update"
22 | echo "[INFO] No command line input provided. Set \$release_note to $release_note"
23 | fi
24 |
25 | # Initialize the local directory as a Git repository
26 | git init
27 |
28 | # Adds the files in the local repository and stages them for commit.
29 | git add .
30 |
31 | # Commits the tracked changes and prepares them to be pushed to a remote repository.
32 | git commit -m "$release_note"
33 |
34 | # Sets the new remote
35 | git_remote=`git remote`
36 | if [ "$git_remote" = "" ]; then # git remote not defined
37 |
38 | if [ "$GIT_TOKEN" = "" ]; then
39 | echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
40 | git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
41 | else
42 | git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
43 | fi
44 |
45 | fi
46 |
47 | git pull origin master
48 |
49 | # Pushes (Forces) the changes in the local repository up to the remote repository
50 | echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
51 | git push origin master 2>&1 | grep -v 'To https'
52 |
53 |
--------------------------------------------------------------------------------
/lib/Api/AllowlistsApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Add email to allowlist
56 | * Adds an email to your email rejection allowlist. If the address is currently on your denylist, that denylist entry will be removed automatically.
57 | */
58 | public function add($body = [])
59 | {
60 | return $this->config->post('/allowlists/add', $body);
61 | }
62 | /**
63 | * Remove email from allowlist
64 | * Removes an email address from the allowlist.
65 | */
66 | public function delete($body = [])
67 | {
68 | return $this->config->post('/allowlists/delete', $body);
69 | }
70 | /**
71 | * List allowlisted emails
72 | * Retrieves your email rejection allowlist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results.
73 | */
74 | public function list($body = [])
75 | {
76 | return $this->config->post('/allowlists/list', $body);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/lib/Api/ExportsApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Export activity history
56 | * Begins an export of your activity history. The activity will be exported to a zip archive containing a single file named activity.csv in the same format as you would be able to export from your account's activity view. It includes the following fields: Date, Email Address, Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom metadata fields, they will be included in the exported data.
57 | */
58 | public function activity($body = [])
59 | {
60 | return $this->config->post('/exports/activity', $body);
61 | }
62 | /**
63 | * Export Allowlist
64 | * Begins an export of your rejection allowlist. The allowlist will be exported to a zip archive containing a single file named allowlist.csv that includes the following fields: email, detail, created_at.
65 | */
66 | public function allowlist($body = [])
67 | {
68 | return $this->config->post('/exports/allowlist', $body);
69 | }
70 | /**
71 | * View export info
72 | * Returns information about an export job. If the export job's state is 'complete', the returned data will include a URL you can use to fetch the results. Every export job produces a zip archive, but the format of the archive is distinct for each job type. The api calls that initiate exports include more details about the output format for that job type.
73 | */
74 | public function info($body = [])
75 | {
76 | return $this->config->post('/exports/info', $body);
77 | }
78 | /**
79 | * List exports
80 | * Returns a list of your exports.
81 | */
82 | public function list($body = [])
83 | {
84 | return $this->config->post('/exports/list', $body);
85 | }
86 | /**
87 | * Export denylist
88 | * Begins an export of your rejection denylist. The denylist will be exported to a zip archive containing a single file named rejects.csv that includes the following fields: email, reason, detail, created_at, expires_at, last_event_at, expires_at.
89 | */
90 | public function rejects($body = [])
91 | {
92 | return $this->config->post('/exports/rejects', $body);
93 | }
94 | /**
95 | * Export Allowlist
96 | * Begins an export of your rejection allowlist. The allowlist will be exported to a zip archive containing a single file named allowlist.csv that includes the following fields: email, detail, created_at.
97 | */
98 | public function whitelist($body = [])
99 | {
100 | return $this->config->post('/exports/whitelist', $body);
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/lib/Api/InboundApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Add inbound domain
56 | * Add an inbound domain to your account.
57 | */
58 | public function addDomain($body = [])
59 | {
60 | return $this->config->post('/inbound/add-domain', $body);
61 | }
62 | /**
63 | * Add mailbox route
64 | * Add a new mailbox route to an inbound domain.
65 | */
66 | public function addRoute($body = [])
67 | {
68 | return $this->config->post('/inbound/add-route', $body);
69 | }
70 | /**
71 | * Check domain settings
72 | * Check the MX settings for an inbound domain. The domain must have already been added with the add-domain call.
73 | */
74 | public function checkDomain($body = [])
75 | {
76 | return $this->config->post('/inbound/check-domain', $body);
77 | }
78 | /**
79 | * Delete inbound domain
80 | * Delete an inbound domain from the account. All mail will stop routing for this domain immediately.
81 | */
82 | public function deleteDomain($body = [])
83 | {
84 | return $this->config->post('/inbound/delete-domain', $body);
85 | }
86 | /**
87 | * Delete mailbox route
88 | * Delete an existing inbound mailbox route.
89 | */
90 | public function deleteRoute($body = [])
91 | {
92 | return $this->config->post('/inbound/delete-route', $body);
93 | }
94 | /**
95 | * List inbound domains
96 | * List the domains that have been configured for inbound delivery.
97 | */
98 | public function domains($body = [])
99 | {
100 | return $this->config->post('/inbound/domains', $body);
101 | }
102 | /**
103 | * List mailbox routes
104 | * List the mailbox routes defined for an inbound domain.
105 | */
106 | public function routes($body = [])
107 | {
108 | return $this->config->post('/inbound/routes', $body);
109 | }
110 | /**
111 | * Send mime document
112 | * Take a raw MIME document destined for a domain with inbound domains set up, and send it to the inbound hook exactly as if it had been sent over SMTP.
113 | */
114 | public function sendRaw($body = [])
115 | {
116 | return $this->config->post('/inbound/send-raw', $body);
117 | }
118 | /**
119 | * Update mailbox route
120 | * Update the pattern or webhook of an existing inbound mailbox route. If null is provided for any fields, the values will remain unchanged.
121 | */
122 | public function updateRoute($body = [])
123 | {
124 | return $this->config->post('/inbound/update-route', $body);
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/lib/Api/IpsApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Cancel ip warmup
56 | * Cancels the warmup process for a dedicated IP.
57 | */
58 | public function cancelWarmup($body = [])
59 | {
60 | return $this->config->post('/ips/cancel-warmup', $body);
61 | }
62 | /**
63 | * Test custom dns
64 | * Tests whether a domain name is valid for use as the custom reverse DNS for a dedicated IP.
65 | */
66 | public function checkCustomDns($body = [])
67 | {
68 | return $this->config->post('/ips/check-custom-dns', $body);
69 | }
70 | /**
71 | * Add ip pool
72 | * Creates a pool and returns it. If a pool already exists with this name, no action will be performed.
73 | */
74 | public function createPool($body = [])
75 | {
76 | return $this->config->post('/ips/create-pool', $body);
77 | }
78 | /**
79 | * Delete ip address
80 | * Deletes a dedicated IP. This is permanent and cannot be undone.
81 | */
82 | public function delete($body = [])
83 | {
84 | return $this->config->post('/ips/delete', $body);
85 | }
86 | /**
87 | * Delete ip pool
88 | * Deletes a pool. A pool must be empty before you can delete it, and you cannot delete your default pool.
89 | */
90 | public function deletePool($body = [])
91 | {
92 | return $this->config->post('/ips/delete-pool', $body);
93 | }
94 | /**
95 | * Get ip info
96 | * Retrieves information about a single dedicated IP.
97 | */
98 | public function info($body = [])
99 | {
100 | return $this->config->post('/ips/info', $body);
101 | }
102 | /**
103 | * List ip addresses
104 | * Lists your dedicated IPs.
105 | */
106 | public function list($body = [])
107 | {
108 | return $this->config->post('/ips/list', $body);
109 | }
110 | /**
111 | * List ip pools
112 | * Lists your dedicated IP pools.
113 | */
114 | public function listPools($body = [])
115 | {
116 | return $this->config->post('/ips/list-pools', $body);
117 | }
118 | /**
119 | * Get ip pool info
120 | * Describes a single dedicated IP pool.
121 | */
122 | public function poolInfo($body = [])
123 | {
124 | return $this->config->post('/ips/pool-info', $body);
125 | }
126 | /**
127 | * Request additional ip
128 | * Requests an additional dedicated IP for your account. Accounts may have one outstanding request at any time, and provisioning requests are processed within 24 hours.
129 | */
130 | public function provision($body = [])
131 | {
132 | return $this->config->post('/ips/provision', $body);
133 | }
134 | /**
135 | * Set custom dns
136 | * Configures the custom DNS name for a dedicated IP.
137 | */
138 | public function setCustomDns($body = [])
139 | {
140 | return $this->config->post('/ips/set-custom-dns', $body);
141 | }
142 | /**
143 | * Move ip to different pool
144 | * Moves a dedicated IP to a different pool.
145 | */
146 | public function setPool($body = [])
147 | {
148 | return $this->config->post('/ips/set-pool', $body);
149 | }
150 | /**
151 | * Start ip warmup
152 | * Begins the warmup process for a dedicated IP. During the warmup process, the Transactional API will gradually increase the percentage of your mail that is sent over the warming-up IP, over a period of roughly 30 days. The rest of your mail will be sent over shared IPs or other dedicated IPs in the same pool.
153 | */
154 | public function startWarmup($body = [])
155 | {
156 | return $this->config->post('/ips/start-warmup', $body);
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/lib/Api/MessagesApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Cancel scheduled email
56 | * Cancels a scheduled email.
57 | */
58 | public function cancelScheduled($body = [])
59 | {
60 | return $this->config->post('/messages/cancel-scheduled', $body);
61 | }
62 | /**
63 | * Get message content
64 | * Get the full content of a recently sent message.
65 | */
66 | public function content($body = [])
67 | {
68 | return $this->config->post('/messages/content', $body);
69 | }
70 | /**
71 | * Get message info
72 | * Get the information for a single recently sent message.
73 | */
74 | public function info($body = [])
75 | {
76 | return $this->config->post('/messages/info', $body);
77 | }
78 | /**
79 | * List scheduled emails
80 | * Queries your scheduled emails.
81 | */
82 | public function listScheduled($body = [])
83 | {
84 | return $this->config->post('/messages/list-scheduled', $body);
85 | }
86 | /**
87 | * Parse mime document
88 | * Parse the full MIME document for an email message, returning the content of the message broken into its constituent pieces.
89 | */
90 | public function parse($body = [])
91 | {
92 | return $this->config->post('/messages/parse', $body);
93 | }
94 | /**
95 | * Reschedule email
96 | * Reschedules a scheduled email.
97 | */
98 | public function reschedule($body = [])
99 | {
100 | return $this->config->post('/messages/reschedule', $body);
101 | }
102 | /**
103 | * Search messages by date
104 | * Search recently sent messages and optionally narrow by date range, tags, senders, and API keys. If no date range is specified, results within the last 7 days are returned. This method may be called up to 20 times per minute. If you need the data more often, you can use /messages/info.json to get the information for a single message, or webhooks to push activity to your own application for querying.
105 | */
106 | public function search($body = [])
107 | {
108 | return $this->config->post('/messages/search', $body);
109 | }
110 | /**
111 | * Search messages by hour
112 | * Search the content of recently sent messages and return the aggregated hourly stats for matching messages.
113 | */
114 | public function searchTimeSeries($body = [])
115 | {
116 | return $this->config->post('/messages/search-time-series', $body);
117 | }
118 | /**
119 | * Send new message
120 | * Send a new transactional message through the Transactional API.
121 | */
122 | public function send($body = [])
123 | {
124 | return $this->config->post('/messages/send', $body);
125 | }
126 | /**
127 | * Send mime document
128 | * Take a raw MIME document for a message, and send it exactly as if it were sent through the Transactional API's SMTP servers.
129 | */
130 | public function sendRaw($body = [])
131 | {
132 | return $this->config->post('/messages/send-raw', $body);
133 | }
134 | /**
135 | * Send using message template
136 | * Send a new transactional message through the Transactional API using a template.
137 | */
138 | public function sendTemplate($body = [])
139 | {
140 | return $this->config->post('/messages/send-template', $body);
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/lib/Api/MetadataApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Add metadata field
56 | * Add a new custom metadata field to be indexed for the account.
57 | */
58 | public function add($body = [])
59 | {
60 | return $this->config->post('/metadata/add', $body);
61 | }
62 | /**
63 | * Delete metadata field
64 | * Delete an existing custom metadata field. Deletion isn't instataneous, and /metadata/list will continue to return the field until the asynchronous deletion process is complete.
65 | */
66 | public function delete($body = [])
67 | {
68 | return $this->config->post('/metadata/delete', $body);
69 | }
70 | /**
71 | * List metadata fields
72 | * Get the list of custom metadata fields indexed for the account.
73 | */
74 | public function list($body = [])
75 | {
76 | return $this->config->post('/metadata/list', $body);
77 | }
78 | /**
79 | * Update metadata field
80 | * Update an existing custom metadata field.
81 | */
82 | public function update($body = [])
83 | {
84 | return $this->config->post('/metadata/update', $body);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/lib/Api/RejectsApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Add email to denylist
56 | * Adds an email to your email rejection denylist. Addresses that you add manually will never expire and there is no reputation penalty for removing them from your denylist. Attempting to denylist an address that has been added to the allowlist will have no effect.
57 | */
58 | public function add($body = [])
59 | {
60 | return $this->config->post('/rejects/add', $body);
61 | }
62 | /**
63 | * Delete email from denylist
64 | * Deletes an email rejection. There is no limit to how many rejections you can remove from your denylist, but keep in mind that each deletion has an affect on your reputation.
65 | */
66 | public function delete($body = [])
67 | {
68 | return $this->config->post('/rejects/delete', $body);
69 | }
70 | /**
71 | * List denylisted emails
72 | * Retrieves your email rejection denylist. You can provide an email address to limit the results. Returns up to 1000 results. By default, entries that have expired are excluded from the results; set include_expired to true to include them.
73 | */
74 | public function list($body = [])
75 | {
76 | return $this->config->post('/rejects/list', $body);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/lib/Api/SendersApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Add sender domain
56 | * Adds a sender domain to your account. Sender domains are added automatically as you send, but you can use this call to add them ahead of time.
57 | */
58 | public function addDomain($body = [])
59 | {
60 | return $this->config->post('/senders/add-domain', $body);
61 | }
62 | /**
63 | * Check domain settings
64 | * Checks the SPF and DKIM settings for a domain, as well the domain verification. If you haven't already added this domain to your account, it will be added automatically.
65 | */
66 | public function checkDomain($body = [])
67 | {
68 | return $this->config->post('/senders/check-domain', $body);
69 | }
70 | /**
71 | * List sender domains
72 | * Returns the sender domains that have been added to this account.
73 | */
74 | public function domains($body = [])
75 | {
76 | return $this->config->post('/senders/domains', $body);
77 | }
78 | /**
79 | * Get sender info
80 | * Return more detailed information about a single sender, including aggregates of recent stats.
81 | */
82 | public function info($body = [])
83 | {
84 | return $this->config->post('/senders/info', $body);
85 | }
86 | /**
87 | * List account senders
88 | * Return the senders that have tried to use this account.
89 | */
90 | public function list($body = [])
91 | {
92 | return $this->config->post('/senders/list', $body);
93 | }
94 | /**
95 | * View sender history
96 | * Return the recent history (hourly stats for the last 30 days) for a sender.
97 | */
98 | public function timeSeries($body = [])
99 | {
100 | return $this->config->post('/senders/time-series', $body);
101 | }
102 | /**
103 | * Verify domain
104 | * Sends a verification email in order to verify ownership of a domain. Domain verification is a required step to confirm ownership of a domain. Once a domain has been verified in a Transactional API account, other accounts may not have their messages signed by that domain unless they also verify the domain. This prevents other Transactional API accounts from sending mail signed by your domain.
105 | */
106 | public function verifyDomain($body = [])
107 | {
108 | return $this->config->post('/senders/verify-domain', $body);
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/lib/Api/SubaccountsApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Add subaccount
56 | * Add a new subaccount.
57 | */
58 | public function add($body = [])
59 | {
60 | return $this->config->post('/subaccounts/add', $body);
61 | }
62 | /**
63 | * Delete subaccount
64 | * Delete an existing subaccount. Any email related to the subaccount will be saved, but stats will be removed and any future sending calls to this subaccount will fail.
65 | */
66 | public function delete($body = [])
67 | {
68 | return $this->config->post('/subaccounts/delete', $body);
69 | }
70 | /**
71 | * Get subaccount info
72 | * Given the ID of an existing subaccount, return the data about it.
73 | */
74 | public function info($body = [])
75 | {
76 | return $this->config->post('/subaccounts/info', $body);
77 | }
78 | /**
79 | * List subaccounts
80 | * Get the list of subaccounts defined for the account, optionally filtered by a prefix.
81 | */
82 | public function list($body = [])
83 | {
84 | return $this->config->post('/subaccounts/list', $body);
85 | }
86 | /**
87 | * Pause subaccount
88 | * Pause a subaccount's sending. Any future emails delivered to this subaccount will be queued for a maximum of 3 days until the subaccount is resumed.
89 | */
90 | public function pause($body = [])
91 | {
92 | return $this->config->post('/subaccounts/pause', $body);
93 | }
94 | /**
95 | * Resume subaccount
96 | * Resume a paused subaccount's sending.
97 | */
98 | public function resume($body = [])
99 | {
100 | return $this->config->post('/subaccounts/resume', $body);
101 | }
102 | /**
103 | * Update subaccount
104 | * Update an existing subaccount.
105 | */
106 | public function update($body = [])
107 | {
108 | return $this->config->post('/subaccounts/update', $body);
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/lib/Api/TagsApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * View all tags history
56 | * Return the recent history (hourly stats for the last 30 days) for all tags.
57 | */
58 | public function allTimeSeries($body = [])
59 | {
60 | return $this->config->post('/tags/all-time-series', $body);
61 | }
62 | /**
63 | * Delete tag
64 | * Deletes a tag permanently. Deleting a tag removes the tag from any messages that have been sent, and also deletes the tag's stats. There is no way to undo this operation, so use it carefully.
65 | */
66 | public function delete($body = [])
67 | {
68 | return $this->config->post('/tags/delete', $body);
69 | }
70 | /**
71 | * Get tag info
72 | * Return more detailed information about a single tag, including aggregates of recent stats.
73 | */
74 | public function info($body = [])
75 | {
76 | return $this->config->post('/tags/info', $body);
77 | }
78 | /**
79 | * List tags
80 | * Return all of the user-defined tag information.
81 | */
82 | public function list($body = [])
83 | {
84 | return $this->config->post('/tags/list', $body);
85 | }
86 | /**
87 | * View tag history
88 | * Return the recent history (hourly stats for the last 30 days) for a tag.
89 | */
90 | public function timeSeries($body = [])
91 | {
92 | return $this->config->post('/tags/time-series', $body);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/lib/Api/TemplatesApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Add template
56 | * Add a new template.
57 | */
58 | public function add($body = [])
59 | {
60 | return $this->config->post('/templates/add', $body);
61 | }
62 | /**
63 | * Delete template
64 | * Delete a template.
65 | */
66 | public function delete($body = [])
67 | {
68 | return $this->config->post('/templates/delete', $body);
69 | }
70 | /**
71 | * Get template info
72 | * Get the information for an existing template.
73 | */
74 | public function info($body = [])
75 | {
76 | return $this->config->post('/templates/info', $body);
77 | }
78 | /**
79 | * List templates
80 | * Return a list of all the templates available to this user.
81 | */
82 | public function list($body = [])
83 | {
84 | return $this->config->post('/templates/list', $body);
85 | }
86 | /**
87 | * Publish template content
88 | * Publish the content for the template. Any new messages sent using this template will start using the content that was previously in draft.
89 | */
90 | public function publish($body = [])
91 | {
92 | return $this->config->post('/templates/publish', $body);
93 | }
94 | /**
95 | * Render html template
96 | * Inject content and optionally merge fields into a template, returning the HTML that results.
97 | */
98 | public function render($body = [])
99 | {
100 | return $this->config->post('/templates/render', $body);
101 | }
102 | /**
103 | * Get template history
104 | * Return the recent history (hourly stats for the last 30 days) for a template.
105 | */
106 | public function timeSeries($body = [])
107 | {
108 | return $this->config->post('/templates/time-series', $body);
109 | }
110 | /**
111 | * Update template
112 | * Update the code for an existing template. If null is provided for any fields, the values will remain unchanged.
113 | */
114 | public function update($body = [])
115 | {
116 | return $this->config->post('/templates/update', $body);
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/lib/Api/UrlsApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Add tracking domains
56 | * Add a tracking domain to your account.
57 | */
58 | public function addTrackingDomain($body = [])
59 | {
60 | return $this->config->post('/urls/add-tracking-domain', $body);
61 | }
62 | /**
63 | * Check cname settings
64 | * Checks the CNAME settings for a tracking domain. The domain must have been added already with the add-tracking-domain call.
65 | */
66 | public function checkTrackingDomain($body = [])
67 | {
68 | return $this->config->post('/urls/check-tracking-domain', $body);
69 | }
70 | /**
71 | * List most clicked urls
72 | * Get the 100 most clicked URLs.
73 | */
74 | public function list($body = [])
75 | {
76 | return $this->config->post('/urls/list', $body);
77 | }
78 | /**
79 | * Search most clicked urls
80 | * Return the 100 most clicked URLs that match the search query given.
81 | */
82 | public function search($body = [])
83 | {
84 | return $this->config->post('/urls/search', $body);
85 | }
86 | /**
87 | * Get url history
88 | * Return the recent history (hourly stats for the last 30 days) for a URL
89 | */
90 | public function timeSeries($body = [])
91 | {
92 | return $this->config->post('/urls/time-series', $body);
93 | }
94 | /**
95 | * List tracking domains
96 | * Get the list of tracking domains set up for this account.
97 | */
98 | public function trackingDomains($body = [])
99 | {
100 | return $this->config->post('/urls/tracking-domains', $body);
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/lib/Api/UsersApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Get user info
56 | * Return the information about the API-connected user.
57 | */
58 | public function info($body = [])
59 | {
60 | return $this->config->post('/users/info', $body);
61 | }
62 | /**
63 | * Ping
64 | * Validate an API key and respond to a ping.
65 | */
66 | public function ping($body = [])
67 | {
68 | return $this->config->post('/users/ping', $body);
69 | }
70 | /**
71 | * Ping 2
72 | * Validate an API key and respond to a ping (JSON parser version).
73 | */
74 | public function ping2($body = [])
75 | {
76 | return $this->config->post('/users/ping2', $body);
77 | }
78 | /**
79 | * List account senders
80 | * Return the senders that have tried to use this account, both verified and unverified.
81 | */
82 | public function senders($body = [])
83 | {
84 | return $this->config->post('/users/senders', $body);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/lib/Api/WebhooksApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Add webhook
56 | * Add a new webhook.
57 | */
58 | public function add($body = [])
59 | {
60 | return $this->config->post('/webhooks/add', $body);
61 | }
62 | /**
63 | * Delete webhook
64 | * Delete an existing webhook.
65 | */
66 | public function delete($body = [])
67 | {
68 | return $this->config->post('/webhooks/delete', $body);
69 | }
70 | /**
71 | * Get webhook info
72 | * Given the ID of an existing webhook, return the data about it.
73 | */
74 | public function info($body = [])
75 | {
76 | return $this->config->post('/webhooks/info', $body);
77 | }
78 | /**
79 | * List webhooks
80 | * Get the list of all webhooks defined on the account.
81 | */
82 | public function list($body = [])
83 | {
84 | return $this->config->post('/webhooks/list', $body);
85 | }
86 | /**
87 | * Update webhook
88 | * Update an existing webhook.
89 | */
90 | public function update($body = [])
91 | {
92 | return $this->config->post('/webhooks/update', $body);
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/lib/Api/WhitelistsApi.php:
--------------------------------------------------------------------------------
1 | config = $config ?: new Configuration();
52 | }
53 |
54 | /**
55 | * Add email to allowlist
56 | * Adds an email to your email rejection allowlist. If the address is currently on your denylist, that denylist entry will be removed automatically.
57 | */
58 | public function add($body = [])
59 | {
60 | return $this->config->post('/whitelists/add', $body);
61 | }
62 | /**
63 | * Remove email from allowlist
64 | * Removes an email address from the allowlist.
65 | */
66 | public function delete($body = [])
67 | {
68 | return $this->config->post('/whitelists/delete', $body);
69 | }
70 | /**
71 | * List allowlisted emails
72 | * Retrieves your email rejection allowlist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results.
73 | */
74 | public function list($body = [])
75 | {
76 | return $this->config->post('/whitelists/list', $body);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/lib/ApiClient.php:
--------------------------------------------------------------------------------
1 | responseHeaders = $responseHeaders;
77 | $this->responseBody = $responseBody;
78 | }
79 |
80 | /**
81 | * Gets the HTTP response header
82 | *
83 | * @return string[]|null HTTP response header
84 | */
85 | public function getResponseHeaders()
86 | {
87 | return $this->responseHeaders;
88 | }
89 |
90 | /**
91 | * Gets the HTTP body of the server response either as Json or string
92 | *
93 | * @return mixed HTTP body of the server response either as \stdClass or string
94 | */
95 | public function getResponseBody()
96 | {
97 | return $this->responseBody;
98 | }
99 |
100 | /**
101 | * Sets the deseralized response object (during deserialization)
102 | *
103 | * @param mixed $obj Deserialized response object
104 | *
105 | * @return void
106 | */
107 | public function setResponseObject($obj)
108 | {
109 | $this->responseObject = $obj;
110 | }
111 |
112 | /**
113 | * Gets the deseralized response object (during deserialization)
114 | *
115 | * @return mixed the deserialized response object
116 | */
117 | public function getResponseObject()
118 | {
119 | return $this->responseObject;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/lib/Configuration.php:
--------------------------------------------------------------------------------
1 | requestClient = new RequestClient([
71 | 'defaults' => [
72 | 'timeout' => $this->timeout
73 | ]
74 | ]);
75 |
76 | // API Routes
77 | $this->allowlists = new AllowlistsApi($this);
78 | $this->exports = new ExportsApi($this);
79 | $this->inbound = new InboundApi($this);
80 | $this->ips = new IpsApi($this);
81 | $this->messages = new MessagesApi($this);
82 | $this->metadata = new MetadataApi($this);
83 | $this->rejects = new RejectsApi($this);
84 | $this->senders = new SendersApi($this);
85 | $this->subaccounts = new SubaccountsApi($this);
86 | $this->tags = new TagsApi($this);
87 | $this->templates = new TemplatesApi($this);
88 | $this->urls = new UrlsApi($this);
89 | $this->users = new UsersApi($this);
90 | $this->webhooks = new WebhooksApi($this);
91 | $this->whitelists = new WhitelistsApi($this);
92 | }
93 |
94 | public function setApiKey($apiKey = '')
95 | {
96 | $this->apiKey = $apiKey;
97 | return $this;
98 | }
99 |
100 | public function getApiKey()
101 | {
102 | return $this->apiKey;
103 | }
104 |
105 | public function getRequestClient()
106 | {
107 | return $this->requestClient;
108 | }
109 |
110 | public function getHost()
111 | {
112 | return $this->host;
113 | }
114 |
115 | public function setDefaultOutputFormat($outputFormat = '')
116 | {
117 | $this->defaultOutputFormat = $outputFormat;
118 | return $this;
119 | }
120 |
121 | public function getDefaultOutputFormat()
122 | {
123 | return $this->defaultOutputFormat;
124 | }
125 |
126 | public function setTimeout($timeout) {
127 | $this->timeout = $timeout;
128 | }
129 |
130 | public function getTimeout() {
131 | return $this->timeout;
132 | }
133 |
134 | public function getRequestOptions() {
135 | return [
136 | 'timeout' => $this->getTimeout()
137 | ];
138 | }
139 |
140 | // HTTP POST request helper
141 | public function post($path, $body)
142 | {
143 | // Apply API key as body param
144 | $body['key'] = $this->getApiKey();
145 |
146 | $options = $this->getRequestOptions();
147 |
148 | // prepare request params
149 | $postUrl = $this->getHost() . $path;
150 | $options['json'] = $body;
151 |
152 | // set output format
153 | $defaultOutputFormat = $this->getDefaultOutputFormat();
154 | $useDefaultOutputFormat = true;
155 |
156 | if (array_key_exists('outputFormat', $body)) {
157 | $selectedFormat = strtolower($body['outputFormat']);
158 |
159 | if (in_array($selectedFormat, Configuration::$formatList)) {
160 | $postUrl = $postUrl . '.' . $selectedFormat;
161 | unset($body['outputFormat']);
162 | $useDefaultOutputFormat = false;
163 | }
164 | }
165 |
166 | if ($useDefaultOutputFormat && in_array($defaultOutputFormat, Configuration::$formatList)) {
167 | $postUrl = $postUrl . '.' . $defaultOutputFormat;
168 | }
169 |
170 | // send request
171 | try {
172 | $client = $this->getRequestClient();
173 | $response = $client->request('POST', $postUrl, $options);
174 | $resp = $response->getBody();
175 | $contentType = $response->getHeaderLine('content-type');
176 |
177 | if (strpos($contentType, 'application/json') !== false) {
178 | return json_decode($resp);
179 | }
180 |
181 | return $resp;
182 | } catch (RequestException $e) {
183 | return $e;
184 | }
185 | }
186 | }
187 |
--------------------------------------------------------------------------------
/lib/HeaderSelector.php:
--------------------------------------------------------------------------------
1 | selectAcceptHeader($accept);
54 | if ($accept !== null) {
55 | $headers['Accept'] = $accept;
56 | }
57 |
58 | $headers['Content-Type'] = $this->selectContentTypeHeader($contentTypes);
59 | return $headers;
60 | }
61 |
62 | /**
63 | * @param string[] $accept
64 | * @return array
65 | */
66 | public function selectHeadersForMultipart($accept)
67 | {
68 | $headers = $this->selectHeaders($accept, []);
69 |
70 | unset($headers['Content-Type']);
71 | return $headers;
72 | }
73 |
74 | /**
75 | * Return the header 'Accept' based on an array of Accept provided
76 | *
77 | * @param string[] $accept Array of header
78 | *
79 | * @return string Accept (e.g. application/json)
80 | */
81 | private function selectAcceptHeader($accept)
82 | {
83 | if (count($accept) === 0 || (count($accept) === 1 && $accept[0] === '')) {
84 | return null;
85 | } elseif (preg_grep("/application\/json/i", $accept)) {
86 | return 'application/json';
87 | } else {
88 | return implode(',', $accept);
89 | }
90 | }
91 |
92 | /**
93 | * Return the content type based on an array of content-type provided
94 | *
95 | * @param string[] $contentType Array fo content-type
96 | *
97 | * @return string Content-Type (e.g. application/json)
98 | */
99 | private function selectContentTypeHeader($contentType)
100 | {
101 | if (count($contentType) === 0 || (count($contentType) === 1 && $contentType[0] === '')) {
102 | return 'application/json';
103 | } elseif (preg_grep("/application\/json/i", $contentType)) {
104 | return 'application/json';
105 | } else {
106 | return implode(',', $contentType);
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/lib/ObjectSerializer.php:
--------------------------------------------------------------------------------
1 | format('Y-m-d') : $data->format(\DateTime::ATOM);
57 | } elseif (is_array($data)) {
58 | foreach ($data as $property => $value) {
59 | $data[$property] = self::sanitizeForSerialization($value);
60 | }
61 | return $data;
62 | } elseif ($data instanceof \stdClass) {
63 | foreach ($data as $property => $value) {
64 | $data->$property = self::sanitizeForSerialization($value);
65 | }
66 | return $data;
67 | } elseif (is_object($data)) {
68 | $values = [];
69 | $formats = $data::swaggerFormats();
70 | foreach ($data::swaggerTypes() as $property => $swaggerType) {
71 | $getter = $data::getters()[$property];
72 | $value = $data->$getter();
73 | if ($value !== null
74 | && !in_array($swaggerType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)
75 | && method_exists($swaggerType, 'getAllowableEnumValues')
76 | && !in_array($value, $swaggerType::getAllowableEnumValues(), true)) {
77 | $imploded = implode("', '", $swaggerType::getAllowableEnumValues());
78 | throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'");
79 | }
80 | if ($value !== null) {
81 | $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $swaggerType, $formats[$property]);
82 | }
83 | }
84 | return (object)$values;
85 | } else {
86 | return (string)$data;
87 | }
88 | }
89 |
90 | /**
91 | * Sanitize filename by removing path.
92 | * e.g. ../../sun.gif becomes sun.gif
93 | *
94 | * @param string $filename filename to be sanitized
95 | *
96 | * @return string the sanitized filename
97 | */
98 | public static function sanitizeFilename($filename)
99 | {
100 | if (preg_match("/.*[\/\\\\](.*)$/", $filename, $match)) {
101 | return $match[1];
102 | } else {
103 | return $filename;
104 | }
105 | }
106 |
107 | /**
108 | * Take value and turn it into a string suitable for inclusion in
109 | * the path, by url-encoding.
110 | *
111 | * @param string $value a string which will be part of the path
112 | *
113 | * @return string the serialized object
114 | */
115 | public static function toPathValue($value)
116 | {
117 | return rawurlencode(self::toString($value));
118 | }
119 |
120 | /**
121 | * Take value and turn it into a string suitable for inclusion in
122 | * the query, by imploding comma-separated if it's an object.
123 | * If it's a string, pass through unchanged. It will be url-encoded
124 | * later.
125 | *
126 | * @param string[]|string|\DateTime $object an object to be serialized to a string
127 | *
128 | * @return string the serialized object
129 | */
130 | public static function toQueryValue($object)
131 | {
132 | if (is_array($object)) {
133 | return implode(',', $object);
134 | } else {
135 | return self::toString($object);
136 | }
137 | }
138 |
139 | /**
140 | * Take value and turn it into a string suitable for inclusion in
141 | * the header. If it's a string, pass through unchanged
142 | * If it's a datetime object, format it in ISO8601
143 | *
144 | * @param string $value a string which will be part of the header
145 | *
146 | * @return string the header string
147 | */
148 | public static function toHeaderValue($value)
149 | {
150 | return self::toString($value);
151 | }
152 |
153 | /**
154 | * Take value and turn it into a string suitable for inclusion in
155 | * the http body (form parameter). If it's a string, pass through unchanged
156 | * If it's a datetime object, format it in ISO8601
157 | *
158 | * @param string|\SplFileObject $value the value of the form parameter
159 | *
160 | * @return string the form string
161 | */
162 | public static function toFormValue($value)
163 | {
164 | if ($value instanceof \SplFileObject) {
165 | return $value->getRealPath();
166 | } else {
167 | return self::toString($value);
168 | }
169 | }
170 |
171 | /**
172 | * Take value and turn it into a string suitable for inclusion in
173 | * the parameter. If it's a string, pass through unchanged
174 | * If it's a datetime object, format it in ISO8601
175 | *
176 | * @param string|\DateTime $value the value of the parameter
177 | *
178 | * @return string the header string
179 | */
180 | public static function toString($value)
181 | {
182 | if ($value instanceof \DateTime) { // datetime in ISO8601 format
183 | return $value->format(\DateTime::ATOM);
184 | } else {
185 | return $value;
186 | }
187 | }
188 |
189 | /**
190 | * Serialize an array to a string.
191 | *
192 | * @param array $collection collection to serialize to a string
193 | * @param string $collectionFormat the format use for serialization (csv,
194 | * ssv, tsv, pipes, multi)
195 | * @param bool $allowCollectionFormatMulti allow collection format to be a multidimensional array
196 | *
197 | * @return string
198 | */
199 | public static function serializeCollection(array $collection, $collectionFormat, $allowCollectionFormatMulti = false)
200 | {
201 | if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) {
202 | // http_build_query() almost does the job for us. We just
203 | // need to fix the result of multidimensional arrays.
204 | return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&'));
205 | }
206 | switch ($collectionFormat) {
207 | case 'pipes':
208 | return implode('|', $collection);
209 |
210 | case 'tsv':
211 | return implode("\t", $collection);
212 |
213 | case 'ssv':
214 | return implode(' ', $collection);
215 |
216 | case 'csv':
217 | // Deliberate fall through. CSV is default format.
218 | default:
219 | return implode(',', $collection);
220 | }
221 | }
222 |
223 | /**
224 | * Deserialize a JSON string into an object
225 | *
226 | * @param mixed $data object or primitive to be deserialized
227 | * @param string $class class name is passed as a string
228 | * @param string[] $httpHeaders HTTP headers
229 | * @param string $discriminator discriminator if polymorphism is used
230 | *
231 | * @return object|array|null an single or an array of $class instances
232 | */
233 | public static function deserialize($data, $class, $httpHeaders = null)
234 | {
235 | if (null === $data) {
236 | return null;
237 | } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int]
238 | $inner = substr($class, 4, -1);
239 | $deserialized = [];
240 | if (strrpos($inner, ",") !== false) {
241 | $subClass_array = explode(',', $inner, 2);
242 | $subClass = $subClass_array[1];
243 | foreach ($data as $key => $value) {
244 | $deserialized[$key] = self::deserialize($value, $subClass, null);
245 | }
246 | }
247 | return $deserialized;
248 | } elseif (strcasecmp(substr($class, -2), '[]') === 0) {
249 | $subClass = substr($class, 0, -2);
250 | $values = [];
251 | foreach ($data as $key => $value) {
252 | $values[] = self::deserialize($value, $subClass, null);
253 | }
254 | return $values;
255 | } elseif ($class === 'object') {
256 | settype($data, 'array');
257 | return $data;
258 | } elseif ($class === '\DateTime') {
259 | // Some API's return an invalid, empty string as a
260 | // date-time property. DateTime::__construct() will return
261 | // the current time for empty input which is probably not
262 | // what is meant. The invalid empty string is probably to
263 | // be interpreted as a missing field/value. Let's handle
264 | // this graceful.
265 | if (!empty($data)) {
266 | return new \DateTime($data);
267 | } else {
268 | return null;
269 | }
270 | } elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
271 | settype($data, $class);
272 | return $data;
273 | } elseif ($class === '\SplFileObject') {
274 | /** @var \Psr\Http\Message\StreamInterface $data */
275 |
276 | // determine file name
277 | if (array_key_exists('Content-Disposition', $httpHeaders) &&
278 | preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
279 | $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]);
280 | } else {
281 | $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
282 | }
283 |
284 | $file = fopen($filename, 'w');
285 | while ($chunk = $data->read(200)) {
286 | fwrite($file, $chunk);
287 | }
288 | fclose($file);
289 |
290 | return new \SplFileObject($filename, 'r');
291 | } elseif (method_exists($class, 'getAllowableEnumValues')) {
292 | if (!in_array($data, $class::getAllowableEnumValues(), true)) {
293 | $imploded = implode("', '", $class::getAllowableEnumValues());
294 | throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'");
295 | }
296 | return $data;
297 | } else {
298 | // If a discriminator is defined and points to a valid subclass, use it.
299 | $discriminator = $class::DISCRIMINATOR;
300 | if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) {
301 | $subclass = '\MailchimpTransactional\Model\\' . $data->{$discriminator};
302 | if (is_subclass_of($subclass, $class)) {
303 | $class = $subclass;
304 | }
305 | }
306 | $instance = new $class();
307 | foreach ($instance::swaggerTypes() as $property => $type) {
308 | $propertySetter = $instance::setters()[$property];
309 |
310 | if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) {
311 | continue;
312 | }
313 |
314 | $propertyValue = $data->{$instance::attributeMap()[$property]};
315 | if (isset($propertyValue)) {
316 | $instance->$propertySetter(self::deserialize($propertyValue, $type, null));
317 | }
318 | }
319 | return $instance;
320 | }
321 | }
322 | }
323 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 | ./test/Api
11 | ./test/Model
12 |
13 |
14 |
15 |
16 |
17 | ./lib/Api
18 | ./lib/Model
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------