diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e49f469 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - "6" + - "6.1" + - "5" + - "5.11" + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b77d64b --- /dev/null +++ b/LICENSE @@ -0,0 +1,53 @@ +Mailchimp Client Library License Agreement + +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”). + +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. + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +1. Definitions. +“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. +“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. +“You” (or “Your”) shall mean an individual or Legal Entity exercising permissions granted by this License. +“Source” form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. +“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. +“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. +“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. +“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.” +“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. + +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. + +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. + +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: +a) You must give any other recipients of the Work or Derivative Works a copy of this License; and +b) You must cause any modified files to carry prominent notices stating that You changed the files; and +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 +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. +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. + +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. + +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. + +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. + +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. + +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. + +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. + +Copyright 2020, The Rocket Science Group LLC + +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. + +You should include a copy of the License, typically in a file called LICENSE, in your work, and consider also including a NOTICE file. + +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. +Copyright [yyyy] [name of copyright owner] + +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. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..16993f0 --- /dev/null +++ b/README.md @@ -0,0 +1,163 @@ +# Mailchimp Transactional — Node.js + +The official Node.js client library for the Mailchimp Transactional API (v1) + +## Installation + +``` +npm install @mailchimp/mailchimp_transactional +``` + +## Quick Start + +```javascript +const mailchimp = require('@mailchimp/mailchimp_transactional')('YOUR_API_KEY'); + +async function callPing() { + const response = await mailchimp.users.ping(); + console.log(response); +} + +callPing(); +``` + +## Sending Requests +All requests are sent via POST and accept a single argument as the request body parameter. +```javascript +mailchimp.templates.publish({ name: 'My Template' }); +``` + +## Output Formats +Optionally, you can set the default response format for **all requests** to one of the following: +- `json` *(default)* +- `xml` +- `php` +- `yaml` + +```javascript +mailchimp.setDefaultOutputFormat('xml'); +``` + +You can also set the response format for a **single request** by passing in a special `outputFormat` param to the request body. +```javascript +mailchimp.senders.list({ outputFormat: 'php' }); +``` + +## API Endpoints + +All URIs are relative to *https://mandrillapp.com/api/1.0* + +| Method | Endpoint | +| ---------- | -------- | +| **exports.activity** | /exports/activity | +| **exports.info** | /exports/info | +| **exports.list** | /exports/list | +| **exports.rejects** | /exports/rejects | +| **exports.whitelist** | /exports/whitelist | +| **inbound.addDomain** | /inbound/add-domain | +| **inbound.addRoute** | /inbound/add-route | +| **inbound.checkDomain** | /inbound/check-domain | +| **inbound.deleteDomain** | /inbound/delete-domain | +| **inbound.deleteRoute** | /inbound/delete-route | +| **inbound.domains** | /inbound/domains | +| **inbound.routes** | /inbound/routes | +| **inbound.sendRaw** | /inbound/send-raw | +| **inbound.updateRoute** | /inbound/update-route | +| **ips.cancelWarmup** | /ips/cancel-warmup | +| **ips.checkCustomDns** | /ips/check-custom-dns | +| **ips.createPool** | /ips/create-pool | +| **ips.delete** | /ips/delete | +| **ips.deletePool** | /ips/delete-pool | +| **ips.info** | /ips/info | +| **ips.list** | /ips/list | +| **ips.listPools** | /ips/list-pools | +| **ips.poolInfo** | /ips/pool-info | +| **ips.provision** | /ips/provision | +| **ips.setCustomDns** | /ips/set-custom-dns | +| **ips.setPool** | /ips/set-pool | +| **ips.startWarmup** | /ips/start-warmup | +| **messages.cancelScheduled** | /messages/cancel-scheduled | +| **messages.content** | /messages/content | +| **messages.info** | /messages/info | +| **messages.listScheduled** | /messages/list-scheduled | +| **messages.parse** | /messages/parse | +| **messages.reschedule** | /messages/reschedule | +| **messages.search** | /messages/search | +| **messages.searchTimeSeries** | /messages/search-time-series | +| **messages.send** | /messages/send | +| **messages.sendRaw** | /messages/send-raw | +| **messages.sendTemplate** | /messages/send-template | +| **metadata.add** | /metadata/add | +| **metadata.delete** | /metadata/delete | +| **metadata.list** | /metadata/list | +| **metadata.update** | /metadata/update | +| **rejects.add** | /rejects/add | +| **rejects.delete** | /rejects/delete | +| **rejects.list** | /rejects/list | +| **senders.addDomain** | /senders/add-domain | +| **senders.checkDomain** | /senders/check-domain | +| **senders.domains** | /senders/domains | +| **senders.info** | /senders/info | +| **senders.list** | /senders/list | +| **senders.timeSeries** | /senders/time-series | +| **senders.verifyDomain** | /senders/verify-domain | +| **subaccounts.add** | /subaccounts/add | +| **subaccounts.delete** | /subaccounts/delete | +| **subaccounts.info** | /subaccounts/info | +| **subaccounts.list** | /subaccounts/list | +| **subaccounts.pause** | /subaccounts/pause | +| **subaccounts.resume** | /subaccounts/resume | +| **subaccounts.update** | /subaccounts/update | +| **tags.allTimeSeries** | /tags/all-time-series | +| **tags.delete** | /tags/delete | +| **tags.info** | /tags/info | +| **tags.list** | /tags/list | +| **tags.timeSeries** | /tags/time-series | +| **templates.add** | /templates/add | +| **templates.delete** | /templates/delete | +| **templates.info** | /templates/info | +| **templates.list** | /templates/list | +| **templates.publish** | /templates/publish | +| **templates.render** | /templates/render | +| **templates.timeSeries** | /templates/time-series | +| **templates.update** | /templates/update | +| **urls.addTrackingDomain** | /urls/add-tracking-domain | +| **urls.checkTrackingDomain** | /urls/check-tracking-domain | +| **urls.list** | /urls/list | +| **urls.search** | /urls/search | +| **urls.timeSeries** | /urls/time-series | +| **urls.trackingDomains** | /urls/tracking-domains | +| **users.info** | /users/info | +| **users.ping** | /users/ping | +| **users.ping2** | /users/ping2 | +| **users.senders** | /users/senders | +| **webhooks.add** | /webhooks/add | +| **webhooks.delete** | /webhooks/delete | +| **webhooks.info** | /webhooks/info | +| **webhooks.list** | /webhooks/list | +| **webhooks.update** | /webhooks/update | +| **whitelists.add** | /whitelists/add | +| **whitelists.delete** | /whitelists/delete | +| **whitelists.list** | /whitelists/list | + + + +## Additional Client Libraries + +Mailchimp Transactional libraries are available in the following languages: + +
+ diff --git a/git_push.sh b/git_push.sh new file mode 100644 index 0000000..0d041ad --- /dev/null +++ b/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the Git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/package.json b/package.json new file mode 100644 index 0000000..ea7f26f --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "@mailchimp/mailchimp_transactional", + "version": "1.0.19", + "description": "The official Node client library for the Mailchimp Transactional API", + "license": "Apache 2.0", + "main": "src/index.js", + "browser": { + "fs": false + }, + "dependencies": { + "axios": "^0.19.2" + }, + "types": "types.d.ts" +} \ No newline at end of file diff --git a/src/ApiClient.js b/src/ApiClient.js new file mode 100644 index 0000000..f0a1b5a --- /dev/null +++ b/src/ApiClient.js @@ -0,0 +1,117 @@ +/* + * Mailchimp Transactional API + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * OpenAPI spec version: 1.0.19 + * Contact: apihelp@mailchimp.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * + * Swagger Codegen version: 2.4.12 + * + * Do not edit the class manually. + * + */ + +var axios = require('axios'); + +axios.defaults.timeout = 300000; // 300s + +var Exports = require('./api/ExportsApi'); +var Inbound = require('./api/InboundApi'); +var Ips = require('./api/IpsApi'); +var Messages = require('./api/MessagesApi'); +var Metadata = require('./api/MetadataApi'); +var Rejects = require('./api/RejectsApi'); +var Senders = require('./api/SendersApi'); +var Subaccounts = require('./api/SubaccountsApi'); +var Tags = require('./api/TagsApi'); +var Templates = require('./api/TemplatesApi'); +var Urls = require('./api/UrlsApi'); +var Users = require('./api/UsersApi'); +var Webhooks = require('./api/WebhooksApi'); +var Whitelists = require('./api/WhitelistsApi'); + +var exports = function (apiKey = '') { + this.basePath = 'https://mandrillapp.com/api/1.0'; + this.apiKey = apiKey; + this.defaultOutputFormat = ''; + + this.formatList = ['json', 'xml', 'php', 'yaml']; + this.contentTypes = ['application/json']; + this.accepts = [ + 'application/json', + 'application/xml', + 'application/x-php', + 'application/x-yaml; charset=utf-8' + ]; + + // API Routes + this.exports = new Exports(this); + this.inbound = new Inbound(this); + this.ips = new Ips(this); + this.messages = new Messages(this); + this.metadata = new Metadata(this); + this.rejects = new Rejects(this); + this.senders = new Senders(this); + this.subaccounts = new Subaccounts(this); + this.tags = new Tags(this); + this.templates = new Templates(this); + this.urls = new Urls(this); + this.users = new Users(this); + this.webhooks = new Webhooks(this); + this.whitelists = new Whitelists(this); +}; + +// HTTP POST request helper +exports.prototype.post = function post(path, body = {}) { + var _this = this; + var url = _this.basePath + path; + + // apply API key to the request + body.key = _this.apiKey; + + // apply response format modifier + var formatList = _this.formatList; + var useDefaultOutputFormat = true; + + if (typeof body.outputFormat === 'string') { + var format = body.outputFormat.toLowerCase(); + if (formatList.indexOf(format) !== -1) { + url = url + '.' + format; + delete body.outputFormat; + useDefaultOutputFormat = false; + } + } + + // or use the default response format + var defaultOutputFormat = _this.defaultOutputFormat; + if (useDefaultOutputFormat && formatList.indexOf(defaultOutputFormat) !== -1) { + url = url + '.' + defaultOutputFormat; + } + + return axios + .post(url, body) + .then(function (response) { + return response.data; + }) + .catch(function (error) { + return error; + }) +}; + +// Updates the default HTTP request response format (json, xml, php, yaml) +exports.prototype.setDefaultOutputFormat = function (outputFormat) { + var _this = this; + if (_this.formatList.indexOf(outputFormat) !== -1) { + _this.defaultOutputFormat = outputFormat; + } +}; + +// The default API client implementation. +exports.instance = function (apiKey) { + return new exports(apiKey); +}; + +module.exports = exports; diff --git a/src/api/ExportsApi.js b/src/api/ExportsApi.js new file mode 100644 index 0000000..daa296f --- /dev/null +++ b/src/api/ExportsApi.js @@ -0,0 +1,46 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Export activity history + * 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. + */ + this.activity = function (body) { + return this.apiClient.post('/exports/activity', body); + }; + + /** + * View export info + * 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. + */ + this.info = function (body) { + return this.apiClient.post('/exports/info', body); + }; + + /** + * List exports + * Returns a list of your exports. + */ + this.list = function (body) { + return this.apiClient.post('/exports/list', body); + }; + + /** + * Export blacklist + * Begins an export of your rejection blacklist. The blacklist 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. + */ + this.rejects = function (body) { + return this.apiClient.post('/exports/rejects', body); + }; + + /** + * Export whitelist + * Begins an export of your rejection whitelist. The whitelist will be exported to a zip archive containing a single file named whitelist.csv that includes the following fields: email, detail, created_at. + */ + this.whitelist = function (body) { + return this.apiClient.post('/exports/whitelist', body); + }; + +}; diff --git a/src/api/InboundApi.js b/src/api/InboundApi.js new file mode 100644 index 0000000..f02e887 --- /dev/null +++ b/src/api/InboundApi.js @@ -0,0 +1,78 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Add inbound domain + * Add an inbound domain to your account. + */ + this.addDomain = function (body) { + return this.apiClient.post('/inbound/add-domain', body); + }; + + /** + * Add mailbox route + * Add a new mailbox route to an inbound domain. + */ + this.addRoute = function (body) { + return this.apiClient.post('/inbound/add-route', body); + }; + + /** + * Check domain settings + * Check the MX settings for an inbound domain. The domain must have already been added with the add-domain call. + */ + this.checkDomain = function (body) { + return this.apiClient.post('/inbound/check-domain', body); + }; + + /** + * Delete inbound domain + * Delete an inbound domain from the account. All mail will stop routing for this domain immediately. + */ + this.deleteDomain = function (body) { + return this.apiClient.post('/inbound/delete-domain', body); + }; + + /** + * Delete mailbox route + * Delete an existing inbound mailbox route. + */ + this.deleteRoute = function (body) { + return this.apiClient.post('/inbound/delete-route', body); + }; + + /** + * List inbound domains + * List the domains that have been configured for inbound delivery. + */ + this.domains = function (body) { + return this.apiClient.post('/inbound/domains', body); + }; + + /** + * List mailbox routes + * List the mailbox routes defined for an inbound domain. + */ + this.routes = function (body) { + return this.apiClient.post('/inbound/routes', body); + }; + + /** + * Send mime document + * 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. + */ + this.sendRaw = function (body) { + return this.apiClient.post('/inbound/send-raw', body); + }; + + /** + * Update mailbox route + * Update the pattern or webhook of an existing inbound mailbox route. If null is provided for any fields, the values will remain unchanged. + */ + this.updateRoute = function (body) { + return this.apiClient.post('/inbound/update-route', body); + }; + +}; diff --git a/src/api/IpsApi.js b/src/api/IpsApi.js new file mode 100644 index 0000000..045c6c4 --- /dev/null +++ b/src/api/IpsApi.js @@ -0,0 +1,110 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Cancel ip warmup + * Cancels the warmup process for a dedicated IP. + */ + this.cancelWarmup = function (body) { + return this.apiClient.post('/ips/cancel-warmup', body); + }; + + /** + * Test custom dns + * Tests whether a domain name is valid for use as the custom reverse DNS for a dedicated IP. + */ + this.checkCustomDns = function (body) { + return this.apiClient.post('/ips/check-custom-dns', body); + }; + + /** + * Add ip pool + * Creates a pool and returns it. If a pool already exists with this name, no action will be performed. + */ + this.createPool = function (body) { + return this.apiClient.post('/ips/create-pool', body); + }; + + /** + * Delete ip address + * Deletes a dedicated IP. This is permanent and cannot be undone. + */ + this.delete = function (body) { + return this.apiClient.post('/ips/delete', body); + }; + + /** + * Delete ip pool + * Deletes a pool. A pool must be empty before you can delete it, and you cannot delete your default pool. + */ + this.deletePool = function (body) { + return this.apiClient.post('/ips/delete-pool', body); + }; + + /** + * Get ip info + * Retrieves information about a single dedicated IP. + */ + this.info = function (body) { + return this.apiClient.post('/ips/info', body); + }; + + /** + * List ip addresses + * Lists your dedicated IPs. + */ + this.list = function (body) { + return this.apiClient.post('/ips/list', body); + }; + + /** + * List ip pools + * Lists your dedicated IP pools. + */ + this.listPools = function (body) { + return this.apiClient.post('/ips/list-pools', body); + }; + + /** + * Get ip pool info + * Describes a single dedicated IP pool. + */ + this.poolInfo = function (body) { + return this.apiClient.post('/ips/pool-info', body); + }; + + /** + * Request additional ip + * 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. + */ + this.provision = function (body) { + return this.apiClient.post('/ips/provision', body); + }; + + /** + * Set custom dns + * Configures the custom DNS name for a dedicated IP. + */ + this.setCustomDns = function (body) { + return this.apiClient.post('/ips/set-custom-dns', body); + }; + + /** + * Move ip to different pool + * Moves a dedicated IP to a different pool. + */ + this.setPool = function (body) { + return this.apiClient.post('/ips/set-pool', body); + }; + + /** + * Start ip warmup + * 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. + */ + this.startWarmup = function (body) { + return this.apiClient.post('/ips/start-warmup', body); + }; + +}; diff --git a/src/api/MessagesApi.js b/src/api/MessagesApi.js new file mode 100644 index 0000000..f196a5d --- /dev/null +++ b/src/api/MessagesApi.js @@ -0,0 +1,94 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Cancel scheduled email + * Cancels a scheduled email. + */ + this.cancelScheduled = function (body) { + return this.apiClient.post('/messages/cancel-scheduled', body); + }; + + /** + * Get message content + * Get the full content of a recently sent message. + */ + this.content = function (body) { + return this.apiClient.post('/messages/content', body); + }; + + /** + * Get message info + * Get the information for a single recently sent message. + */ + this.info = function (body) { + return this.apiClient.post('/messages/info', body); + }; + + /** + * List scheduled emails + * Queries your scheduled emails. + */ + this.listScheduled = function (body) { + return this.apiClient.post('/messages/list-scheduled', body); + }; + + /** + * Parse mime document + * Parse the full MIME document for an email message, returning the content of the message broken into its constituent pieces. + */ + this.parse = function (body) { + return this.apiClient.post('/messages/parse', body); + }; + + /** + * Reschedule email + * Reschedules a scheduled email. + */ + this.reschedule = function (body) { + return this.apiClient.post('/messages/reschedule', body); + }; + + /** + * Search messages by date + * 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. + */ + this.search = function (body) { + return this.apiClient.post('/messages/search', body); + }; + + /** + * Search messages by hour + * Search the content of recently sent messages and return the aggregated hourly stats for matching messages. + */ + this.searchTimeSeries = function (body) { + return this.apiClient.post('/messages/search-time-series', body); + }; + + /** + * Send new message + * Send a new transactional message through the Transactional API. + */ + this.send = function (body) { + return this.apiClient.post('/messages/send', body); + }; + + /** + * Send mime document + * Take a raw MIME document for a message, and send it exactly as if it were sent through the Transactional API's SMTP servers. + */ + this.sendRaw = function (body) { + return this.apiClient.post('/messages/send-raw', body); + }; + + /** + * Send using message template + * Send a new transactional message through the Transactional API using a template. + */ + this.sendTemplate = function (body) { + return this.apiClient.post('/messages/send-template', body); + }; + +}; diff --git a/src/api/MetadataApi.js b/src/api/MetadataApi.js new file mode 100644 index 0000000..ca5d551 --- /dev/null +++ b/src/api/MetadataApi.js @@ -0,0 +1,38 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Add metadata field + * Add a new custom metadata field to be indexed for the account. + */ + this.add = function (body) { + return this.apiClient.post('/metadata/add', body); + }; + + /** + * Delete metadata field + * 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. + */ + this.delete = function (body) { + return this.apiClient.post('/metadata/delete', body); + }; + + /** + * List metadata fields + * Get the list of custom metadata fields indexed for the account. + */ + this.list = function (body) { + return this.apiClient.post('/metadata/list', body); + }; + + /** + * Update metadata field + * Update an existing custom metadata field. + */ + this.update = function (body) { + return this.apiClient.post('/metadata/update', body); + }; + +}; diff --git a/src/api/RejectsApi.js b/src/api/RejectsApi.js new file mode 100644 index 0000000..815736a --- /dev/null +++ b/src/api/RejectsApi.js @@ -0,0 +1,30 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Add email to blacklist + * Adds an email to your email rejection blacklist. Addresses that you add manually will never expire and there is no reputation penalty for removing them from your blacklist. Attempting to blacklist an address that has been whitelisted will have no effect. + */ + this.add = function (body) { + return this.apiClient.post('/rejects/add', body); + }; + + /** + * Delete email from blacklist + * Deletes an email rejection. There is no limit to how many rejections you can remove from your blacklist, but keep in mind that each deletion has an affect on your reputation. + */ + this.delete = function (body) { + return this.apiClient.post('/rejects/delete', body); + }; + + /** + * List blacklisted emails + * Retrieves your email rejection blacklist. 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. + */ + this.list = function (body) { + return this.apiClient.post('/rejects/list', body); + }; + +}; diff --git a/src/api/SendersApi.js b/src/api/SendersApi.js new file mode 100644 index 0000000..22bf596 --- /dev/null +++ b/src/api/SendersApi.js @@ -0,0 +1,62 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Add sender domain + * 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. + */ + this.addDomain = function (body) { + return this.apiClient.post('/senders/add-domain', body); + }; + + /** + * Check domain settings + * Checks the SPF and DKIM settings for a domain. If you haven't already added this domain to your account, it will be added automatically. + */ + this.checkDomain = function (body) { + return this.apiClient.post('/senders/check-domain', body); + }; + + /** + * List sender domains + * Returns the sender domains that have been added to this account. + */ + this.domains = function (body) { + return this.apiClient.post('/senders/domains', body); + }; + + /** + * Get sender info + * Return more detailed information about a single sender, including aggregates of recent stats. + */ + this.info = function (body) { + return this.apiClient.post('/senders/info', body); + }; + + /** + * List account senders + * Return the senders that have tried to use this account. + */ + this.list = function (body) { + return this.apiClient.post('/senders/list', body); + }; + + /** + * View sender history + * Return the recent history (hourly stats for the last 30 days) for a sender. + */ + this.timeSeries = function (body) { + return this.apiClient.post('/senders/time-series', body); + }; + + /** + * Verify domain + * 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. + */ + this.verifyDomain = function (body) { + return this.apiClient.post('/senders/verify-domain', body); + }; + +}; diff --git a/src/api/SubaccountsApi.js b/src/api/SubaccountsApi.js new file mode 100644 index 0000000..92b87d4 --- /dev/null +++ b/src/api/SubaccountsApi.js @@ -0,0 +1,62 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Add subaccount + * Add a new subaccount. + */ + this.add = function (body) { + return this.apiClient.post('/subaccounts/add', body); + }; + + /** + * Delete subaccount + * 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. + */ + this.delete = function (body) { + return this.apiClient.post('/subaccounts/delete', body); + }; + + /** + * Get subaccount info + * Given the ID of an existing subaccount, return the data about it. + */ + this.info = function (body) { + return this.apiClient.post('/subaccounts/info', body); + }; + + /** + * List subaccounts + * Get the list of subaccounts defined for the account, optionally filtered by a prefix. + */ + this.list = function (body) { + return this.apiClient.post('/subaccounts/list', body); + }; + + /** + * Pause subaccount + * 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. + */ + this.pause = function (body) { + return this.apiClient.post('/subaccounts/pause', body); + }; + + /** + * Resume subaccount + * Resume a paused subaccount's sending. + */ + this.resume = function (body) { + return this.apiClient.post('/subaccounts/resume', body); + }; + + /** + * Update subaccount + * Update an existing subaccount. + */ + this.update = function (body) { + return this.apiClient.post('/subaccounts/update', body); + }; + +}; diff --git a/src/api/TagsApi.js b/src/api/TagsApi.js new file mode 100644 index 0000000..9b9f2c2 --- /dev/null +++ b/src/api/TagsApi.js @@ -0,0 +1,46 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * View all tags history + * Return the recent history (hourly stats for the last 30 days) for all tags. + */ + this.allTimeSeries = function (body) { + return this.apiClient.post('/tags/all-time-series', body); + }; + + /** + * Delete tag + * 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. + */ + this.delete = function (body) { + return this.apiClient.post('/tags/delete', body); + }; + + /** + * Get tag info + * Return more detailed information about a single tag, including aggregates of recent stats. + */ + this.info = function (body) { + return this.apiClient.post('/tags/info', body); + }; + + /** + * List tags + * Return all of the user-defined tag information. + */ + this.list = function (body) { + return this.apiClient.post('/tags/list', body); + }; + + /** + * View tag history + * Return the recent history (hourly stats for the last 30 days) for a tag. + */ + this.timeSeries = function (body) { + return this.apiClient.post('/tags/time-series', body); + }; + +}; diff --git a/src/api/TemplatesApi.js b/src/api/TemplatesApi.js new file mode 100644 index 0000000..a00cbeb --- /dev/null +++ b/src/api/TemplatesApi.js @@ -0,0 +1,70 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Add template + * Add a new template. + */ + this.add = function (body) { + return this.apiClient.post('/templates/add', body); + }; + + /** + * Delete template + * Delete a template. + */ + this.delete = function (body) { + return this.apiClient.post('/templates/delete', body); + }; + + /** + * Get template info + * Get the information for an existing template. + */ + this.info = function (body) { + return this.apiClient.post('/templates/info', body); + }; + + /** + * List templates + * Return a list of all the templates available to this user. + */ + this.list = function (body) { + return this.apiClient.post('/templates/list', body); + }; + + /** + * Publish template content + * Publish the content for the template. Any new messages sent using this template will start using the content that was previously in draft. + */ + this.publish = function (body) { + return this.apiClient.post('/templates/publish', body); + }; + + /** + * Render html template + * Inject content and optionally merge fields into a template, returning the HTML that results. + */ + this.render = function (body) { + return this.apiClient.post('/templates/render', body); + }; + + /** + * Get template history + * Return the recent history (hourly stats for the last 30 days) for a template. + */ + this.timeSeries = function (body) { + return this.apiClient.post('/templates/time-series', body); + }; + + /** + * Update template + * Update the code for an existing template. If null is provided for any fields, the values will remain unchanged. + */ + this.update = function (body) { + return this.apiClient.post('/templates/update', body); + }; + +}; diff --git a/src/api/UrlsApi.js b/src/api/UrlsApi.js new file mode 100644 index 0000000..72d0af3 --- /dev/null +++ b/src/api/UrlsApi.js @@ -0,0 +1,54 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Add tracking domains + * Add a tracking domain to your account. + */ + this.addTrackingDomain = function (body) { + return this.apiClient.post('/urls/add-tracking-domain', body); + }; + + /** + * Check cname settings + * Checks the CNAME settings for a tracking domain. The domain must have been added already with the add-tracking-domain call. + */ + this.checkTrackingDomain = function (body) { + return this.apiClient.post('/urls/check-tracking-domain', body); + }; + + /** + * List most clicked urls + * Get the 100 most clicked URLs. + */ + this.list = function (body) { + return this.apiClient.post('/urls/list', body); + }; + + /** + * Search most clicked urls + * Return the 100 most clicked URLs that match the search query given. + */ + this.search = function (body) { + return this.apiClient.post('/urls/search', body); + }; + + /** + * Get url history + * Return the recent history (hourly stats for the last 30 days) for a URL + */ + this.timeSeries = function (body) { + return this.apiClient.post('/urls/time-series', body); + }; + + /** + * List tracking domains + * Get the list of tracking domains set up for this account. + */ + this.trackingDomains = function (body) { + return this.apiClient.post('/urls/tracking-domains', body); + }; + +}; diff --git a/src/api/UsersApi.js b/src/api/UsersApi.js new file mode 100644 index 0000000..14892cb --- /dev/null +++ b/src/api/UsersApi.js @@ -0,0 +1,38 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Get user info + * Return the information about the API-connected user. + */ + this.info = function (body) { + return this.apiClient.post('/users/info', body); + }; + + /** + * Ping + * Validate an API key and respond to a ping. + */ + this.ping = function (body) { + return this.apiClient.post('/users/ping', body); + }; + + /** + * Ping 2 + * Validate an API key and respond to a ping (JSON parser version). + */ + this.ping2 = function (body) { + return this.apiClient.post('/users/ping2', body); + }; + + /** + * List account senders + * Return the senders that have tried to use this account, both verified and unverified. + */ + this.senders = function (body) { + return this.apiClient.post('/users/senders', body); + }; + +}; diff --git a/src/api/WebhooksApi.js b/src/api/WebhooksApi.js new file mode 100644 index 0000000..fbc167a --- /dev/null +++ b/src/api/WebhooksApi.js @@ -0,0 +1,46 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Add webhook + * Add a new webhook. + */ + this.add = function (body) { + return this.apiClient.post('/webhooks/add', body); + }; + + /** + * Delete webhook + * Delete an existing webhook. + */ + this.delete = function (body) { + return this.apiClient.post('/webhooks/delete', body); + }; + + /** + * Get webhook info + * Given the ID of an existing webhook, return the data about it. + */ + this.info = function (body) { + return this.apiClient.post('/webhooks/info', body); + }; + + /** + * List webhooks + * Get the list of all webhooks defined on the account. + */ + this.list = function (body) { + return this.apiClient.post('/webhooks/list', body); + }; + + /** + * Update webhook + * Update an existing webhook. + */ + this.update = function (body) { + return this.apiClient.post('/webhooks/update', body); + }; + +}; diff --git a/src/api/WhitelistsApi.js b/src/api/WhitelistsApi.js new file mode 100644 index 0000000..3064797 --- /dev/null +++ b/src/api/WhitelistsApi.js @@ -0,0 +1,30 @@ +var ApiClient = require('../ApiClient'); + +module.exports = function (apiClient) { + this.apiClient = apiClient || ApiClient.instance(); + + /** + * Add email to whitelist + * Adds an email to your email rejection whitelist. If the address is currently on your blacklist, that blacklist entry will be removed automatically. + */ + this.add = function (body) { + return this.apiClient.post('/whitelists/add', body); + }; + + /** + * Remove email from whitelist + * Removes an email address from the whitelist. + */ + this.delete = function (body) { + return this.apiClient.post('/whitelists/delete', body); + }; + + /** + * List whitelisted emails + * Retrieves your email rejection whitelist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results. + */ + this.list = function (body) { + return this.apiClient.post('/whitelists/list', body); + }; + +}; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..b089ca7 --- /dev/null +++ b/src/index.js @@ -0,0 +1,5 @@ +var ApiClient = require('./ApiClient'); + +module.exports = function(apiKey) { + return ApiClient.instance(apiKey); +}; diff --git a/types.d.ts b/types.d.ts new file mode 100644 index 0000000..d250d2b --- /dev/null +++ b/types.d.ts @@ -0,0 +1,6 @@ +/** + * This file was auto-generated by swagger-to-ts. + * Do not make direct changes to the file. + */ + +declare namespace OpenAPI2 {}