/** * Class api sets up the request to the SendGrid API, this is main interface. * @param request the request object. * @return the response object. * @throws IOException in case of a network error. */ public Response api(Request request) throws IOException { Request req = new Request(); req.setMethod(request.getMethod()); req.setBaseUri(this.host); req.setEndpoint("/" + version + "/" + request.getEndpoint()); req.setBody(request.getBody()); for (Map.Entry<String, String> header : this.requestHeaders.entrySet()) { req.addHeader(header.getKey(), header.getValue()); } for (Map.Entry<String, String> queryParam : request.getQueryParams().entrySet()) { req.addQueryParam(queryParam.getKey(), queryParam.getValue()); } return makeCall(req); }
/** * Class api sets up the request to the SendGrid API, this is main interface. * @param request the request object. * @return the response object. * @throws IOException in case of a network error. */ public Response api(Request request) throws IOException { Request req = new Request(); req.setMethod(request.getMethod()); req.setBaseUri(this.host); req.setEndpoint("/" + version + "/" + request.getEndpoint()); req.setBody(request.getBody()); for (Map.Entry<String, String> header : this.requestHeaders.entrySet()) { req.addHeader(header.getKey(), header.getValue()); } for (Map.Entry<String, String> queryParam : request.getQueryParams().entrySet()) { req.addQueryParam(queryParam.getKey(), queryParam.getValue()); } return makeCall(req); }