0.1.0 • Published 3 years ago

mimepost v0.1.0

Weekly downloads
3
License
Unlicense
Repository
github
Last release
3 years ago

mimepost

Mimepost - JavaScript client for mimepost MimePost API for sending email. You can find out more about MimePost at https://mimepost.com. For this sample, you can use the api key special-key to test the authorization filters. This SDK is automatically generated by the Swagger Codegen project:

  • API version: 0.1.0
  • Package version: 0.1.0
  • Build package: io.swagger.codegen.languages.JavascriptClientCodegen

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install mimespost --save
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your mimepost from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('mimepost') in javascript files from the directory you ran the last command above from.

git

If the library is hosted at a git repository, e.g. https://github.com/mimepost/mimepost-node then install it via:

    npm install mimepost/mimepost-node --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var Mimepost = require('mimepost');

var defaultClient = Mimepost.ApiClient.instance;

// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = "YOUR API KEY"
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix['X-Auth-Token'] = "Token"

var api = new Mimepost.AccountsApi()

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.accountProfileGet(callback);

Send Email Example

var Mimepost = require('mimepost');

var defaultClient = Mimepost.ApiClient.instance;

// Configure API key authorization: api_key
var api_key = defaultClient.authentications['api_key'];
api_key.apiKey = 'YOUR_API_KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//api_key.apiKeyPrefix = 'Token';

var apiInstance = new MimePost.EmailsApi();

var body = new MimePost.Email(); // Email | Single Email object 
var to = new MimePost.EmailTo() // To Email | Single To Email object

to.email = "TO_EMAIL" 


body.html = "<h1>Html Code OR Text</h1>" 
body.from_email = "FROM_EMAIL"
body.from_name = "FROM_NAME"
body.subject = "SUBJECT"
body.to = [to]


var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + response.text);
  }
};
apiInstance.sendEmail(body, callback);

Documentation for API Endpoints

All URIs are relative to https://api.mimepost.com/v1/

ClassMethodHTTP requestDescription
Mimepost.AccountsApiaccountProfileGetGET /account/profile/Get account profile details
Mimepost.AccountsApiaccountProfilePostPOST /account/profile/Update account profile details
Mimepost.AccountsApisettingsGetGET /settings/Get all the settings
Mimepost.AccountsApisettingsPostPOST /settings/Set a setting
Mimepost.DomainsApidomainsGetGET /domains/Get a list of all the domains
Mimepost.DomainsApidomainsIdApprovePostPOST /domains/{id}/approve/Submit request for the approval of a verified domain
Mimepost.DomainsApidomainsIdDeleteDELETE /domains/{id}Remove a single domain
Mimepost.DomainsApidomainsIdGetGET /domains/{id}Get the details of a single domain
Mimepost.DomainsApidomainsIdVerifyDkimPostPOST /domains/{id}/verify_dkim/Request for the verification of DKIM record for a single domain
Mimepost.DomainsApidomainsIdVerifySpfPostPOST /domains/{id}/verify_spf/Request for the verification of SPF record for a single domain
Mimepost.DomainsApidomainsIdVerifyTrackingPostPOST /domains/{id}/verify_tracking/Request for the verification of tracking record for a single domain
Mimepost.DomainsApidomainsPostPOST /domains/Add single domain
Mimepost.EmailsApisendEmailPOST /emails/Send email
Mimepost.StatsApiemaillogsGetGET /emaillogs/Get the logs of a particular date
Mimepost.StatsApistatsGetGET /stats/Get the summary of stats for a range of dates
Mimepost.WebhooksApiwebhooksGetGET /webhooks/Get the list of all the webhooks
Mimepost.WebhooksApiwebhooksIdDeleteDELETE /webhooks/{id}Remove a single webhook
Mimepost.WebhooksApiwebhooksIdGetGET /webhooks/{id}Get the details of a single webhook
Mimepost.WebhooksApiwebhooksIdPutPUT /webhooks/{id}Update the details of a single webhook
Mimepost.WebhooksApiwebhooksPostPOST /webhooks/Add single webhook

Documentation for Models

Documentation for Authorization

api_key

  • Type: API key
  • API key parameter name: X-Auth-Token
  • Location: HTTP header