-
Notifications
You must be signed in to change notification settings - Fork 123
Provide a generic to http get methods #466
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
Conversation
6f0b0e3
to
7eadf5c
Compare
7eadf5c
to
82d32f9
Compare
Result<Task> result = | ||
httpClient.jsonHandler.decode( | ||
this.httpClient.get(urlPath), Result.class, Task.class); | ||
Result<Task> result = httpClient.get(urlPath, Result.class, Task.class); |
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.
I think you can return directly like you did in the other places :)
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.
I hesitate because it is a complex type and this is the line that generates the Type safety
warning so maybe it's better to remove it when the warning will be fix
src/main/java/com/meilisearch/sdk/http/response/BasicResponse.java
Outdated
Show resolved
Hide resolved
@@ -20,6 +20,6 @@ public boolean hasContent() { | |||
} | |||
|
|||
public byte[] getContentAsBytes() { | |||
return content.getBytes(); | |||
return ((String) content).getBytes(); |
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.
How can you ensure this content
will be castable to a String
?
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.
It should be, anyway I don't use this method maybe it's better to remove it? WDYT?
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.
Of course, if you don't use it, remove it! ;D
Result<Task> result = | ||
httpClient.jsonHandler.decode( | ||
this.httpClient.get(urlPath), Result.class, Task.class); | ||
Result<Task> result = httpClient.get(urlPath, Result.class, Task.class); |
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.
Same comment as I sent below :)
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.
Same I hesitate because it is a complex type and this is the line that generates the Type safety
warning
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.
🎉 🎉 🎉
Provide a generic to http post methods
Provide a generic to http put method
Provide a generic to http delete method
Pull Request
What does this PR do?
Most of the methods had to use the
jsonHandler
after the call to theget
method through the client. The purpose of this PR is to bypass this step to simplify the call to the get method via the client:became
Note:
This method still need a call to the
decode
method fromjsonHandler