當前位置: 首頁>>代碼示例>>Java>>正文


Java Response類代碼示例

本文整理匯總了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;
}
 
開發者ID:faizan-ali,項目名稱:full-javaee-app,代碼行數:22,代碼來源:SendGridContacts.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:19,代碼來源:Example.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:19,代碼來源:Example.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:17,代碼來源:GetAllMailSettings.java

示例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;
  } 
}
 
開發者ID:sendgrid,項目名稱:java-http-client,代碼行數:11,代碼來源:Example.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:16,代碼來源:apikeys.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:16,代碼來源:UpdatePlainContentMailSettings.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:16,代碼來源:UpdateBCCMailSettings.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:15,代碼來源:GetPlainContentMailSettings.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:15,代碼來源:GetTemplateMailSettings.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:16,代碼來源:UpdateFooterMailSettings.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:16,代碼來源:UpdateTemplateMailSettings.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:15,代碼來源:GetFooterMailSettings.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:15,代碼來源:GetSpamCheckMailSettings.java

示例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;
  }
}
 
開發者ID:sendgrid,項目名稱:sendgrid-java,代碼行數:16,代碼來源:UpdateSpamCheckMailSettings.java


注:本文中的com.sendgrid.Response類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。