GithubHelp home page GithubHelp logo

floresfdev / mailjet-apiv3-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mailjet/mailjet-apiv3-java

0.0 2.0 0.0 10.29 MB

[API v3] Mailjet Java API Wrapper

Home Page: https://dev.mailjet.com

License: MIT License

Java 100.00%

mailjet-apiv3-java's Introduction

alt text

Mailjet Java Client

Build Status

This repo features the Brand new Java wrapper for the Mailjet API. Check out the Offical Documentation

Getting Started

Installation (Maven)

Add the following in your pom.xml

    <dependencies>
        <dependency>
            <groupId>com.mailjet</groupId>
            <artifactId>mailjet-client</artifactId>
            <version>4.0.1</version>
        </dependency>
    </dependencies>

Grab your keys here

MailjetClient client = new MailjetClient(System.getenv("MJ_APIKEY_PUBLIC"), System.getenv("MJ_APIKEY_PRIVATE"));

Requests are easy to understand

MailjetRequest request = MailjetRequest(resource, id, actionId)

GET requests

List all your contacts

MailjetRequest contacts;
MailjetResponse response;

contacts = new MailjetRequest(Contact.resource);
response = client.get(contacts);

Filtering resources

MailjetRequest contacts;
MailjetResponse response;

contacts = new MailjetRequest(Contact.resource)
            .filter(Contact.LIMIT, 2);

response = client.get(contacts);

View a single resource

MailjetRequest contacts;
MailjetResponse response;

contacts = new MailjetRequest(Contact.resource, id);

response = client.get(contacts);

POST requests

Post a new sender

MailjetRequest contacts;
MailjetResponse response;

sender = new MailjetRequest(Sender.resource)
            .property(Sender.EMAIL, "[email protected]");

response = client.post(sender);

Send an Email

MailjetRequest email;
JSONArray recipients;
MailjetResponse response;

recipients = new JSONArray()
                .put(new JSONObject().put(Contact.EMAIL, "[email protected]"))
                .put(new JSONObject().put(Contact.EMAIL, "[email protected]"))
                .put(new JSONObject().put(Contact.EMAIL, "[email protected]"));

email = new MailjetRequest(Email.resource)
                    .property(Email.FROMNAME, "Guillaume")
                    .property(Email.FROMEMAIL, "[email protected]")
                    .property(Email.SUBJECT, "Subject")
                    .property(Email.TEXTPART, "Java is coming!...")
                    .property(Email.RECIPIENTS, recipients)
                    .property(Email.MJCUSTOMID, "JAVA-Email");

response = client.post(email);

Get and update a Sender

MailjetRequest getSender = new MailjetRequest(Sender.resource)
                                .filter(Sender.EMAIL, "email adress");
        
MailjetResponse senders = client.get(getSender);
        
// Grab the first sender
JSONObject sender = senders.getData().getJSONObject(0);
        
// Change the name
MailjetRequest update = new MailjetRequest(Sender.resource, sender.getLong("ID"))
                    .setBody(sender.put(Sender.NAME, "new name"));
                    
System.out.println(client.put(update));
      

TODO:

  • head

mailjet-apiv3-java's People

Contributors

charlescollas avatar fclairamb avatar gormador avatar hristo-todorov avatar shubs avatar swooop avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.