-
Notifications
You must be signed in to change notification settings - Fork 78
Update the request object with sensible defaults and access methods, #13 #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
50c0dcb
70876ae
05d2baa
e3ec8ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,19 +18,15 @@ public static void main(String[] args) throws IOException { | |
|
||
Request request = new Request(); | ||
request.baseUri = "api.sendgrid.com"; | ||
Map<String,String> requestHeaders = new HashMap<String, String>(); | ||
requestHeaders.put("Authorization", "Bearer " + System.getenv("SENDGRID_API_KEY")); | ||
request.headers = requestHeaders; | ||
request.getHeaders().put("Authorization", "Bearer " + System.getenv("SENDGRID_API_KEY")); | ||
|
||
Response response = new Response(); | ||
|
||
// GET Collection | ||
request.method = Method.GET; | ||
request.endpoint = "/v3/api_keys"; | ||
Map<String,String> queryParams = new HashMap<String, String>(); | ||
queryParams.put("limit", "100"); | ||
queryParams.put("offset", "0"); | ||
request.queryParams = queryParams; | ||
request.getQueryParams().put("limit", "100"); | ||
request.getQueryParams().put("offset", "0"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use a setter here instead? e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
try { | ||
response = client.api(request); | ||
System.out.println(response.statusCode); | ||
|
@@ -39,7 +35,7 @@ public static void main(String[] args) throws IOException { | |
} catch (IOException ex) { | ||
throw ex; | ||
} | ||
request.queryParams = null; | ||
request.getQueryParams().clear(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
// POST | ||
request.method = Method.POST; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a setter here instead?
e.g.
request.addHeader("Authorization", "Bearer " + System.getenv("SENDGRID_API_KEY"));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed