当前位置: 首页>>代码示例>>Java>>正文


Java MailjetException类代码示例

本文整理汇总了Java中com.mailjet.client.errors.MailjetException的典型用法代码示例。如果您正苦于以下问题:Java MailjetException类的具体用法?Java MailjetException怎么用?Java MailjetException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MailjetException类属于com.mailjet.client.errors包,在下文中一共展示了MailjetException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFilteringGet

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
@Test
public void testFilteringGet() throws MailjetException, MailjetSocketTimeoutException {
    MailjetClient client;

    client = new MailjetClient("", "");
    client.setDebug(MailjetClient.NOCALL_DEBUG);

    System.out.println("TESTING: Simple Filtering with GET");


    // Simple contact GET request
    MailjetRequest contacts;
    MailjetResponse response;

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

    response = client.get(contacts);
    String url = response.getString("url");
    Boolean test = url.equals("https://api.mailjet.com/v3/REST/contact?Offset=2&Limit=10") ||
            url.equals("https://api.mailjet.com/v3/REST/contact?Limit=10&Offset=2");

    assertTrue(test);
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:26,代码来源:MailjetClientTest.java

示例2: main

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
public static void main(String[] args) throws MailjetException, MailjetSocketTimeoutException {
  final String mailjetApiKey = "YOUR-MAILJET-API-KEY";
  final String mailjetSecretKey = "YOUR-MAILJET-SECRET-KEY";
  MailjetClient client = new MailjetClient(
      mailjetApiKey, mailjetSecretKey, new ClientOptions("v3.1"));

  MailjetSender sender = new MailjetSender();
  sender.sendMailjet(args[0], args[1], client);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:10,代码来源:MailjetSender.java

示例3: sendMailjet

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
public MailjetResponse sendMailjet(String recipient, String sender, MailjetClient client)
      throws MailjetException, MailjetSocketTimeoutException {
  MailjetRequest email = new MailjetRequest(Emailv31.resource)
      .property(Emailv31.MESSAGES, new JSONArray()
      .put(new JSONObject()
        .put(Emailv31.Message.FROM, new JSONObject()
          .put("Email", sender)
          .put("Name", "pandora"))
        .put(Emailv31.Message.TO, new JSONArray()
          .put(new JSONObject()
            .put("Email", recipient)))
        .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
        .put(Emailv31.Message.TEXTPART,
            "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
        .put(Emailv31.Message.HTMLPART,
            "<h3>Dear passenger, welcome to Mailjet!</h3>"
            + "<br />May the delivery force be with you!")));


  try {
    // trigger the API call
    MailjetResponse response = client.post(email);
    // Read the response data and status
    System.out.println(response.getStatus());
    System.out.println(response.getData());
    return response;
  } catch (MailjetException e) {
    System.out.println("Mailjet Exception: " + e);
    return null;
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:32,代码来源:MailjetSender.java

示例4: sendEmailWithService

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
@Override
protected void sendEmailWithService(EmailWrapper wrapper) throws MailjetException, MailjetSocketTimeoutException {
    MailjetRequest email = parseToEmail(wrapper);
    MailjetClient mailjet = new MailjetClient(Config.MAILJET_APIKEY, Config.MAILJET_SECRETKEY);
    MailjetResponse response = mailjet.post(email);
    if (response.getStatus() != SUCCESS_CODE) {
        log.severe("Email failed to send: " + response.getData().toString());
    }
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:10,代码来源:MailjetService.java

示例5: main

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
public static void main (String[] args) throws MailjetException, MailjetSocketTimeoutException {
    MailjetClient client;
    MailjetRequest request;
    MailjetResponse response;
    
    client = new MailjetClient("", "");
    request = new MailjetRequest(Contact.resource)
                    .filter(Contact.LIMIT, 10);
    
    response = client.get(request);
    System.out.println(response.getStatus());
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:13,代码来源:Main.java

示例6: getString

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
public String getString(String key) throws MailjetException {
    try {
        return _rawResponse.getString(key);
    } catch (NullPointerException e) {
       throw new MailjetException("No entry found for key: " + key);
    }
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:8,代码来源:MailjetResponse.java

示例7: getInt

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
public int getInt(String key) throws MailjetException {
    try {
        return _rawResponse.getInt(key);
    } catch (NullPointerException e) {
        throw new MailjetException("No entry found for key: " + key);
    }
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:8,代码来源:MailjetResponse.java

示例8: getJSONArray

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
public JSONArray getJSONArray(String key) throws MailjetException {
    try {
        return _rawResponse.getJSONArray(key);
    } catch (NullPointerException e) { 
        throw new MailjetException("No entry found for key: " + key);
    }
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:8,代码来源:MailjetResponse.java

示例9: testSendv3

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
@Test
public void testSendv3() throws MailjetException, MalformedURLException, UnsupportedEncodingException, MailjetSocketTimeoutException {
    MailjetClient client;

    client = new MailjetClient("", "");
    client.setDebug(MailjetClient.NOCALL_DEBUG);

    System.out.println("TESTING: Send email with Send API v3.0");

    MailjetRequest request;
    MailjetResponse response;

    String fromEmail =  "[email protected]",
           fromName = "Mailjet Pilot",
           subject = "Your email flight plan!",
           textPart = "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
           htmlPart = "<h3>Dear passenger, welcome to Mailjet</h3><br/>May the delivery force be with you!",
           recipient = "[email protected]";

    // Simple contact GET request
    request = new MailjetRequest(Email.resource)
                    .property(Email.FROMEMAIL, fromEmail)
                    .property(Email.FROMNAME, fromName)
                    .property(Email.SUBJECT, subject)
                    .property(Email.TEXTPART, textPart)
                    .property(Email.HTMLPART, htmlPart)
                    .property(Email.RECIPIENTS, new JSONArray()
                    .put(new JSONObject()
                    .put(Email.EMAIL, recipient)));
    response = client.post(request);
    assertEquals(response.getString("url"), "https://api.mailjet.com/v3/send");
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:33,代码来源:MailjetClientTest.java

示例10: testSendv31

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
@Test
public void testSendv31() throws MailjetException, MalformedURLException, UnsupportedEncodingException, MailjetSocketTimeoutException {
    MailjetClient client;

    client = new MailjetClient("", "", new ClientOptions("v3.1"));
    client.setDebug(MailjetClient.NOCALL_DEBUG);

    System.out.println("TESTING: Send email with Send API v3.1");

    MailjetRequest request;
    MailjetResponse response;

    JSONObject message = new JSONObject();
    message.put(Emailv31.Message.FROM, new JSONObject()
    .put(Emailv31.Message.EMAIL, "[email protected]")
    .put(Emailv31.Message.NAME, "Mailjet Pilot"))
    .put(Emailv31.Message.SUBJECT, "Your email flight plan!")
    .put(Emailv31.Message.TEXTPART, "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
    .put(Emailv31.Message.HTMLPART, "<h3>Dear passenger, welcome to Mailjet</h3><br/>May the delivery force be with you!")
    .put(Emailv31.Message.TO, new JSONArray()
    .put(new JSONObject()
    .put(Emailv31.Message.EMAIL, "[email protected]")));

    // Simple contact GET request
    request = new MailjetRequest(Emailv31.resource).property(Emailv31.MESSAGES, (new JSONArray()).put(message));
    response = client.post(request);

    assertEquals(response.getString("url"), "https://api.mailjet.com/v3.1/send");
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:30,代码来源:MailjetClientTest.java

示例11: testEmailSend

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
@Test
public void testEmailSend() throws MailjetException, MailjetSocketTimeoutException {

    List<Person> recipients = new ArrayList<Person>() {
        {
            add(new Person("[email protected]", "Guillaume"));
            add(new Person("[email protected]", "Arnaud"));
            add(new Person("[email protected]", "Florent"));
        }
    };

    // We create a client
    MJEasyClient client = new MJEasyClient();
    client.setDebug(MJEasyClient.NOCALL_DEBUG);


    for (Person r : recipients) {
        // Create an email
        MailjetResponse response = client.email()
                .from("[email protected]")
                .to(r.email)
                .subject("Simple proposal")
                .text("Hi " + r.name + ",\n" +
                        "the idea is just for few very common operations to provide a higher level wrapper.\n" +
                        "\n-- \nFlorent")


                .send(); // And send it

        System.out.println(response);
        Assert.assertTrue(true);
    }

    // This what we get:
    // Response: {"Status":200,"Sent":[{"Email":"[email protected]","MessageID":16888522541389720}]}
    // Response: {"Status":200,"Sent":[{"Email":"[email protected]","MessageID":18014415886981635}]}
    // Response: {"Status":200,"Sent":[{"Email":"[email protected]","MessageID":18014415886982635}]}
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:39,代码来源:MJEasyClientTest.java

示例12: testSimpleGet

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
/**
 * Test of setDebug method, of class MailjetClient.
 * @throws com.mailjet.client.errors.MailjetException
 */
@Test
public void testSimpleGet() throws MailjetException, MailjetSocketTimeoutException {
    MailjetClient client;

    client = new MailjetClient("", "");
    client.setDebug(MailjetClient.NOCALL_DEBUG);

    System.out.println("TESTING: Simple GET");


    // Simple contact GET request
    MailjetRequest contacts;
    MailjetResponse response;

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


    assertEquals(response.getString("url"), "https://api.mailjet.com/v3/REST/contact");

}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:26,代码来源:MailjetClientTest.java

示例13: testActionGet

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
@Test
public void testActionGet() throws MailjetException, MalformedURLException, UnsupportedEncodingException, MailjetSocketTimeoutException {
    MailjetClient client;

    client = new MailjetClient("", "");
    client.setDebug(MailjetClient.NOCALL_DEBUG);

    System.out.println("TESTING: Simple Action with GET");


    // Simple contact GET request
    MailjetRequest contacts;
    MailjetResponse response;

    contacts = new MailjetRequest(ContactGetcontactslists.resource, existingContactID);

    response = client.get(contacts);


    assertEquals(response.getString("url"), "https://api.mailjet.com/v3/REST/contact/" + existingContactID + "/getcontactslists");
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:22,代码来源:MailjetClientTest.java

示例14: send

import com.mailjet.client.errors.MailjetException; //导入依赖的package包/类
/**
 * Send the email
 * @return a MailjetResponse instance
 * @throws MailjetException
 */
public MailjetResponse send() throws MailjetException, MailjetSocketTimeoutException {
    return client.getClient().post(request);
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:9,代码来源:MJEasyEmail.java


注:本文中的com.mailjet.client.errors.MailjetException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。