diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java index 0059add9a8..fb2c3272a7 100644 --- a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java @@ -1450,7 +1450,7 @@ public Call clearRulesAsync( */ private Call delCall( String path, - String parameters, + Map parameters, Object body, final ApiCallback _callback ) throws AlgoliaRuntimeException { @@ -1463,7 +1463,14 @@ private Call delCall( Map headers = new HashMap(); if (parameters != null) { - queryParams.addAll(this.parameterToPair("parameters", parameters)); + for (Map.Entry parameter : parameters.entrySet()) { + queryParams.addAll( + this.parameterToPair( + parameter.getKey(), + parameter.getValue().toString() + ) + ); + } } headers.put("Accept", "application/json"); @@ -1481,7 +1488,7 @@ private Call delCall( private Call delValidateBeforeCall( String path, - String parameters, + Map parameters, Object body, final ApiCallback _callback ) throws AlgoliaRuntimeException { @@ -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 parameters, Object body) throws AlgoliaRuntimeException { Call req = delValidateBeforeCall(path, parameters, body, null); if (req instanceof CallEcho) { @@ -1520,7 +1526,7 @@ 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); } /** @@ -1528,8 +1534,7 @@ public Object del(String path) throws AlgoliaRuntimeException { * * @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 @@ -1538,7 +1543,7 @@ public Object del(String path) throws AlgoliaRuntimeException { */ public Call delAsync( String path, - String parameters, + Map parameters, Object body, final ApiCallback _callback ) throws AlgoliaRuntimeException { @@ -2309,7 +2314,7 @@ public Call deleteSynonymAsync( */ private Call getCall( String path, - String parameters, + Map parameters, final ApiCallback _callback ) throws AlgoliaRuntimeException { Object bodyObj = null; @@ -2321,7 +2326,14 @@ private Call getCall( Map headers = new HashMap(); if (parameters != null) { - queryParams.addAll(this.parameterToPair("parameters", parameters)); + for (Map.Entry parameter : parameters.entrySet()) { + queryParams.addAll( + this.parameterToPair( + parameter.getKey(), + parameter.getValue().toString() + ) + ); + } } headers.put("Accept", "application/json"); @@ -2339,7 +2351,7 @@ private Call getCall( private Call getValidateBeforeCall( String path, - String parameters, + Map parameters, final ApiCallback _callback ) throws AlgoliaRuntimeException { // verify the required parameter 'path' is set @@ -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 parameters) throws AlgoliaRuntimeException { Call req = getValidateBeforeCall(path, parameters, null); if (req instanceof CallEcho) { @@ -2376,7 +2387,7 @@ 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<>()); } /** @@ -2384,8 +2395,7 @@ public Object get(String path) throws AlgoliaRuntimeException { * * @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 @@ -2393,7 +2403,7 @@ public Object get(String path) throws AlgoliaRuntimeException { */ public Call getAsync( String path, - String parameters, + Map parameters, final ApiCallback _callback ) throws AlgoliaRuntimeException { Call call = getValidateBeforeCall(path, parameters, _callback); @@ -4553,7 +4563,7 @@ public Call partialUpdateObjectAsync( */ private Call postCall( String path, - String parameters, + Map parameters, Object body, final ApiCallback _callback ) throws AlgoliaRuntimeException { @@ -4566,7 +4576,14 @@ private Call postCall( Map headers = new HashMap(); if (parameters != null) { - queryParams.addAll(this.parameterToPair("parameters", parameters)); + for (Map.Entry parameter : parameters.entrySet()) { + queryParams.addAll( + this.parameterToPair( + parameter.getKey(), + parameter.getValue().toString() + ) + ); + } } headers.put("Accept", "application/json"); @@ -4584,7 +4601,7 @@ private Call postCall( private Call postValidateBeforeCall( String path, - String parameters, + Map parameters, Object body, final ApiCallback _callback ) throws AlgoliaRuntimeException { @@ -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 parameters, Object body) throws AlgoliaRuntimeException { Call req = postValidateBeforeCall(path, parameters, body, null); if (req instanceof CallEcho) { @@ -4623,7 +4639,7 @@ 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); } /** @@ -4631,8 +4647,7 @@ public Object post(String path) throws AlgoliaRuntimeException { * * @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 @@ -4641,7 +4656,7 @@ public Object post(String path) throws AlgoliaRuntimeException { */ public Call postAsync( String path, - String parameters, + Map parameters, Object body, final ApiCallback _callback ) throws AlgoliaRuntimeException { @@ -4660,7 +4675,7 @@ public Call postAsync( */ private Call putCall( String path, - String parameters, + Map parameters, Object body, final ApiCallback _callback ) throws AlgoliaRuntimeException { @@ -4673,7 +4688,14 @@ private Call putCall( Map headers = new HashMap(); if (parameters != null) { - queryParams.addAll(this.parameterToPair("parameters", parameters)); + for (Map.Entry parameter : parameters.entrySet()) { + queryParams.addAll( + this.parameterToPair( + parameter.getKey(), + parameter.getValue().toString() + ) + ); + } } headers.put("Accept", "application/json"); @@ -4691,7 +4713,7 @@ private Call putCall( private Call putValidateBeforeCall( String path, - String parameters, + Map parameters, Object body, final ApiCallback _callback ) throws AlgoliaRuntimeException { @@ -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 parameters, Object body) throws AlgoliaRuntimeException { Call req = putValidateBeforeCall(path, parameters, body, null); if (req instanceof CallEcho) { @@ -4730,7 +4751,7 @@ 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); } /** @@ -4738,8 +4759,7 @@ public Object put(String path) throws AlgoliaRuntimeException { * * @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 @@ -4748,7 +4768,7 @@ public Object put(String path) throws AlgoliaRuntimeException { */ public Call putAsync( String path, - String parameters, + Map parameters, Object body, final ApiCallback _callback ) throws AlgoliaRuntimeException { diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts b/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts index 685b888d61..6a6d15b4ff 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/src/abtestingApi.ts @@ -74,10 +74,6 @@ export function createAbtestingApi( addABTestsRequest: AddABTestsRequest, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/abtests'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!addABTestsRequest) { throw new Error( 'Parameter `addABTestsRequest` is required when calling `addABTests`.' @@ -100,6 +96,10 @@ export function createAbtestingApi( ); } + const requestPath = '/2/abtests'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -122,24 +122,20 @@ export function createAbtestingApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param del.parameters - Query parameters to be applied to the current query. * @param del.body - The parameters to send with the custom request. */ del( { path, parameters, body }: DelProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `del`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'DELETE', @@ -168,19 +164,19 @@ export function createAbtestingApi( { id }: DeleteABTestProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/abtests/{id}'.replace( - '{id}', - encodeURIComponent(String(id)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!id) { throw new Error( 'Parameter `id` is required when calling `deleteABTest`.' ); } + const requestPath = '/2/abtests/{id}'.replace( + '{id}', + encodeURIComponent(id) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'DELETE', path: requestPath, @@ -202,23 +198,19 @@ export function createAbtestingApi( * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get.parameters - Query parameters to be applied to the current query. */ get( { path, parameters }: GetProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `get`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'GET', @@ -246,17 +238,17 @@ export function createAbtestingApi( { id }: GetABTestProps, requestOptions?: RequestOptions ): Promise { + if (!id) { + throw new Error('Parameter `id` is required when calling `getABTest`.'); + } + const requestPath = '/2/abtests/{id}'.replace( '{id}', - encodeURIComponent(String(id)) + encodeURIComponent(id) ); const headers: Headers = {}; const queryParameters: QueryParameters = {}; - if (!id) { - throw new Error('Parameter `id` is required when calling `getABTest`.'); - } - const request: Request = { method: 'GET', path: requestPath, @@ -317,24 +309,20 @@ export function createAbtestingApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param post.parameters - Query parameters to be applied to the current query. * @param post.body - The parameters to send with the custom request. */ post( { path, parameters, body }: PostProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `post`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'POST', @@ -358,24 +346,20 @@ export function createAbtestingApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param put.parameters - Query parameters to be applied to the current query. * @param put.body - The parameters to send with the custom request. */ put( { path, parameters, body }: PutProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `put`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'PUT', @@ -404,19 +388,19 @@ export function createAbtestingApi( { id }: StopABTestProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/abtests/{id}/stop'.replace( - '{id}', - encodeURIComponent(String(id)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!id) { throw new Error( 'Parameter `id` is required when calling `stopABTest`.' ); } + const requestPath = '/2/abtests/{id}/stop'.replace( + '{id}', + encodeURIComponent(id) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -442,9 +426,9 @@ export type DelProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -464,9 +448,9 @@ export type GetProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; }; export type GetABTestProps = { @@ -493,9 +477,9 @@ export type PostProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -508,9 +492,9 @@ export type PutProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts index 4582a1a0d3..231ab72a9d 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/src/analyticsApi.ts @@ -83,24 +83,20 @@ export function createAnalyticsApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param del.parameters - Query parameters to be applied to the current query. * @param del.body - The parameters to send with the custom request. */ del( { path, parameters, body }: DelProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `del`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'DELETE', @@ -124,23 +120,19 @@ export function createAnalyticsApi( * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get.parameters - Query parameters to be applied to the current query. */ get( { path, parameters }: GetProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `get`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'GET', @@ -171,16 +163,16 @@ export function createAnalyticsApi( { index, startDate, endDate, tags }: GetAverageClickPositionProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/clicks/averageClickPosition'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getAverageClickPosition`.' ); } + const requestPath = '/2/clicks/averageClickPosition'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -226,16 +218,16 @@ export function createAnalyticsApi( { index, startDate, endDate, tags }: GetClickPositionsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/clicks/positions'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getClickPositions`.' ); } + const requestPath = '/2/clicks/positions'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -281,16 +273,16 @@ export function createAnalyticsApi( { index, startDate, endDate, tags }: GetClickThroughRateProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/clicks/clickThroughRate'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getClickThroughRate`.' ); } + const requestPath = '/2/clicks/clickThroughRate'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -336,16 +328,16 @@ export function createAnalyticsApi( { index, startDate, endDate, tags }: GetConversationRateProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/conversions/conversionRate'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getConversationRate`.' ); } + const requestPath = '/2/conversions/conversionRate'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -391,16 +383,16 @@ export function createAnalyticsApi( { index, startDate, endDate, tags }: GetNoClickRateProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/searches/noClickRate'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getNoClickRate`.' ); } + const requestPath = '/2/searches/noClickRate'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -446,16 +438,16 @@ export function createAnalyticsApi( { index, startDate, endDate, tags }: GetNoResultsRateProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/searches/noResultRate'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getNoResultsRate`.' ); } + const requestPath = '/2/searches/noResultRate'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -501,16 +493,16 @@ export function createAnalyticsApi( { index, startDate, endDate, tags }: GetSearchesCountProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/searches/count'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getSearchesCount`.' ); } + const requestPath = '/2/searches/count'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -565,16 +557,16 @@ export function createAnalyticsApi( }: GetSearchesNoClicksProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/searches/noClicks'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getSearchesNoClicks`.' ); } + const requestPath = '/2/searches/noClicks'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -637,16 +629,16 @@ export function createAnalyticsApi( }: GetSearchesNoResultsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/searches/noResults'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getSearchesNoResults`.' ); } + const requestPath = '/2/searches/noResults'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -697,16 +689,16 @@ export function createAnalyticsApi( { index }: GetStatusProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/status'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getStatus`.' ); } + const requestPath = '/2/status'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -742,16 +734,16 @@ export function createAnalyticsApi( { index, startDate, endDate, limit, offset, tags }: GetTopCountriesProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/countries'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getTopCountries`.' ); } + const requestPath = '/2/countries'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -816,16 +808,16 @@ export function createAnalyticsApi( }: GetTopFilterAttributesProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/filters'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getTopFilterAttributes`.' ); } + const requestPath = '/2/filters'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -896,13 +888,6 @@ export function createAnalyticsApi( }: GetTopFilterForAttributeProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/filters/{attribute}'.replace( - '{attribute}', - encodeURIComponent(String(attribute)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!attribute) { throw new Error( 'Parameter `attribute` is required when calling `getTopFilterForAttribute`.' @@ -915,6 +900,13 @@ export function createAnalyticsApi( ); } + const requestPath = '/2/filters/{attribute}'.replace( + '{attribute}', + encodeURIComponent(attribute) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -983,16 +975,16 @@ export function createAnalyticsApi( }: GetTopFiltersNoResultsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/filters/noResults'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getTopFiltersNoResults`.' ); } + const requestPath = '/2/filters/noResults'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -1063,16 +1055,16 @@ export function createAnalyticsApi( }: GetTopHitsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/hits'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getTopHits`.' ); } + const requestPath = '/2/hits'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -1149,16 +1141,16 @@ export function createAnalyticsApi( }: GetTopSearchesProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/searches'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getTopSearches`.' ); } + const requestPath = '/2/searches'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -1224,16 +1216,16 @@ export function createAnalyticsApi( { index, startDate, endDate, tags }: GetUsersCountProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/2/users/count'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!index) { throw new Error( 'Parameter `index` is required when calling `getUsersCount`.' ); } + const requestPath = '/2/users/count'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (index !== undefined) { queryParameters.index = index.toString(); } @@ -1271,24 +1263,20 @@ export function createAnalyticsApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param post.parameters - Query parameters to be applied to the current query. * @param post.body - The parameters to send with the custom request. */ post( { path, parameters, body }: PostProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `post`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'POST', @@ -1312,24 +1300,20 @@ export function createAnalyticsApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param put.parameters - Query parameters to be applied to the current query. * @param put.body - The parameters to send with the custom request. */ put( { path, parameters, body }: PutProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `put`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'PUT', @@ -1357,9 +1341,9 @@ export type DelProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -1372,9 +1356,9 @@ export type GetProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; }; export type GetAverageClickPositionProps = { @@ -1798,9 +1782,9 @@ export type PostProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -1813,9 +1797,9 @@ export type PutProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts b/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts index ad1daf723f..775b52d74a 100644 --- a/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-insights/src/insightsApi.ts @@ -68,24 +68,20 @@ export function createInsightsApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param del.parameters - Query parameters to be applied to the current query. * @param del.body - The parameters to send with the custom request. */ del( { path, parameters, body }: DelProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `del`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'DELETE', @@ -109,23 +105,19 @@ export function createInsightsApi( * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get.parameters - Query parameters to be applied to the current query. */ get( { path, parameters }: GetProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `get`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'GET', @@ -148,24 +140,20 @@ export function createInsightsApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param post.parameters - Query parameters to be applied to the current query. * @param post.body - The parameters to send with the custom request. */ post( { path, parameters, body }: PostProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `post`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'POST', @@ -193,10 +181,6 @@ export function createInsightsApi( insightEvents: InsightEvents, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/events'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!insightEvents) { throw new Error( 'Parameter `insightEvents` is required when calling `pushEvents`.' @@ -209,6 +193,10 @@ export function createInsightsApi( ); } + const requestPath = '/1/events'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -231,24 +219,20 @@ export function createInsightsApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param put.parameters - Query parameters to be applied to the current query. * @param put.body - The parameters to send with the custom request. */ put( { path, parameters, body }: PutProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `put`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'PUT', @@ -276,9 +260,9 @@ export type DelProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -291,9 +275,9 @@ export type GetProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; }; export type PostProps = { @@ -302,9 +286,9 @@ export type PostProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -317,9 +301,9 @@ export type PutProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts b/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts index b535874e57..2cabf74731 100644 --- a/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/src/personalizationApi.ts @@ -68,24 +68,20 @@ export function createPersonalizationApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param del.parameters - Query parameters to be applied to the current query. * @param del.body - The parameters to send with the custom request. */ del( { path, parameters, body }: DelProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `del`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'DELETE', @@ -114,19 +110,19 @@ export function createPersonalizationApi( { userToken }: DeleteUserProfileProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/profiles/{userToken}'.replace( - '{userToken}', - encodeURIComponent(String(userToken)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!userToken) { throw new Error( 'Parameter `userToken` is required when calling `deleteUserProfile`.' ); } + const requestPath = '/1/profiles/{userToken}'.replace( + '{userToken}', + encodeURIComponent(userToken) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'DELETE', path: requestPath, @@ -148,23 +144,19 @@ export function createPersonalizationApi( * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get.parameters - Query parameters to be applied to the current query. */ get( { path, parameters }: GetProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `get`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'GET', @@ -219,19 +211,19 @@ export function createPersonalizationApi( { userToken }: GetUserTokenProfileProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/profiles/personalization/{userToken}'.replace( - '{userToken}', - encodeURIComponent(String(userToken)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!userToken) { throw new Error( 'Parameter `userToken` is required when calling `getUserTokenProfile`.' ); } + const requestPath = '/1/profiles/personalization/{userToken}'.replace( + '{userToken}', + encodeURIComponent(userToken) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'GET', path: requestPath, @@ -253,24 +245,20 @@ export function createPersonalizationApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param post.parameters - Query parameters to be applied to the current query. * @param post.body - The parameters to send with the custom request. */ post( { path, parameters, body }: PostProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `post`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'POST', @@ -294,24 +282,20 @@ export function createPersonalizationApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param put.parameters - Query parameters to be applied to the current query. * @param put.body - The parameters to send with the custom request. */ put( { path, parameters, body }: PutProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `put`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'PUT', @@ -339,10 +323,6 @@ export function createPersonalizationApi( personalizationStrategyParams: PersonalizationStrategyParams, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/strategies/personalization'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!personalizationStrategyParams) { throw new Error( 'Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.' @@ -365,6 +345,10 @@ export function createPersonalizationApi( ); } + const requestPath = '/1/strategies/personalization'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -391,9 +375,9 @@ export type DelProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -413,9 +397,9 @@ export type GetProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; }; export type GetUserTokenProfileProps = { @@ -431,9 +415,9 @@ export type PostProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -446,9 +430,9 @@ export type PutProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts b/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts index c1e4b7f3b6..bd2f25a0a4 100644 --- a/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-predict/src/predictApi.ts @@ -62,24 +62,20 @@ export function createPredictApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param del.parameters - Query parameters to be applied to the current query. * @param del.body - The parameters to send with the custom request. */ del( { path, parameters, body }: DelProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `del`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'DELETE', @@ -109,13 +105,6 @@ export function createPredictApi(options: CreateClientOptions) { { userID, params }: FetchUserProfileProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/users/{userID}/fetch'.replace( - '{userID}', - encodeURIComponent(String(userID)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!userID) { throw new Error( 'Parameter `userID` is required when calling `fetchUserProfile`.' @@ -128,6 +117,13 @@ export function createPredictApi(options: CreateClientOptions) { ); } + const requestPath = '/1/users/{userID}/fetch'.replace( + '{userID}', + encodeURIComponent(userID) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -150,23 +146,19 @@ export function createPredictApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get.parameters - Query parameters to be applied to the current query. */ get( { path, parameters }: GetProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `get`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'GET', @@ -189,24 +181,20 @@ export function createPredictApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param post.parameters - Query parameters to be applied to the current query. * @param post.body - The parameters to send with the custom request. */ post( { path, parameters, body }: PostProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `post`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'POST', @@ -230,24 +218,20 @@ export function createPredictApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param put.parameters - Query parameters to be applied to the current query. * @param put.body - The parameters to send with the custom request. */ put( { path, parameters, body }: PutProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `put`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'PUT', @@ -275,9 +259,9 @@ export type DelProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -298,9 +282,9 @@ export type GetProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; }; export type PostProps = { @@ -309,9 +293,9 @@ export type PostProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -324,9 +308,9 @@ export type PutProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts index 82335a72c6..4de6a6e909 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/src/querySuggestionsApi.ts @@ -74,16 +74,16 @@ export function createQuerySuggestionsApi( querySuggestionsIndexWithIndexParam: QuerySuggestionsIndexWithIndexParam, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/configs'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!querySuggestionsIndexWithIndexParam) { throw new Error( 'Parameter `querySuggestionsIndexWithIndexParam` is required when calling `createConfig`.' ); } + const requestPath = '/1/configs'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -106,24 +106,20 @@ export function createQuerySuggestionsApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param del.parameters - Query parameters to be applied to the current query. * @param del.body - The parameters to send with the custom request. */ del( { path, parameters, body }: DelProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `del`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'DELETE', @@ -152,19 +148,19 @@ export function createQuerySuggestionsApi( { indexName }: DeleteConfigProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/configs/{indexName}'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `deleteConfig`.' ); } + const requestPath = '/1/configs/{indexName}'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'DELETE', path: requestPath, @@ -186,23 +182,19 @@ export function createQuerySuggestionsApi( * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get.parameters - Query parameters to be applied to the current query. */ get( { path, parameters }: GetProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `get`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'GET', @@ -257,19 +249,19 @@ export function createQuerySuggestionsApi( { indexName }: GetConfigProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/configs/{indexName}'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `getConfig`.' ); } + const requestPath = '/1/configs/{indexName}'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'GET', path: requestPath, @@ -296,19 +288,19 @@ export function createQuerySuggestionsApi( { indexName }: GetConfigStatusProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/configs/{indexName}/status'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `getConfigStatus`.' ); } + const requestPath = '/1/configs/{indexName}/status'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'GET', path: requestPath, @@ -335,19 +327,19 @@ export function createQuerySuggestionsApi( { indexName }: GetLogFileProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/logs/{indexName}'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `getLogFile`.' ); } + const requestPath = '/1/logs/{indexName}'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'GET', path: requestPath, @@ -369,24 +361,20 @@ export function createQuerySuggestionsApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param post.parameters - Query parameters to be applied to the current query. * @param post.body - The parameters to send with the custom request. */ post( { path, parameters, body }: PostProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `post`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'POST', @@ -410,24 +398,20 @@ export function createQuerySuggestionsApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param put.parameters - Query parameters to be applied to the current query. * @param put.body - The parameters to send with the custom request. */ put( { path, parameters, body }: PutProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `put`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'PUT', @@ -457,13 +441,6 @@ export function createQuerySuggestionsApi( { indexName, querySuggestionsIndexParam }: UpdateConfigProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/configs/{indexName}'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `updateConfig`.' @@ -482,6 +459,13 @@ export function createQuerySuggestionsApi( ); } + const requestPath = '/1/configs/{indexName}'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'PUT', path: requestPath, @@ -508,9 +492,9 @@ export type DelProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -530,9 +514,9 @@ export type GetProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; }; export type GetConfigProps = { @@ -562,9 +546,9 @@ export type PostProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -577,9 +561,9 @@ export type PutProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts index 1ab80edd53..e5d4f59e4b 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/src/searchApi.ts @@ -148,10 +148,6 @@ export function createSearchApi(options: CreateClientOptions) { apiKey: ApiKey, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/keys'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!apiKey) { throw new Error( 'Parameter `apiKey` is required when calling `addApiKey`.' @@ -164,6 +160,10 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/keys'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -193,12 +193,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, objectID, body }: AddOrUpdateObjectProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/{objectID}' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{objectID}', encodeURIComponent(String(objectID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `addOrUpdateObject`.' @@ -217,6 +211,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/{objectID}' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{objectID}', encodeURIComponent(objectID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'PUT', path: requestPath, @@ -243,16 +243,16 @@ export function createSearchApi(options: CreateClientOptions) { source: Source, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/security/sources/append'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!source) { throw new Error( 'Parameter `source` is required when calling `appendSource`.' ); } + const requestPath = '/1/security/sources/append'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -281,10 +281,6 @@ export function createSearchApi(options: CreateClientOptions) { { xAlgoliaUserID, assignUserIdParams }: AssignUserIdProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/clusters/mapping'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!xAlgoliaUserID) { throw new Error( 'Parameter `xAlgoliaUserID` is required when calling `assignUserId`.' @@ -303,6 +299,10 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/clusters/mapping'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (xAlgoliaUserID !== undefined) { queryParameters['X-Algolia-User-ID'] = xAlgoliaUserID.toString(); } @@ -335,13 +335,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, batchWriteParams }: BatchProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/batch'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `batch`.' @@ -354,6 +347,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/batch'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -382,10 +382,6 @@ export function createSearchApi(options: CreateClientOptions) { { xAlgoliaUserID, batchAssignUserIdsParams }: BatchAssignUserIdsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/clusters/mapping/batch'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!xAlgoliaUserID) { throw new Error( 'Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.' @@ -409,6 +405,10 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/clusters/mapping/batch'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (xAlgoliaUserID !== undefined) { queryParameters['X-Algolia-User-ID'] = xAlgoliaUserID.toString(); } @@ -444,13 +444,6 @@ export function createSearchApi(options: CreateClientOptions) { }: BatchDictionaryEntriesProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/dictionaries/{dictionaryName}/batch'.replace( - '{dictionaryName}', - encodeURIComponent(String(dictionaryName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!dictionaryName) { throw new Error( 'Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.' @@ -469,6 +462,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/dictionaries/{dictionaryName}/batch'.replace( + '{dictionaryName}', + encodeURIComponent(dictionaryName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -504,13 +504,6 @@ export function createSearchApi(options: CreateClientOptions) { }: BatchRulesProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/rules/batch'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `batchRules`.' @@ -523,6 +516,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/rules/batch'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (forwardToReplicas !== undefined) { queryParameters.forwardToReplicas = forwardToReplicas.toString(); } @@ -559,19 +559,19 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, browseRequest }: BrowseProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/browse'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `browse`.' ); } + const requestPath = '/1/indexes/{indexName}/browse'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -600,19 +600,19 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, forwardToReplicas }: ClearAllSynonymsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/synonyms/clear'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `clearAllSynonyms`.' ); } + const requestPath = '/1/indexes/{indexName}/synonyms/clear'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (forwardToReplicas !== undefined) { queryParameters.forwardToReplicas = forwardToReplicas.toString(); } @@ -643,19 +643,19 @@ export function createSearchApi(options: CreateClientOptions) { { indexName }: ClearObjectsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/clear'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `clearObjects`.' ); } + const requestPath = '/1/indexes/{indexName}/clear'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -683,19 +683,19 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, forwardToReplicas }: ClearRulesProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/rules/clear'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `clearRules`.' ); } + const requestPath = '/1/indexes/{indexName}/rules/clear'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (forwardToReplicas !== undefined) { queryParameters.forwardToReplicas = forwardToReplicas.toString(); } @@ -721,24 +721,20 @@ export function createSearchApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param del.parameters - Query parameters to be applied to the current query. * @param del.body - The parameters to send with the custom request. */ del( { path, parameters, body }: DelProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `del`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'DELETE', @@ -767,19 +763,19 @@ export function createSearchApi(options: CreateClientOptions) { { key }: DeleteApiKeyProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/keys/{key}'.replace( - '{key}', - encodeURIComponent(String(key)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!key) { throw new Error( 'Parameter `key` is required when calling `deleteApiKey`.' ); } + const requestPath = '/1/keys/{key}'.replace( + '{key}', + encodeURIComponent(key) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'DELETE', path: requestPath, @@ -807,13 +803,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, searchParams }: DeleteByProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/deleteByQuery'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `deleteBy`.' @@ -826,6 +815,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/deleteByQuery'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -853,19 +849,19 @@ export function createSearchApi(options: CreateClientOptions) { { indexName }: DeleteIndexProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `deleteIndex`.' ); } + const requestPath = '/1/indexes/{indexName}'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'DELETE', path: requestPath, @@ -893,12 +889,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, objectID }: DeleteObjectProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/{objectID}' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{objectID}', encodeURIComponent(String(objectID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `deleteObject`.' @@ -911,6 +901,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/{objectID}' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{objectID}', encodeURIComponent(objectID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'DELETE', path: requestPath, @@ -939,12 +935,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, objectID, forwardToReplicas }: DeleteRuleProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/rules/{objectID}' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{objectID}', encodeURIComponent(String(objectID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `deleteRule`.' @@ -957,6 +947,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/rules/{objectID}' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{objectID}', encodeURIComponent(objectID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (forwardToReplicas !== undefined) { queryParameters.forwardToReplicas = forwardToReplicas.toString(); } @@ -987,19 +983,19 @@ export function createSearchApi(options: CreateClientOptions) { { source }: DeleteSourceProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/security/sources/{source}'.replace( - '{source}', - encodeURIComponent(String(source)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!source) { throw new Error( 'Parameter `source` is required when calling `deleteSource`.' ); } + const requestPath = '/1/security/sources/{source}'.replace( + '{source}', + encodeURIComponent(source) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'DELETE', path: requestPath, @@ -1028,12 +1024,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, objectID, forwardToReplicas }: DeleteSynonymProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{objectID}', encodeURIComponent(String(objectID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `deleteSynonym`.' @@ -1046,6 +1036,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{objectID}', encodeURIComponent(objectID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (forwardToReplicas !== undefined) { queryParameters.forwardToReplicas = forwardToReplicas.toString(); } @@ -1071,23 +1067,19 @@ export function createSearchApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get.parameters - Query parameters to be applied to the current query. */ get( { path, parameters }: GetProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `get`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'GET', @@ -1115,19 +1107,19 @@ export function createSearchApi(options: CreateClientOptions) { { key }: GetApiKeyProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/keys/{key}'.replace( - '{key}', - encodeURIComponent(String(key)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!key) { throw new Error( 'Parameter `key` is required when calling `getApiKey`.' ); } + const requestPath = '/1/keys/{key}'.replace( + '{key}', + encodeURIComponent(key) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'GET', path: requestPath, @@ -1259,12 +1251,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, objectID, attributesToRetrieve }: GetObjectProps, requestOptions?: RequestOptions ): Promise<{ [key: string]: string }> { - const requestPath = '/1/indexes/{indexName}/{objectID}' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{objectID}', encodeURIComponent(String(objectID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `getObject`.' @@ -1277,6 +1263,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/{objectID}' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{objectID}', encodeURIComponent(objectID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (attributesToRetrieve !== undefined) { queryParameters.attributesToRetrieve = attributesToRetrieve.toString(); } @@ -1306,16 +1298,16 @@ export function createSearchApi(options: CreateClientOptions) { getObjectsParams: GetObjectsParams, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/*/objects'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!getObjectsParams) { throw new Error( 'Parameter `getObjectsParams` is required when calling `getObjects`.' ); } + const requestPath = '/1/indexes/*/objects'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -1344,12 +1336,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, objectID }: GetRuleProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/rules/{objectID}' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{objectID}', encodeURIComponent(String(objectID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `getRule`.' @@ -1362,6 +1348,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/rules/{objectID}' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{objectID}', encodeURIComponent(objectID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'GET', path: requestPath, @@ -1388,19 +1380,19 @@ export function createSearchApi(options: CreateClientOptions) { { indexName }: GetSettingsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/settings'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `getSettings`.' ); } + const requestPath = '/1/indexes/{indexName}/settings'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'GET', path: requestPath, @@ -1453,12 +1445,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, objectID }: GetSynonymProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{objectID}', encodeURIComponent(String(objectID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `getSynonym`.' @@ -1471,6 +1457,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{objectID}', encodeURIComponent(objectID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'GET', path: requestPath, @@ -1498,12 +1490,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, taskID }: GetTaskProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/task/{taskID}' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{taskID}', encodeURIComponent(String(taskID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `getTask`.' @@ -1516,6 +1502,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/task/{taskID}' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{taskID}', encodeURIComponent(taskID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'GET', path: requestPath, @@ -1569,19 +1561,19 @@ export function createSearchApi(options: CreateClientOptions) { { userID }: GetUserIdProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/clusters/mapping/{userID}'.replace( - '{userID}', - encodeURIComponent(String(userID)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!userID) { throw new Error( 'Parameter `userID` is required when calling `getUserId`.' ); } + const requestPath = '/1/clusters/mapping/{userID}'.replace( + '{userID}', + encodeURIComponent(userID) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'GET', path: requestPath, @@ -1766,16 +1758,16 @@ export function createSearchApi(options: CreateClientOptions) { batchParams: BatchParams, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/*/batch'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!batchParams) { throw new Error( 'Parameter `batchParams` is required when calling `multipleBatch`.' ); } + const requestPath = '/1/indexes/*/batch'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -1802,10 +1794,6 @@ export function createSearchApi(options: CreateClientOptions) { multipleQueriesParams: MultipleQueriesParams, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/*/queries'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!multipleQueriesParams) { throw new Error( 'Parameter `multipleQueriesParams` is required when calling `multipleQueries`.' @@ -1818,6 +1806,10 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/*/queries'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -1846,13 +1838,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, operationIndexParams }: OperationIndexProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/operation'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `operationIndex`.' @@ -1876,6 +1861,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/operation'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -1911,12 +1903,6 @@ export function createSearchApi(options: CreateClientOptions) { }: PartialUpdateObjectProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/{objectID}/partial' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{objectID}', encodeURIComponent(String(objectID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `partialUpdateObject`.' @@ -1935,6 +1921,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/{objectID}/partial' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{objectID}', encodeURIComponent(objectID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (createIfNotExists !== undefined) { queryParameters.createIfNotExists = createIfNotExists.toString(); } @@ -1961,24 +1953,20 @@ export function createSearchApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param post.parameters - Query parameters to be applied to the current query. * @param post.body - The parameters to send with the custom request. */ post( { path, parameters, body }: PostProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `post`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'POST', @@ -2002,24 +1990,20 @@ export function createSearchApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param put.parameters - Query parameters to be applied to the current query. * @param put.body - The parameters to send with the custom request. */ put( { path, parameters, body }: PutProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `put`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'PUT', @@ -2048,19 +2032,19 @@ export function createSearchApi(options: CreateClientOptions) { { userID }: RemoveUserIdProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/clusters/mapping/{userID}'.replace( - '{userID}', - encodeURIComponent(String(userID)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!userID) { throw new Error( 'Parameter `userID` is required when calling `removeUserId`.' ); } + const requestPath = '/1/clusters/mapping/{userID}'.replace( + '{userID}', + encodeURIComponent(userID) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'DELETE', path: requestPath, @@ -2087,16 +2071,16 @@ export function createSearchApi(options: CreateClientOptions) { { source }: ReplaceSourcesProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/security/sources'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!source) { throw new Error( 'Parameter `source` is required when calling `replaceSources`.' ); } + const requestPath = '/1/security/sources'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'PUT', path: requestPath, @@ -2124,19 +2108,19 @@ export function createSearchApi(options: CreateClientOptions) { { key }: RestoreApiKeyProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/keys/{key}/restore'.replace( - '{key}', - encodeURIComponent(String(key)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!key) { throw new Error( 'Parameter `key` is required when calling `restoreApiKey`.' ); } + const requestPath = '/1/keys/{key}/restore'.replace( + '{key}', + encodeURIComponent(key) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -2164,13 +2148,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, body }: SaveObjectProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `saveObject`.' @@ -2183,6 +2160,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -2213,12 +2197,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, objectID, rule, forwardToReplicas }: SaveRuleProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/rules/{objectID}' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{objectID}', encodeURIComponent(String(objectID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `saveRule`.' @@ -2248,6 +2226,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/rules/{objectID}' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{objectID}', encodeURIComponent(objectID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (forwardToReplicas !== undefined) { queryParameters.forwardToReplicas = forwardToReplicas.toString(); } @@ -2282,12 +2266,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, objectID, synonymHit, forwardToReplicas }: SaveSynonymProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{objectID}', encodeURIComponent(String(objectID))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `saveSynonym`.' @@ -2312,6 +2290,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{objectID}', encodeURIComponent(objectID)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (forwardToReplicas !== undefined) { queryParameters.forwardToReplicas = forwardToReplicas.toString(); } @@ -2351,13 +2335,6 @@ export function createSearchApi(options: CreateClientOptions) { }: SaveSynonymsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/synonyms/batch'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `saveSynonyms`.' @@ -2370,6 +2347,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/synonyms/batch'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (forwardToReplicas !== undefined) { queryParameters.forwardToReplicas = forwardToReplicas.toString(); } @@ -2407,13 +2391,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, searchParams }: SearchProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/query'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `search`.' @@ -2426,6 +2403,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/query'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -2457,13 +2441,6 @@ export function createSearchApi(options: CreateClientOptions) { }: SearchDictionaryEntriesProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/dictionaries/{dictionaryName}/search'.replace( - '{dictionaryName}', - encodeURIComponent(String(dictionaryName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!dictionaryName) { throw new Error( 'Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.' @@ -2482,6 +2459,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/dictionaries/{dictionaryName}/search'.replace( + '{dictionaryName}', + encodeURIComponent(dictionaryName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -2515,12 +2499,6 @@ export function createSearchApi(options: CreateClientOptions) { }: SearchForFacetValuesProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/facets/{facetName}/query' - .replace('{indexName}', encodeURIComponent(String(indexName))) - .replace('{facetName}', encodeURIComponent(String(facetName))); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `searchForFacetValues`.' @@ -2533,6 +2511,12 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/facets/{facetName}/query' + .replace('{indexName}', encodeURIComponent(indexName)) + .replace('{facetName}', encodeURIComponent(facetName)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -2561,13 +2545,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, searchRulesParams }: SearchRulesProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/rules/search'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `searchRules`.' @@ -2580,6 +2557,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/rules/search'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -2611,19 +2595,19 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, query, type, page, hitsPerPage }: SearchSynonymsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/synonyms/search'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `searchSynonyms`.' ); } + const requestPath = '/1/indexes/{indexName}/synonyms/search'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (query !== undefined) { queryParameters.query = query.toString(); } @@ -2665,10 +2649,6 @@ export function createSearchApi(options: CreateClientOptions) { searchUserIdsParams: SearchUserIdsParams, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/clusters/mapping/search'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!searchUserIdsParams) { throw new Error( 'Parameter `searchUserIdsParams` is required when calling `searchUserIds`.' @@ -2681,6 +2661,10 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/clusters/mapping/search'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -2707,10 +2691,6 @@ export function createSearchApi(options: CreateClientOptions) { dictionarySettingsParams: DictionarySettingsParams, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/dictionaries/*/settings'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!dictionarySettingsParams) { throw new Error( 'Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.' @@ -2723,6 +2703,10 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/dictionaries/*/settings'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'PUT', path: requestPath, @@ -2752,13 +2736,6 @@ export function createSearchApi(options: CreateClientOptions) { { indexName, indexSettings, forwardToReplicas }: SetSettingsProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/{indexName}/settings'.replace( - '{indexName}', - encodeURIComponent(String(indexName)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!indexName) { throw new Error( 'Parameter `indexName` is required when calling `setSettings`.' @@ -2771,6 +2748,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/{indexName}/settings'.replace( + '{indexName}', + encodeURIComponent(indexName) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + if (forwardToReplicas !== undefined) { queryParameters.forwardToReplicas = forwardToReplicas.toString(); } @@ -2803,13 +2787,6 @@ export function createSearchApi(options: CreateClientOptions) { { key, apiKey }: UpdateApiKeyProps, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/keys/{key}'.replace( - '{key}', - encodeURIComponent(String(key)) - ); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!key) { throw new Error( 'Parameter `key` is required when calling `updateApiKey`.' @@ -2828,6 +2805,13 @@ export function createSearchApi(options: CreateClientOptions) { ); } + const requestPath = '/1/keys/{key}'.replace( + '{key}', + encodeURIComponent(key) + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'PUT', path: requestPath, @@ -2954,9 +2938,9 @@ export type DelProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -3039,9 +3023,9 @@ export type GetProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; }; export type GetApiKeyProps = { @@ -3192,9 +3176,9 @@ export type PostProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -3207,9 +3191,9 @@ export type PutProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts b/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts index 80067aac33..71369094c8 100644 --- a/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts +++ b/clients/algoliasearch-client-javascript/packages/client-sources/src/sourcesApi.ts @@ -66,24 +66,20 @@ export function createSourcesApi( * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param del.parameters - Query parameters to be applied to the current query. * @param del.body - The parameters to send with the custom request. */ del( { path, parameters, body }: DelProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `del`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'DELETE', @@ -107,23 +103,19 @@ export function createSourcesApi( * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get.parameters - Query parameters to be applied to the current query. */ get( { path, parameters }: GetProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `get`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'GET', @@ -146,24 +138,20 @@ export function createSourcesApi( * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param post.parameters - Query parameters to be applied to the current query. * @param post.body - The parameters to send with the custom request. */ post( { path, parameters, body }: PostProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `post`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'POST', @@ -191,10 +179,6 @@ export function createSourcesApi( postURLJob: PostURLJob, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/ingest/url'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!postURLJob) { throw new Error( 'Parameter `postURLJob` is required when calling `postIngestUrl`.' @@ -217,6 +201,10 @@ export function createSourcesApi( ); } + const requestPath = '/1/ingest/url'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -239,24 +227,20 @@ export function createSourcesApi( * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param put.parameters - Query parameters to be applied to the current query. * @param put.body - The parameters to send with the custom request. */ put( { path, parameters, body }: PutProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `put`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'PUT', @@ -284,9 +268,9 @@ export type DelProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -299,9 +283,9 @@ export type GetProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; }; export type PostProps = { @@ -310,9 +294,9 @@ export type PostProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -325,9 +309,9 @@ export type PutProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts b/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts index 3c3118a3d1..eb84c828e6 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/src/recommendApi.ts @@ -88,24 +88,20 @@ export function createRecommendApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param del - The del object. * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param del.parameters - Query parameters to be applied to the current query. * @param del.body - The parameters to send with the custom request. */ del( { path, parameters, body }: DelProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `del`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'DELETE', @@ -129,23 +125,19 @@ export function createRecommendApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param get - The get object. * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param get.parameters - Query parameters to be applied to the current query. */ get( { path, parameters }: GetProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `get`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'GET', @@ -172,10 +164,6 @@ export function createRecommendApi(options: CreateClientOptions) { getRecommendationsParams: GetRecommendationsParams, requestOptions?: RequestOptions ): Promise { - const requestPath = '/1/indexes/*/recommendations'; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!getRecommendationsParams) { throw new Error( 'Parameter `getRecommendationsParams` is required when calling `getRecommendations`.' @@ -188,6 +176,10 @@ export function createRecommendApi(options: CreateClientOptions) { ); } + const requestPath = '/1/indexes/*/recommendations'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + const request: Request = { method: 'POST', path: requestPath, @@ -210,24 +202,20 @@ export function createRecommendApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param post - The post object. * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param post.parameters - Query parameters to be applied to the current query. * @param post.body - The parameters to send with the custom request. */ post( { path, parameters, body }: PostProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `post`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'POST', @@ -251,24 +239,20 @@ export function createRecommendApi(options: CreateClientOptions) { * @summary Send requests to the Algolia REST API. * @param put - The put object. * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified. - * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * @param put.parameters - Query parameters to be applied to the current query. * @param put.body - The parameters to send with the custom request. */ put( { path, parameters, body }: PutProps, requestOptions?: RequestOptions ): Promise> { - const requestPath = '/1{path}'.replace('{path}', String(path)); - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - if (!path) { throw new Error('Parameter `path` is required when calling `put`.'); } - if (parameters !== undefined) { - queryParameters.parameters = parameters.toString(); - } + const requestPath = '/1{path}'.replace('{path}', path); + const headers: Headers = {}; + const queryParameters: QueryParameters = parameters || {}; const request: Request = { method: 'PUT', @@ -296,9 +280,9 @@ export type DelProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -311,9 +295,9 @@ export type GetProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; }; export type PostProps = { @@ -322,9 +306,9 @@ export type PostProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ @@ -337,9 +321,9 @@ export type PutProps = { */ path: string; /** - * URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + * Query parameters to be applied to the current query. */ - parameters?: string; + parameters?: Record; /** * The parameters to send with the custom request. */ diff --git a/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php b/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php index 383b36e69d..13217305b2 100644 --- a/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php +++ b/clients/algoliasearch-client-php/lib/Api/AbtestingApi.php @@ -117,7 +117,7 @@ public function addABTests($addABTestsRequest) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -141,7 +141,7 @@ public function del($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -197,7 +197,7 @@ public function deleteABTest($id) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * * @return array */ @@ -220,7 +220,7 @@ public function get($path, $parameters = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -309,7 +309,7 @@ public function listABTests($offset = 0, $limit = 10) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -333,7 +333,7 @@ public function post($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -357,7 +357,7 @@ public function post($path, $parameters = null, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -381,7 +381,7 @@ public function put($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } diff --git a/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php b/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php index ff1d18b2e7..3e02fc3cf6 100644 --- a/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/AnalyticsApi.php @@ -90,7 +90,7 @@ public function getClientConfig() * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -114,7 +114,7 @@ public function del($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -138,7 +138,7 @@ public function del($path, $parameters = null, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * * @return array */ @@ -161,7 +161,7 @@ public function get($path, $parameters = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -1662,7 +1662,7 @@ public function getUsersCount($index, $startDate = null, $endDate = null, $tags * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -1686,7 +1686,7 @@ public function post($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -1710,7 +1710,7 @@ public function post($path, $parameters = null, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -1734,7 +1734,7 @@ public function put($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } diff --git a/clients/algoliasearch-client-php/lib/Api/InsightsApi.php b/clients/algoliasearch-client-php/lib/Api/InsightsApi.php index 51298c6608..fe7180ca3c 100644 --- a/clients/algoliasearch-client-php/lib/Api/InsightsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/InsightsApi.php @@ -89,7 +89,7 @@ public function getClientConfig() * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -113,7 +113,7 @@ public function del($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -137,7 +137,7 @@ public function del($path, $parameters = null, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * * @return array */ @@ -160,7 +160,7 @@ public function get($path, $parameters = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -180,7 +180,7 @@ public function get($path, $parameters = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -204,7 +204,7 @@ public function post($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -255,7 +255,7 @@ public function pushEvents($insightEvents) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -279,7 +279,7 @@ public function put($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } diff --git a/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php b/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php index 8d65a5aff9..ecf80c0fb4 100644 --- a/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php +++ b/clients/algoliasearch-client-php/lib/Api/PersonalizationApi.php @@ -90,7 +90,7 @@ public function getClientConfig() * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -114,7 +114,7 @@ public function del($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -170,7 +170,7 @@ public function deleteUserProfile($userToken) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * * @return array */ @@ -193,7 +193,7 @@ public function get($path, $parameters = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -260,7 +260,7 @@ public function getUserTokenProfile($userToken) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -284,7 +284,7 @@ public function post($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -308,7 +308,7 @@ public function post($path, $parameters = null, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -332,7 +332,7 @@ public function put($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } diff --git a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php index 278cb09833..f03f9d1648 100644 --- a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php +++ b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsApi.php @@ -117,7 +117,7 @@ public function createConfig($querySuggestionsIndexWithIndexParam) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -141,7 +141,7 @@ public function del($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -197,7 +197,7 @@ public function deleteConfig($indexName) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * * @return array */ @@ -220,7 +220,7 @@ public function get($path, $parameters = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -351,7 +351,7 @@ public function getLogFile($indexName) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -375,7 +375,7 @@ public function post($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -399,7 +399,7 @@ public function post($path, $parameters = null, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -423,7 +423,7 @@ public function put($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } diff --git a/clients/algoliasearch-client-php/lib/Api/RecommendApi.php b/clients/algoliasearch-client-php/lib/Api/RecommendApi.php index 31710f7d17..36251f7a18 100644 --- a/clients/algoliasearch-client-php/lib/Api/RecommendApi.php +++ b/clients/algoliasearch-client-php/lib/Api/RecommendApi.php @@ -90,7 +90,7 @@ public function getClientConfig() * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -114,7 +114,7 @@ public function del($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -138,7 +138,7 @@ public function del($path, $parameters = null, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * * @return array */ @@ -161,7 +161,7 @@ public function get($path, $parameters = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -208,7 +208,7 @@ public function getRecommendations($getRecommendationsParams) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -232,7 +232,7 @@ public function post($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -256,7 +256,7 @@ public function post($path, $parameters = null, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -280,7 +280,7 @@ public function put($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } diff --git a/clients/algoliasearch-client-php/lib/Api/SearchApi.php b/clients/algoliasearch-client-php/lib/Api/SearchApi.php index 29be5b6a66..81d7b50796 100644 --- a/clients/algoliasearch-client-php/lib/Api/SearchApi.php +++ b/clients/algoliasearch-client-php/lib/Api/SearchApi.php @@ -606,7 +606,7 @@ public function clearRules($indexName, $forwardToReplicas = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -630,7 +630,7 @@ public function del($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -959,7 +959,7 @@ public function deleteSynonym($indexName, $objectID, $forwardToReplicas = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * * @return array */ @@ -982,7 +982,7 @@ public function get($path, $parameters = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -1740,7 +1740,7 @@ public function partialUpdateObject($indexName, $objectID, $attributeOrBuiltInOp * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -1764,7 +1764,7 @@ public function post($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } @@ -1788,7 +1788,7 @@ public function post($path, $parameters = null, $body = null) * Send requests to the Algolia REST API. * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) - * @param string $parameters URL-encoded query string. Force some query parameters to be applied for each query made with this API key. (optional) + * @param array $parameters Query parameters to be applied to the current query. (optional) * @param array $body The parameters to send with the custom request. (optional) * * @return array @@ -1812,7 +1812,7 @@ public function put($path, $parameters = null, $body = null) $queryParams[$key] = $value; } } else { - $queryParams['parameters'] = $parameters; + $queryParams = $parameters; } } diff --git a/generators/src/main/java/com/algolia/codegen/AlgoliaJavascriptGenerator.java b/generators/src/main/java/com/algolia/codegen/AlgoliaJavascriptGenerator.java index 8a02f021dd..0c451019b9 100644 --- a/generators/src/main/java/com/algolia/codegen/AlgoliaJavascriptGenerator.java +++ b/generators/src/main/java/com/algolia/codegen/AlgoliaJavascriptGenerator.java @@ -4,7 +4,8 @@ import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.languages.TypeScriptNodeClientCodegen; - +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.parameters.Parameter; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.servers.Server; @@ -18,4 +19,12 @@ public String getName() { public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List servers) { return Utils.specifyCustomRequest(super.fromOperation(path, httpMethod, operation, servers)); } + + @Override + protected String getParameterDataType(Parameter parameter, Schema p) { + String type = super.getParameterDataType(parameter, p); + // openapi generator is wrong, 'object' is not a fit all object, we need 'any' + // we use replace because there might be more to this type, like '| undefined' + return type.replace("{ [key: string]: object; }", "Record"); + } } diff --git a/specs/bundled/abtesting.yml b/specs/bundled/abtesting.yml index 9d8b2efcbf..9d49a3173b 100644 --- a/specs/bundled/abtesting.yml +++ b/specs/bundled/abtesting.yml @@ -27,12 +27,10 @@ components: Parameters: name: parameters in: query - description: >- - URL-encoded query string. Force some query parameters to be applied for - each query made with this API key. + description: Query parameters to be applied to the current query. schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + type: object + additionalProperties: true Offset: in: query name: offset diff --git a/specs/bundled/analytics.yml b/specs/bundled/analytics.yml index c77cbaed43..87ae14b5d7 100644 --- a/specs/bundled/analytics.yml +++ b/specs/bundled/analytics.yml @@ -27,12 +27,10 @@ components: Parameters: name: parameters in: query - description: >- - URL-encoded query string. Force some query parameters to be applied for - each query made with this API key. + description: Query parameters to be applied to the current query. schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + type: object + additionalProperties: true Index: in: query name: index diff --git a/specs/bundled/insights.yml b/specs/bundled/insights.yml index 0a02752e52..64358c9159 100644 --- a/specs/bundled/insights.yml +++ b/specs/bundled/insights.yml @@ -27,12 +27,10 @@ components: Parameters: name: parameters in: query - description: >- - URL-encoded query string. Force some query parameters to be applied for - each query made with this API key. + description: Query parameters to be applied to the current query. schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + type: object + additionalProperties: true schemas: ErrorBase: description: Error. diff --git a/specs/bundled/personalization.yml b/specs/bundled/personalization.yml index feba18b022..bf0b7de524 100644 --- a/specs/bundled/personalization.yml +++ b/specs/bundled/personalization.yml @@ -27,12 +27,10 @@ components: Parameters: name: parameters in: query - description: >- - URL-encoded query string. Force some query parameters to be applied for - each query made with this API key. + description: Query parameters to be applied to the current query. schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + type: object + additionalProperties: true UserToken: name: userToken in: path diff --git a/specs/bundled/predict.yml b/specs/bundled/predict.yml index dbc9c4c047..75fac55183 100644 --- a/specs/bundled/predict.yml +++ b/specs/bundled/predict.yml @@ -27,12 +27,10 @@ components: Parameters: name: parameters in: query - description: >- - URL-encoded query string. Force some query parameters to be applied for - each query made with this API key. + description: Query parameters to be applied to the current query. schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + type: object + additionalProperties: true userID: name: userID in: path diff --git a/specs/bundled/query-suggestions.yml b/specs/bundled/query-suggestions.yml index 6e1b6690ee..0b2b46ff65 100644 --- a/specs/bundled/query-suggestions.yml +++ b/specs/bundled/query-suggestions.yml @@ -27,12 +27,10 @@ components: Parameters: name: parameters in: query - description: >- - URL-encoded query string. Force some query parameters to be applied for - each query made with this API key. + description: Query parameters to be applied to the current query. schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + type: object + additionalProperties: true IndexName: name: indexName in: path diff --git a/specs/bundled/recommend.yml b/specs/bundled/recommend.yml index 4a5555dc12..4eda404843 100644 --- a/specs/bundled/recommend.yml +++ b/specs/bundled/recommend.yml @@ -27,12 +27,10 @@ components: Parameters: name: parameters in: query - description: >- - URL-encoded query string. Force some query parameters to be applied for - each query made with this API key. + description: Query parameters to be applied to the current query. schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + type: object + additionalProperties: true schemas: ErrorBase: description: Error. diff --git a/specs/bundled/search.yml b/specs/bundled/search.yml index 6407b2a594..e2c8d7df5c 100644 --- a/specs/bundled/search.yml +++ b/specs/bundled/search.yml @@ -27,12 +27,10 @@ components: Parameters: name: parameters in: query - description: >- - URL-encoded query string. Force some query parameters to be applied for - each query made with this API key. + description: Query parameters to be applied to the current query. schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + type: object + additionalProperties: true IndexName: name: indexName in: path diff --git a/specs/bundled/sources.yml b/specs/bundled/sources.yml index 62a3ad1e6d..4dca86c856 100644 --- a/specs/bundled/sources.yml +++ b/specs/bundled/sources.yml @@ -27,12 +27,10 @@ components: Parameters: name: parameters in: query - description: >- - URL-encoded query string. Force some query parameters to be applied for - each query made with this API key. + description: Query parameters to be applied to the current query. schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + type: object + additionalProperties: true schemas: ErrorBase: description: Error. diff --git a/specs/common/schemas/CustomRequest.yml b/specs/common/schemas/CustomRequest.yml index 052ed7e383..77413a54cd 100644 --- a/specs/common/schemas/CustomRequest.yml +++ b/specs/common/schemas/CustomRequest.yml @@ -35,7 +35,7 @@ PathInPath: Parameters: name: parameters in: query - description: URL-encoded query string. Force some query parameters to be applied for each query made with this API key. + description: Query parameters to be applied to the current query. schema: - type: string - example: '?query=mySearchQuery&hitsPerPage=10' + type: object + additionalProperties: true diff --git a/templates/java/libraries/okhttp-gson/api.mustache b/templates/java/libraries/okhttp-gson/api.mustache index 4b0b5a2afa..a74df90a1e 100644 --- a/templates/java/libraries/okhttp-gson/api.mustache +++ b/templates/java/libraries/okhttp-gson/api.mustache @@ -119,18 +119,25 @@ public class {{classname}} extends ApiClient { {{javaUtilPrefix}}List queryParams = new {{javaUtilPrefix}}ArrayList(); {{javaUtilPrefix}}Map headers = new {{javaUtilPrefix}}HashMap(); - {{#queryParams}} + {{#vendorExtensions}}{{#queryParams}} if ({{paramName}} != null) { + {{^x-is-custom-request}} queryParams.addAll(this.parameterToPair("{{baseName}}", {{paramName}})); + {{/x-is-custom-request}} + {{#x-is-custom-request}} + for (Map.Entry parameter : parameters.entrySet()) { + queryParams.addAll(this.parameterToPair(parameter.getKey(), parameter.getValue().toString())); + } + {{/x-is-custom-request}} } - {{/queryParams}} + {{/queryParams}}{{/vendorExtensions}} {{#headerParams}} if ({{paramName}} != null) { headers.put("{{baseName}}", this.parameterToString({{paramName}})); } - {{/headerParams}} + {{/headerParams}} headers.put("Accept", "application/json"); headers.put("Content-Type", "application/json"); diff --git a/templates/javascript/api-single.mustache b/templates/javascript/api-single.mustache index 35e18d6266..83a0c2909b 100644 --- a/templates/javascript/api-single.mustache +++ b/templates/javascript/api-single.mustache @@ -202,12 +202,6 @@ export function create{{capitalizedApiName}}Api(options: CreateClientOptions{{#h {{/allParams.0}} requestOptions?: RequestOptions ) : Promise<{{{returnType}}}> { - const requestPath = '{{{path}}}'{{#vendorExtensions}}{{#pathParams}}.replace( - {{=<% %>=}}'{<%baseName%>}'<%={{ }}=%>,{{#x-is-custom-request}}String({{paramName}}){{/x-is-custom-request}}{{^x-is-custom-request}}encodeURIComponent(String({{paramName}})){{/x-is-custom-request}} - ){{/pathParams}}{{/vendorExtensions}}; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - {{#allParams}} {{#required}} if ({{#isBoolean}}{{paramName}} === null || {{paramName}} === undefined{{/isBoolean}}{{^isBoolean}}!{{paramName}}{{/isBoolean}}) { @@ -224,12 +218,20 @@ export function create{{capitalizedApiName}}Api(options: CreateClientOptions{{#h {{/required}} {{/allParams}} - {{#queryParams}} + + const requestPath = '{{{path}}}'{{#vendorExtensions}}{{#pathParams}}.replace( + {{=<% %>=}}'{<%baseName%>}'<%={{ }}=%>,{{#x-is-custom-request}}{{paramName}}{{/x-is-custom-request}}{{^x-is-custom-request}}encodeURIComponent({{paramName}}){{/x-is-custom-request}} + ){{/pathParams}}{{/vendorExtensions}}; + const headers: Headers = {}; + const queryParameters: QueryParameters = {{#vendorExtensions.x-is-custom-request}}parameters || {{/vendorExtensions.x-is-custom-request}}{}; + + {{^vendorExtensions.x-is-custom-request}}{{#queryParams}} if ({{paramName}} !== undefined) { queryParameters['{{baseName}}'] = {{paramName}}.toString(); } - {{/queryParams}} + {{/queryParams}}{{/vendorExtensions.x-is-custom-request}} + {{#headerParams}} headers['{{baseName}}'] = {{paramName}}; {{/headerParams}} diff --git a/templates/php/api.mustache b/templates/php/api.mustache index efaf6311f5..cc02efdefe 100644 --- a/templates/php/api.mustache +++ b/templates/php/api.mustache @@ -203,7 +203,7 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts; $resourcePath = '{{{path}}}'; $queryParams = []; $httpBody = []; - {{#queryParams}} + {{#vendorExtensions}}{{#queryParams}} {{#isExplode}} if (${{paramName}} !== null) { @@ -214,7 +214,7 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts; } } else { - $queryParams['{{baseName}}'] = ${{paramName}}; + $queryParams{{^x-is-custom-request}}['{{baseName}}']{{/x-is-custom-request}} = ${{paramName}}; } {{/style}} {{^style}} @@ -230,7 +230,7 @@ use {{invokerPackage}}\RetryStrategy\ClusterHosts; $queryParams['{{baseName}}'] = ${{paramName}}; } {{/isExplode}} - {{/queryParams}} + {{/queryParams}}{{/vendorExtensions}} {{#vendorExtensions}}{{#pathParams}} // path params {{#collectionFormat}}