Skip to content
This repository has been archived by the owner on May 2, 2019. It is now read-only.

yholkamp/postmark-java

Repository files navigation

DEPRECATED Postmark-client

No longer maintained, with the arrival and active development of https://github.com/wildbit/postmark-java, users are strongly urged to use that library instead.

A Java API client for the APIs offered by Postmark, allowing you to send and receive e-mail from your Java application using the Server API. Furthermore, you can configure your Postmark account using the Account API.

The code in this repository is generated using Swagger Codegen.

Installation

Add this dependency to your project's POM:

<dependency>
    <groupId>net.nextpulse</groupId>
    <artifactId>postmark-client</artifactId>
    <version>1.1.0</version>
</dependency>

Example usage

Please follow the installation instructions. Once this is done, you can invoke the Server API using the following code:

import net.nextpulse.postmarkapp.api.*;
import net.nextpulse.postmarkapp.api.auth.*;
import net.nextpulse.postmarkapp.models.server.*;
import net.nextpulse.postmarkapp.api.server.BouncesAPIApi;

public class BouncesAPIApiExample {

    public static void main(String[] args) {
        BouncesAPIApi apiInstance = new BouncesAPIApi();
        String serverApiToken = "xPostmarkServerToken_example"; // String | The token associated with the Server on which this request will operate.
        Long bounceid = 789L; // Long | The ID of the Bounce to activate.
        try {
            BounceActivationResponse result = apiInstance.activateBounce(serverApiToken, bounceid);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling BouncesAPIApi#activateBounce");
            e.printStackTrace();
        }
    }
}

Similarly, you can invoke the Accounts API using the code below. Note that you have to use your Accounts API token for these calls.

import net.nextpulse.postmarkapp.api.*;
import net.nextpulse.postmarkapp.api.auth.*;
import net.nextpulse.postmarkapp.models.account.*;
import net.nextpulse.postmarkapp.api.account.DomainsAPIApi;

public class DomainsAPIApiExample {

    public static void main(String[] args) {
        DomainsAPIApi apiInstance = new DomainsAPIApi();
        String xPostmarkAccountToken = "xPostmarkAccountToken_example"; // String | The token associated with the Account on which this request will operate.
        DomainCreationModel body = new DomainCreationModel(); // DomainCreationModel | 
        try {
            DomainExtendedInformation result = apiInstance.createDomain(xPostmarkAccountToken, body);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling DomainsAPIApi#createDomain");
            e.printStackTrace();
        }
    }
}

Documentation

Documentation for the different API endpoints can be found here:

  • Server API, allowing you to retrieve email caught by the Postmark API, send out new emails, manage bounces and statistics.
  • Accounts API, allowing you to add additional domain names, manage senders.

Development

To (re)generate the client code, execute mvn compile. This will generate new source files and compile them. Using mvn deploy -P release, a new version may be related to Maven Central.

About

Deprecated Java API client for the APIs offered by Postmark

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published