Adds another key/value pair to the Params map. Automatically converts all values to strings. amadeus.get("/foo/bar", Params.with("first_name", "John").and("last_name", "Smith")); @param key the key for the parameter to send to the API @param value the value for the given key @return
(@NonNull String key, Object value)
| 49 | * @return the Param object, allowing for convenient chaining |
| 50 | */ |
| 51 | public Params and(@NonNull String key, Object value) { |
| 52 | if (value instanceof List) { |
| 53 | @SuppressWarnings("unchecked") List<String> values = (List<String>) value; |
| 54 | put(key, String.join(",", values)); |
| 55 | } else { |
| 56 | put(key, String.valueOf(value)); |
| 57 | } |
| 58 | return this; |
| 59 | } |
| 60 | |
| 61 | // Converts params into a HTTP query string. |
| 62 | protected String toQueryString() { |
no outgoing calls