Skip to content

Commit

Permalink
fix(spec): fix wrong query parameters
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#330

Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Apr 5, 2022
1 parent 1c200a8 commit 878de03
Showing 1 changed file with 60 additions and 40 deletions.
100 changes: 60 additions & 40 deletions algoliasearch-core/com/algolia/search/SearchApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ public Call clearRulesAsync(
*/
private Call delCall(
String path,
String parameters,
Map<String, Object> parameters,
Object body,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Expand All @@ -1463,7 +1463,14 @@ private Call delCall(
Map<String, String> headers = new HashMap<String, String>();

if (parameters != null) {
queryParams.addAll(this.parameterToPair("parameters", parameters));
for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
queryParams.addAll(
this.parameterToPair(
parameter.getKey(),
parameter.getValue().toString()
)
);
}
}

headers.put("Accept", "application/json");
Expand All @@ -1481,7 +1488,7 @@ private Call delCall(

private Call delValidateBeforeCall(
String path,
String parameters,
Map<String, Object> parameters,
Object body,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Expand All @@ -1500,14 +1507,13 @@ private Call delValidateBeforeCall(
*
* @param path The path of the API endpoint to target, anything after the /1 needs to be
* specified. (required)
* @param parameters URL-encoded query string. Force some query parameters to be applied for each
* query made with this API key. (optional)
* @param parameters Query parameters to be applied to the current query. (optional)
* @param body The parameters to send with the custom request. (optional)
* @return Object
* @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public Object del(String path, String parameters, Object body)
public Object del(String path, Map<String, Object> parameters, Object body)
throws AlgoliaRuntimeException {
Call req = delValidateBeforeCall(path, parameters, body, null);
if (req instanceof CallEcho) {
Expand All @@ -1520,16 +1526,15 @@ public Object del(String path, String parameters, Object body)
}

public Object del(String path) throws AlgoliaRuntimeException {
return this.del(path, null, null);
return this.del(path, new HashMap<>(), null);
}

/**
* (asynchronously) This method allow you to send requests to the Algolia REST API.
*
* @param path The path of the API endpoint to target, anything after the /1 needs to be
* specified. (required)
* @param parameters URL-encoded query string. Force some query parameters to be applied for each
* query made with this API key. (optional)
* @param parameters Query parameters to be applied to the current query. (optional)
* @param body The parameters to send with the custom request. (optional)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
Expand All @@ -1538,7 +1543,7 @@ public Object del(String path) throws AlgoliaRuntimeException {
*/
public Call delAsync(
String path,
String parameters,
Map<String, Object> parameters,
Object body,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Expand Down Expand Up @@ -2309,7 +2314,7 @@ public Call deleteSynonymAsync(
*/
private Call getCall(
String path,
String parameters,
Map<String, Object> parameters,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Object bodyObj = null;
Expand All @@ -2321,7 +2326,14 @@ private Call getCall(
Map<String, String> headers = new HashMap<String, String>();

if (parameters != null) {
queryParams.addAll(this.parameterToPair("parameters", parameters));
for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
queryParams.addAll(
this.parameterToPair(
parameter.getKey(),
parameter.getValue().toString()
)
);
}
}

headers.put("Accept", "application/json");
Expand All @@ -2339,7 +2351,7 @@ private Call getCall(

private Call getValidateBeforeCall(
String path,
String parameters,
Map<String, Object> parameters,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
// verify the required parameter 'path' is set
Expand All @@ -2357,13 +2369,12 @@ private Call getValidateBeforeCall(
*
* @param path The path of the API endpoint to target, anything after the /1 needs to be
* specified. (required)
* @param parameters URL-encoded query string. Force some query parameters to be applied for each
* query made with this API key. (optional)
* @param parameters Query parameters to be applied to the current query. (optional)
* @return Object
* @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public Object get(String path, String parameters)
public Object get(String path, Map<String, Object> parameters)
throws AlgoliaRuntimeException {
Call req = getValidateBeforeCall(path, parameters, null);
if (req instanceof CallEcho) {
Expand All @@ -2376,24 +2387,23 @@ public Object get(String path, String parameters)
}

public Object get(String path) throws AlgoliaRuntimeException {
return this.get(path, null);
return this.get(path, new HashMap<>());
}

/**
* (asynchronously) This method allow you to send requests to the Algolia REST API.
*
* @param path The path of the API endpoint to target, anything after the /1 needs to be
* specified. (required)
* @param parameters URL-encoded query string. Force some query parameters to be applied for each
* query made with this API key. (optional)
* @param parameters Query parameters to be applied to the current query. (optional)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws AlgoliaRuntimeException If fail to process the API call, e.g. serializing the request
* body object
*/
public Call getAsync(
String path,
String parameters,
Map<String, Object> parameters,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Call call = getValidateBeforeCall(path, parameters, _callback);
Expand Down Expand Up @@ -4553,7 +4563,7 @@ public Call partialUpdateObjectAsync(
*/
private Call postCall(
String path,
String parameters,
Map<String, Object> parameters,
Object body,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Expand All @@ -4566,7 +4576,14 @@ private Call postCall(
Map<String, String> headers = new HashMap<String, String>();

if (parameters != null) {
queryParams.addAll(this.parameterToPair("parameters", parameters));
for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
queryParams.addAll(
this.parameterToPair(
parameter.getKey(),
parameter.getValue().toString()
)
);
}
}

headers.put("Accept", "application/json");
Expand All @@ -4584,7 +4601,7 @@ private Call postCall(

private Call postValidateBeforeCall(
String path,
String parameters,
Map<String, Object> parameters,
Object body,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Expand All @@ -4603,14 +4620,13 @@ private Call postValidateBeforeCall(
*
* @param path The path of the API endpoint to target, anything after the /1 needs to be
* specified. (required)
* @param parameters URL-encoded query string. Force some query parameters to be applied for each
* query made with this API key. (optional)
* @param parameters Query parameters to be applied to the current query. (optional)
* @param body The parameters to send with the custom request. (optional)
* @return Object
* @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public Object post(String path, String parameters, Object body)
public Object post(String path, Map<String, Object> parameters, Object body)
throws AlgoliaRuntimeException {
Call req = postValidateBeforeCall(path, parameters, body, null);
if (req instanceof CallEcho) {
Expand All @@ -4623,16 +4639,15 @@ public Object post(String path, String parameters, Object body)
}

public Object post(String path) throws AlgoliaRuntimeException {
return this.post(path, null, null);
return this.post(path, new HashMap<>(), null);
}

/**
* (asynchronously) This method allow you to send requests to the Algolia REST API.
*
* @param path The path of the API endpoint to target, anything after the /1 needs to be
* specified. (required)
* @param parameters URL-encoded query string. Force some query parameters to be applied for each
* query made with this API key. (optional)
* @param parameters Query parameters to be applied to the current query. (optional)
* @param body The parameters to send with the custom request. (optional)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
Expand All @@ -4641,7 +4656,7 @@ public Object post(String path) throws AlgoliaRuntimeException {
*/
public Call postAsync(
String path,
String parameters,
Map<String, Object> parameters,
Object body,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Expand All @@ -4660,7 +4675,7 @@ public Call postAsync(
*/
private Call putCall(
String path,
String parameters,
Map<String, Object> parameters,
Object body,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Expand All @@ -4673,7 +4688,14 @@ private Call putCall(
Map<String, String> headers = new HashMap<String, String>();

if (parameters != null) {
queryParams.addAll(this.parameterToPair("parameters", parameters));
for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
queryParams.addAll(
this.parameterToPair(
parameter.getKey(),
parameter.getValue().toString()
)
);
}
}

headers.put("Accept", "application/json");
Expand All @@ -4691,7 +4713,7 @@ private Call putCall(

private Call putValidateBeforeCall(
String path,
String parameters,
Map<String, Object> parameters,
Object body,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Expand All @@ -4710,14 +4732,13 @@ private Call putValidateBeforeCall(
*
* @param path The path of the API endpoint to target, anything after the /1 needs to be
* specified. (required)
* @param parameters URL-encoded query string. Force some query parameters to be applied for each
* query made with this API key. (optional)
* @param parameters Query parameters to be applied to the current query. (optional)
* @param body The parameters to send with the custom request. (optional)
* @return Object
* @throws AlgoliaRuntimeException If fail to call the API, e.g. server error or cannot
* deserialize the response body
*/
public Object put(String path, String parameters, Object body)
public Object put(String path, Map<String, Object> parameters, Object body)
throws AlgoliaRuntimeException {
Call req = putValidateBeforeCall(path, parameters, body, null);
if (req instanceof CallEcho) {
Expand All @@ -4730,16 +4751,15 @@ public Object put(String path, String parameters, Object body)
}

public Object put(String path) throws AlgoliaRuntimeException {
return this.put(path, null, null);
return this.put(path, new HashMap<>(), null);
}

/**
* (asynchronously) This method allow you to send requests to the Algolia REST API.
*
* @param path The path of the API endpoint to target, anything after the /1 needs to be
* specified. (required)
* @param parameters URL-encoded query string. Force some query parameters to be applied for each
* query made with this API key. (optional)
* @param parameters Query parameters to be applied to the current query. (optional)
* @param body The parameters to send with the custom request. (optional)
* @param _callback The callback to be executed when the API call finishes
* @return The request call
Expand All @@ -4748,7 +4768,7 @@ public Object put(String path) throws AlgoliaRuntimeException {
*/
public Call putAsync(
String path,
String parameters,
Map<String, Object> parameters,
Object body,
final ApiCallback<Object> _callback
) throws AlgoliaRuntimeException {
Expand Down

0 comments on commit 878de03

Please sign in to comment.