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


Java SendGrid.api方法代码示例

本文整理汇总了Java中com.sendgrid.SendGrid.api方法的典型用法代码示例。如果您正苦于以下问题:Java SendGrid.api方法的具体用法?Java SendGrid.api怎么用?Java SendGrid.api使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sendgrid.SendGrid的用法示例。


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

示例1: baselineExample

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void baselineExample() throws IOException {
  SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
  sg.addRequestHeader("X-Mock", "true");

  Request request = new Request();
  Mail helloWorld = buildHelloEmail();
  try {
    request.setMethod(Method.POST);
    request.setEndpoint("mail/send");
    request.setBody(helloWorld.build());
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:19,代码来源:Example.java

示例2: kitchenSinkExample

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void kitchenSinkExample() throws IOException {
  SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
  sg.addRequestHeader("X-Mock", "true");

  Request request = new Request();
  Mail kitchenSink = buildKitchenSink();
  try {
    request.setMethod(Method.POST);
    request.setEndpoint("mail/send");
    request.setBody(kitchenSink.build());
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:19,代码来源:Example.java

示例3: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.GET);
    request.setEndpoint("mail_settings");
    request.addQueryParam("limit", "1");
    request.addQueryParam("offset", "1");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:17,代码来源:GetAllMailSettings.java

示例4: sendEmail

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
private void sendEmail(Windowed<String> key, Long value) throws IOException {
  Email from = new Email("[email protected]");
  String subject = String.format("Anomaly detected for %s", value);
  Email to = new Email(System.getenv("TESTING_EMAIL"));
  Content content = generateContent(key, value);
  Mail mail = new Mail(from, subject, to, content);

  SendGrid sendGrid = new SendGrid(System.getenv("SENDGRID_API_KEY"));
  Request request = new Request();
  request.method = Method.POST;
  request.endpoint = "mail/send";
  request.body = mail.build();
  sendGrid.api(request);
}
 
开发者ID:kissaten,项目名称:kafka-streams-on-heroku,代码行数:15,代码来源:EmailSink.java

示例5: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.DELETE);
    request.setEndpoint("asm/groups/{group_id}/suppressions/{email}");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:15,代码来源:asm.java

示例6: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.GET);
    request.setEndpoint("mail_settings/bounce_purge");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:15,代码来源:GetBouncePurgeMailSettings.java

示例7: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.DELETE);
    request.setEndpoint("api_keys/{api_key_id}");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:15,代码来源:apikeys.java

示例8: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.PATCH);
    request.setEndpoint("mail_settings/bcc");
    request.setBody("{\"enabled\":false,\"email\":\"[email protected]\"}");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:16,代码来源:UpdateBCCMailSettings.java

示例9: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.GET);
    request.setEndpoint("mail_settings/plain_content");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:15,代码来源:GetPlainContentMailSettings.java

示例10: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.GET);
    request.setEndpoint("mail_settings/address_whitelist");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:15,代码来源:GetAddressWhitelistMailSettings.java

示例11: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.PATCH);
    request.setEndpoint("mail_settings/forward_spam");
    request.setBody("{\"enabled\":false,\"email\":\"\"}");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:16,代码来源:UpdateForwardSpamMailSettings.java

示例12: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.GET);
    request.setEndpoint("mail_settings/footer");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:15,代码来源:GetFooterMailSettings.java

示例13: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.GET);
    request.setEndpoint("mail_settings/spam_check");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:15,代码来源:GetSpamCheckMailSettings.java

示例14: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.PATCH);
    request.setEndpoint("mail_settings/address_whitelist");
    request.setBody("{\"list\":[\"[email protected]\",\"example.com\"],\"enabled\":true}");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:16,代码来源:UpdateAddressWhitelist.java

示例15: main

import com.sendgrid.SendGrid; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
  try {
    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    request.setMethod(Method.PATCH);
    request.setEndpoint("mail_settings/bounce_purge");
    request.setBody("{\"hard_bounces\":5,\"soft_bounces\":5,\"enabled\":true}");
    Response response = sg.api(request);
    System.out.println(response.getStatusCode());
    System.out.println(response.getBody());
    System.out.println(response.getHeaders());
  } catch (IOException ex) {
    throw ex;
  }
}
 
开发者ID:sendgrid,项目名称:sendgrid-java,代码行数:16,代码来源:UpdateBouncePurgeMailSettings.java


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