Skip to content

chaudharydeepak/pepipost-sdk-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pepipostlogo

Twitter Follow

Official Java library ☕ for Pepipost

This library contains methods for easily interacting with the Pepipost Email Sending API to send emails within few seconds.

We are trying to make our libraries Community Driven- which means we need your help in building the right things in proper order we would request you to help us by sharing comments, creating new issues or pull requests.

We welcome any sort of contribution to this library.

The latest 2.5.0 version of this library provides is fully compatible with the latest Pepipost v2.0 API.

For any update of this library check Releases.

Table of Content

Installation

Prerequisites

  • Java version Oracle JDK 7, 8 or OpenJDK 7
  • Java Maven Dependencies
    • Jackson
    • UniRest
    • Apache HttpClient
  • Java Development Enviromment (IDE).
  • A free account on Pepipost. If you don't have a one, click here to signup and get 30,000 emails free every month.

Quick Start

This Java library uses few Maven Dependencies (mentioned above). The reference to these dependencies are added in pom.xml file which will be installed automatically. Just need internet access for successful build.

  • Download zip or get a clone for the pepipost repository using

    git clone https://github.com/pepipost/pepipost-sdk-java.git

  • In order to open the client library in Eclipse click on File -> Import.

    Importing SDK into Eclipse - Step 1

  • In the import dialog, select Existing Java Project and click Next.

    Importing SDK into Eclipse - Step 2

  • Browse to locate the folder containing the source code. Select the detected location of the project and click Finish.

    Importing SDK into Eclipse - Step 3

  • Upon successful import, the project will be automatically built by Eclipse after automatically resolving the dependencies.

    Importing SDK into Eclipse - Step 4

Usage of Pepipost library in project

  1. Starting a new project

    • Click the menu command File > New > Project.

      Add a new project in Eclipse

    • Choose Maven > Maven Project.

    • Click Next.

      Create a new Maven Project - Step 1

    • Here, make sure to use the current workspace by choosing Use default Workspace location, as shown in the screenshot below.

    • Click Next.

      Create a new Maven Project - Step 2

    • Select the quick start project type to create a simple project with an existing class.

    • A main method.

    • To do this, choose maven-archetype-quickstart item from the list.

    • Click Next.

      Create a new Maven Project - Step 3

    • In the last step, provide a Group Id.and Artifact Id as shown in the picture below.

    • Click Finish.

      Create a new Maven Project - Step 4

  2. Add reference of the library project

    • The created Maven project manages its dependencies using its pom.xml file.

    • In order to add a dependency on the PepipostLib client library, double click on the pom.xml file in the Package Explorer.

    • Opening the pom.xml file will render a graphical view on the canvas.

    • Here, switch to the Dependencies tab.

    • Click the Add button as shown in the picture below.

      Adding dependency to the client library - Step 1

    • Click the Add button. A dialog will open, where you need to specify Pepipost in Group Id and PepipostLib in the Artifact Id fields.

    • Once added click OK.

    • Save the pom.xml file.

      Adding dependency to the client library - Step 2

  3. Getting started with code

    • Once the SimpleConsoleApp is created, a file named App.java will be visible in the Package Explorer with a main method.

    • This is the entry point for the execution of the created project.

      Adding dependency to the client library - Step 2

Sample Usage

package testApp.SimpleConsoleApp;
import com.pepipost.api.*;
import com.pepipost.api.models.*;
import com.pepipost.api.controllers.*;
import com.pepipost.api.http.client.*;
import java.util.*;
import java.io.*;
import com.fasterxml.jackson.core.JsonProcessingException;

public class App {

    public static void main(String[] args) throws JsonProcessingException {

        PepipostClient client = new PepipostClient();

        EmailController emailController = client.getEmail();
        String apiKey = "my-api-here";
        EmailBody body = new EmailBody();

        body.setPersonalizations(new LinkedList<Personalizations>());
        Personalizations body_personalizations_0 = new Personalizations();

        body_personalizations_0.setRecipient("[email protected]");
        body.getPersonalizations().add(body_personalizations_0);
        body.setTags("tagsjava");
        body.setFrom(new From());

        body.getFrom().setFromEmail("[email protected]");
        body.getFrom().setFromName("info");
        body.setSubject("JAVA SDK");
        body.setContent("Test mail ready to sent");
        body.setSettings(new Settings());

        body.getSettings().setFooter(0);
        body.getSettings().setClicktrack(1);
        body.getSettings().setOpentrack(1);
        body.getSettings().setUnsubscribe(1);
        

        emailController.createSendEmailAsync(apiKey, body, new APICallBack<SendEmailResponse>() {
            public void onSuccess(HttpContext context, SendEmailResponse response) {
                // TODO success callback handler
            	System.out.print("Message :: " + response.getMessage() + "\n" + "Error :: " + response.getErrorInfo().getErrorMessage());
            }
            public void onFailure(HttpContext context, Throwable error) {
            	System.out.print(context.getResponse());
            }
            
         });
    }
}
  • Change your api-key and sending domain respectively
    • apikey will be available under Login to Pepipost -> Settings -> Integration
    • Sending Domain will be available under Login to Pepiost -> Settings -> Sending Domains
  *Note :: Domains showing with Active status on Sending Domain dashboard are only allowed to send any sort of emails.* In case there are no Sending Domain added under your account, then first add the domain, get the DNS (SPF/DKIM) settings done and get it reviewed by our compliance team for approval. Once the domain is approved, it will be in ACTIVE status and will be ready to send any sort of emails. 
  • Run your project

Announcements

v2.5.0 has been released! Please see the release notes for details.

All updates to this library are documented in our releases. For any queries, feel free to reach out us at [email protected]

Roadmap

If you are interested in the future direction of this project, please take a look at our open issues and pull requests. We would love to hear your feedback.

About

pepipost-sdk-java library is guided and supported by the Pepipost Developer Experience Team . This pepipost library is maintained and funded by Pepipost Ltd. The names and logos for pepipost gem are trademarks of Pepipost Ltd.

License

This code library was semi-automatically generated by APIMATIC v2.0 and licensed under The MIT License (MIT).

About

The Official Pepipost Java API Library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%