本文整理汇总了Java中com.sendgrid.Response类的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Response类属于com.sendgrid包,在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: post
import com.sendgrid.Response; //导入依赖的package包/类
public static boolean post(JSONArray array) {
if (array != null) {
Client client = new Client();
Request request = new Request();
Map<String, String> requestHeaders = new HashMap<String, String>();
requestHeaders.put("Authorization", "Bearer " + apiKey);
request.headers = requestHeaders;
request.baseUri = baseURI;
request.endpoint = endpoint;
request.method = Method.POST;
request.body = array.toString();
try {
Response response = client.api(request);
return ((response.statusCode) + "").contains("20");
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
示例2: baselineExample
import com.sendgrid.Response; //导入依赖的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;
}
}
示例3: kitchenSinkExample
import com.sendgrid.Response; //导入依赖的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;
}
}
示例4: main
import com.sendgrid.Response; //导入依赖的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;
}
}
示例5: delete
import com.sendgrid.Response; //导入依赖的package包/类
private static void delete(Client client, Request request) throws IOException {
request.setMethod(Method.DELETE);
try {
Response response = client.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
}
}
示例6: main
import com.sendgrid.Response; //导入依赖的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.POST);
request.setEndpoint("api_keys");
request.setBody("{\"sample\":\"data\",\"scopes\":[\"mail.send\",\"alerts.create\",\"alerts.read\"],\"name\":\"My API Key\"}");
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;
}
}
示例7: main
import com.sendgrid.Response; //导入依赖的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/plain_content");
request.setBody("{\"enabled\":false}");
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;
}
}
示例8: main
import com.sendgrid.Response; //导入依赖的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;
}
}
示例9: main
import com.sendgrid.Response; //导入依赖的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;
}
}
示例10: main
import com.sendgrid.Response; //导入依赖的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/template");
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;
}
}
示例11: main
import com.sendgrid.Response; //导入依赖的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/footer");
request.setBody("{\"html_content\":\"...\",\"enabled\":true,\"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;
}
}
示例12: main
import com.sendgrid.Response; //导入依赖的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/template");
request.setBody("{\"html_content\":\"<% body %>\",\"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;
}
}
示例13: main
import com.sendgrid.Response; //导入依赖的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;
}
}
示例14: main
import com.sendgrid.Response; //导入依赖的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;
}
}
示例15: main
import com.sendgrid.Response; //导入依赖的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/spam_check");
request.setBody("{\"url\":\"url\",\"max_score\":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;
}
}