diff --git a/clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts b/clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts index fa9a44c48f..ce4a832332 100644 --- a/clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts +++ b/clients/algoliasearch-client-javascript/packages/client-common/src/transporter/createTransporter.ts @@ -240,13 +240,13 @@ export function createTransporter({ cacheable: baseRequestOptions?.cacheable, timeout: baseRequestOptions?.timeout, queryParameters: { - ...methodOptions.queryParameters, ...baseRequestOptions?.queryParameters, + ...methodOptions.queryParameters, }, headers: { Accept: 'application/json', - ...methodOptions.headers, ...baseRequestOptions?.headers, + ...methodOptions.headers, }, }; diff --git a/clients/algoliasearch-client-php/lib/Api/AbtestingClient.php b/clients/algoliasearch-client-php/lib/Api/AbtestingClient.php index 409ba1f295..66838990d0 100644 --- a/clients/algoliasearch-client-php/lib/Api/AbtestingClient.php +++ b/clients/algoliasearch-client-php/lib/Api/AbtestingClient.php @@ -109,7 +109,7 @@ public function getClientConfig() * * @see \Algolia\AlgoliaSearch\Model\Abtesting\AddABTestsRequest * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Abtesting\ABTestResponse */ @@ -127,16 +127,17 @@ public function addABTests($addABTestsRequest, $requestOptions = []) $resourcePath = '/2/abtests'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($addABTestsRequest)) { $httpBody = $addABTestsRequest; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -148,7 +149,7 @@ public function addABTests($addABTestsRequest, $requestOptions = []) * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -163,6 +164,7 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -187,11 +189,10 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -202,7 +203,7 @@ public function del($path, $parameters = null, $requestOptions = []) * Delete a test. * * @param int $id The A/B test ID. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Abtesting\ABTestResponse */ @@ -217,6 +218,7 @@ public function deleteABTest($id, $requestOptions = []) $resourcePath = '/2/abtests/{id}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -228,11 +230,10 @@ public function deleteABTest($id, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -244,7 +245,7 @@ public function deleteABTest($id, $requestOptions = []) * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -259,6 +260,7 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -283,11 +285,10 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -298,7 +299,7 @@ public function get($path, $parameters = null, $requestOptions = []) * Get a test. * * @param int $id The A/B test ID. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Abtesting\ABTest */ @@ -313,6 +314,7 @@ public function getABTest($id, $requestOptions = []) $resourcePath = '/2/abtests/{id}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -324,11 +326,10 @@ public function getABTest($id, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -340,7 +341,7 @@ public function getABTest($id, $requestOptions = []) * * @param int $offset Position of the starting record. Used for paging. 0 is the first record. (optional, default to 0) * @param int $limit Number of records to return. Limit is the size of the page. (optional, default to 10) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Abtesting\ListABTestsResponse */ @@ -351,6 +352,7 @@ public function listABTests( ) { $resourcePath = '/2/abtests'; $queryParameters = []; + $headers = []; $httpBody = []; if ($offset !== null) { @@ -387,11 +389,10 @@ public function listABTests( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -404,7 +405,7 @@ public function listABTests( * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -423,6 +424,7 @@ public function post( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -450,11 +452,11 @@ public function post( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -467,7 +469,7 @@ public function post( * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -486,6 +488,7 @@ public function put( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -513,11 +516,11 @@ public function put( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -528,7 +531,7 @@ public function put( * Stop a test. * * @param int $id The A/B test ID. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Abtesting\ABTestResponse */ @@ -543,6 +546,7 @@ public function stopABTest($id, $requestOptions = []) $resourcePath = '/2/abtests/{id}/stop'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -554,11 +558,10 @@ public function stopABTest($id, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -568,11 +571,30 @@ public function stopABTest($id, $requestOptions = []) private function sendRequest( $method, $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions ) { - $query = \GuzzleHttp\Psr7\Query::build($queryParameters); + if (!isset($requestOptions['headers'])) { + $requestOptions['headers'] = []; + } + if (!isset($requestOptions['queryParameters'])) { + $requestOptions['queryParameters'] = []; + } + + $requestOptions['headers'] = array_merge( + $headers, + $requestOptions['headers'] + ); + $requestOptions['queryParameters'] = array_merge( + $queryParameters, + $requestOptions['queryParameters'] + ); + + $query = \GuzzleHttp\Psr7\Query::build( + $requestOptions['queryParameters'] + ); if ($method === 'GET') { $request = $this->api->read( diff --git a/clients/algoliasearch-client-php/lib/Api/AnalyticsClient.php b/clients/algoliasearch-client-php/lib/Api/AnalyticsClient.php index bdb43b7a44..11995dfc4e 100644 --- a/clients/algoliasearch-client-php/lib/Api/AnalyticsClient.php +++ b/clients/algoliasearch-client-php/lib/Api/AnalyticsClient.php @@ -104,7 +104,7 @@ public function getClientConfig() * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -119,6 +119,7 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -143,11 +144,10 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -159,7 +159,7 @@ public function del($path, $parameters = null, $requestOptions = []) * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -174,6 +174,7 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -198,11 +199,10 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -216,7 +216,7 @@ public function get($path, $parameters = null, $requestOptions = []) * @param string $startDate The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $endDate The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetAverageClickPositionResponse */ @@ -259,6 +259,7 @@ public function getAverageClickPosition( $resourcePath = '/2/clicks/averageClickPosition'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -329,11 +330,10 @@ public function getAverageClickPosition( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -347,7 +347,7 @@ public function getAverageClickPosition( * @param string $startDate The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $endDate The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetClickPositionsResponse */ @@ -390,6 +390,7 @@ public function getClickPositions( $resourcePath = '/2/clicks/positions'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -460,11 +461,10 @@ public function getClickPositions( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -478,7 +478,7 @@ public function getClickPositions( * @param string $startDate The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $endDate The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetClickThroughRateResponse */ @@ -521,6 +521,7 @@ public function getClickThroughRate( $resourcePath = '/2/clicks/clickThroughRate'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -591,11 +592,10 @@ public function getClickThroughRate( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -609,7 +609,7 @@ public function getClickThroughRate( * @param string $startDate The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $endDate The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetConversationRateResponse */ @@ -652,6 +652,7 @@ public function getConversationRate( $resourcePath = '/2/conversions/conversionRate'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -722,11 +723,10 @@ public function getConversationRate( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -740,7 +740,7 @@ public function getConversationRate( * @param string $startDate The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $endDate The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetNoClickRateResponse */ @@ -783,6 +783,7 @@ public function getNoClickRate( $resourcePath = '/2/searches/noClickRate'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -853,11 +854,10 @@ public function getNoClickRate( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -871,7 +871,7 @@ public function getNoClickRate( * @param string $startDate The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $endDate The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetNoResultsRateResponse */ @@ -914,6 +914,7 @@ public function getNoResultsRate( $resourcePath = '/2/searches/noResultRate'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -984,11 +985,10 @@ public function getNoResultsRate( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1002,7 +1002,7 @@ public function getNoResultsRate( * @param string $startDate The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $endDate The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetSearchesCountResponse */ @@ -1045,6 +1045,7 @@ public function getSearchesCount( $resourcePath = '/2/searches/count'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -1115,11 +1116,10 @@ public function getSearchesCount( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1135,7 +1135,7 @@ public function getSearchesCount( * @param int $limit Number of records to return. Limit is the size of the page. (optional, default to 10) * @param int $offset Position of the starting record. Used for paging. 0 is the first record. (optional, default to 0) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetSearchesNoClicksResponse */ @@ -1180,6 +1180,7 @@ public function getSearchesNoClicks( $resourcePath = '/2/searches/noClicks'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -1284,11 +1285,10 @@ public function getSearchesNoClicks( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1304,7 +1304,7 @@ public function getSearchesNoClicks( * @param int $limit Number of records to return. Limit is the size of the page. (optional, default to 10) * @param int $offset Position of the starting record. Used for paging. 0 is the first record. (optional, default to 0) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetSearchesNoResultsResponse */ @@ -1349,6 +1349,7 @@ public function getSearchesNoResults( $resourcePath = '/2/searches/noResults'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -1453,11 +1454,10 @@ public function getSearchesNoResults( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1468,7 +1468,7 @@ public function getSearchesNoResults( * Get Analytics API status. * * @param string $index The index name to target. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetStatusResponse */ @@ -1483,6 +1483,7 @@ public function getStatus($index, $requestOptions = []) $resourcePath = '/2/status'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -1502,11 +1503,10 @@ public function getStatus($index, $requestOptions = []) } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1522,7 +1522,7 @@ public function getStatus($index, $requestOptions = []) * @param int $limit Number of records to return. Limit is the size of the page. (optional, default to 10) * @param int $offset Position of the starting record. Used for paging. 0 is the first record. (optional, default to 0) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetTopCountriesResponse */ @@ -1567,6 +1567,7 @@ public function getTopCountries( $resourcePath = '/2/countries'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -1671,11 +1672,10 @@ public function getTopCountries( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1692,7 +1692,7 @@ public function getTopCountries( * @param int $limit Number of records to return. Limit is the size of the page. (optional, default to 10) * @param int $offset Position of the starting record. Used for paging. 0 is the first record. (optional, default to 0) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetTopFilterAttributesResponse */ @@ -1738,6 +1738,7 @@ public function getTopFilterAttributes( $resourcePath = '/2/filters'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -1859,11 +1860,10 @@ public function getTopFilterAttributes( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1881,7 +1881,7 @@ public function getTopFilterAttributes( * @param int $limit Number of records to return. Limit is the size of the page. (optional, default to 10) * @param int $offset Position of the starting record. Used for paging. 0 is the first record. (optional, default to 0) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetTopFilterForAttributeResponse */ @@ -1937,6 +1937,7 @@ public function getTopFilterForAttribute( $resourcePath = '/2/filters/{attribute}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -2067,11 +2068,10 @@ public function getTopFilterForAttribute( ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2088,7 +2088,7 @@ public function getTopFilterForAttribute( * @param int $limit Number of records to return. Limit is the size of the page. (optional, default to 10) * @param int $offset Position of the starting record. Used for paging. 0 is the first record. (optional, default to 0) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetTopFiltersNoResultsResponse */ @@ -2134,6 +2134,7 @@ public function getTopFiltersNoResults( $resourcePath = '/2/filters/noResults'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -2255,11 +2256,10 @@ public function getTopFiltersNoResults( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2277,7 +2277,7 @@ public function getTopFiltersNoResults( * @param int $limit Number of records to return. Limit is the size of the page. (optional, default to 10) * @param int $offset Position of the starting record. Used for paging. 0 is the first record. (optional, default to 0) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetTopHitsResponse */ @@ -2324,6 +2324,7 @@ public function getTopHits( $resourcePath = '/2/hits'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -2462,11 +2463,10 @@ public function getTopHits( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2485,7 +2485,7 @@ public function getTopHits( * @param int $limit Number of records to return. Limit is the size of the page. (optional, default to 10) * @param int $offset Position of the starting record. Used for paging. 0 is the first record. (optional, default to 0) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetTopSearchesResponse */ @@ -2533,6 +2533,7 @@ public function getTopSearches( $resourcePath = '/2/searches'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -2688,11 +2689,10 @@ public function getTopSearches( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2706,7 +2706,7 @@ public function getTopSearches( * @param string $startDate The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $endDate The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. (optional) * @param string $tags Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Analytics\GetUsersCountResponse */ @@ -2749,6 +2749,7 @@ public function getUsersCount( $resourcePath = '/2/users/count'; $queryParameters = []; + $headers = []; $httpBody = []; if ($index !== null) { @@ -2819,11 +2820,10 @@ public function getUsersCount( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2836,7 +2836,7 @@ public function getUsersCount( * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -2855,6 +2855,7 @@ public function post( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -2882,11 +2883,11 @@ public function post( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2899,7 +2900,7 @@ public function post( * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -2918,6 +2919,7 @@ public function put( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -2945,11 +2947,11 @@ public function put( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2959,11 +2961,30 @@ public function put( private function sendRequest( $method, $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions ) { - $query = \GuzzleHttp\Psr7\Query::build($queryParameters); + if (!isset($requestOptions['headers'])) { + $requestOptions['headers'] = []; + } + if (!isset($requestOptions['queryParameters'])) { + $requestOptions['queryParameters'] = []; + } + + $requestOptions['headers'] = array_merge( + $headers, + $requestOptions['headers'] + ); + $requestOptions['queryParameters'] = array_merge( + $queryParameters, + $requestOptions['queryParameters'] + ); + + $query = \GuzzleHttp\Psr7\Query::build( + $requestOptions['queryParameters'] + ); if ($method === 'GET') { $request = $this->api->read( diff --git a/clients/algoliasearch-client-php/lib/Api/InsightsClient.php b/clients/algoliasearch-client-php/lib/Api/InsightsClient.php index b0dce86ed8..517657608b 100644 --- a/clients/algoliasearch-client-php/lib/Api/InsightsClient.php +++ b/clients/algoliasearch-client-php/lib/Api/InsightsClient.php @@ -103,7 +103,7 @@ public function getClientConfig() * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -118,6 +118,7 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -142,11 +143,10 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -158,7 +158,7 @@ public function del($path, $parameters = null, $requestOptions = []) * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -173,6 +173,7 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -197,11 +198,10 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -214,7 +214,7 @@ public function get($path, $parameters = null, $requestOptions = []) * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -233,6 +233,7 @@ public function post( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -260,11 +261,11 @@ public function post( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -279,7 +280,7 @@ public function post( * * @see \Algolia\AlgoliaSearch\Model\Insights\InsightEvents * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Insights\PushEventsResponse */ @@ -297,16 +298,17 @@ public function pushEvents($insightEvents, $requestOptions = []) $resourcePath = '/1/events'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($insightEvents)) { $httpBody = $insightEvents; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -319,7 +321,7 @@ public function pushEvents($insightEvents, $requestOptions = []) * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -338,6 +340,7 @@ public function put( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -365,11 +368,11 @@ public function put( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -379,11 +382,30 @@ public function put( private function sendRequest( $method, $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions ) { - $query = \GuzzleHttp\Psr7\Query::build($queryParameters); + if (!isset($requestOptions['headers'])) { + $requestOptions['headers'] = []; + } + if (!isset($requestOptions['queryParameters'])) { + $requestOptions['queryParameters'] = []; + } + + $requestOptions['headers'] = array_merge( + $headers, + $requestOptions['headers'] + ); + $requestOptions['queryParameters'] = array_merge( + $queryParameters, + $requestOptions['queryParameters'] + ); + + $query = \GuzzleHttp\Psr7\Query::build( + $requestOptions['queryParameters'] + ); if ($method === 'GET') { $request = $this->api->read( diff --git a/clients/algoliasearch-client-php/lib/Api/PersonalizationClient.php b/clients/algoliasearch-client-php/lib/Api/PersonalizationClient.php index f8834700e6..ad85a58443 100644 --- a/clients/algoliasearch-client-php/lib/Api/PersonalizationClient.php +++ b/clients/algoliasearch-client-php/lib/Api/PersonalizationClient.php @@ -104,7 +104,7 @@ public function getClientConfig() * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -119,6 +119,7 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -143,11 +144,10 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -158,7 +158,7 @@ public function del($path, $parameters = null, $requestOptions = []) * Delete a user profile. * * @param string $userToken userToken representing the user for which to fetch the Personalization profile. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Personalization\DeleteUserProfileResponse */ @@ -176,6 +176,7 @@ public function deleteUserProfile($userToken, $requestOptions = []) $resourcePath = '/1/profiles/{userToken}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -187,11 +188,10 @@ public function deleteUserProfile($userToken, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -203,7 +203,7 @@ public function deleteUserProfile($userToken, $requestOptions = []) * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -218,6 +218,7 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -242,11 +243,10 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -256,7 +256,7 @@ public function get($path, $parameters = null, $requestOptions = []) /** * Get the current strategy. * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Personalization\PersonalizationStrategyParams */ @@ -264,13 +264,13 @@ public function getPersonalizationStrategy($requestOptions = []) { $resourcePath = '/1/strategies/personalization'; $queryParameters = []; + $headers = []; $httpBody = []; - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -281,7 +281,7 @@ public function getPersonalizationStrategy($requestOptions = []) * Get a user profile. * * @param string $userToken userToken representing the user for which to fetch the Personalization profile. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Personalization\GetUserTokenResponse */ @@ -299,6 +299,7 @@ public function getUserTokenProfile($userToken, $requestOptions = []) $resourcePath = '/1/profiles/personalization/{userToken}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -310,11 +311,10 @@ public function getUserTokenProfile($userToken, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -327,7 +327,7 @@ public function getUserTokenProfile($userToken, $requestOptions = []) * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -346,6 +346,7 @@ public function post( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -373,11 +374,11 @@ public function post( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -390,7 +391,7 @@ public function post( * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -409,6 +410,7 @@ public function put( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -436,11 +438,11 @@ public function put( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -457,7 +459,7 @@ public function put( * * @see \Algolia\AlgoliaSearch\Model\Personalization\PersonalizationStrategyParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Personalization\SetPersonalizationStrategyResponse */ @@ -478,16 +480,17 @@ public function setPersonalizationStrategy( $resourcePath = '/1/strategies/personalization'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($personalizationStrategyParams)) { $httpBody = $personalizationStrategyParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -497,11 +500,30 @@ public function setPersonalizationStrategy( private function sendRequest( $method, $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions ) { - $query = \GuzzleHttp\Psr7\Query::build($queryParameters); + if (!isset($requestOptions['headers'])) { + $requestOptions['headers'] = []; + } + if (!isset($requestOptions['queryParameters'])) { + $requestOptions['queryParameters'] = []; + } + + $requestOptions['headers'] = array_merge( + $headers, + $requestOptions['headers'] + ); + $requestOptions['queryParameters'] = array_merge( + $queryParameters, + $requestOptions['queryParameters'] + ); + + $query = \GuzzleHttp\Psr7\Query::build( + $requestOptions['queryParameters'] + ); if ($method === 'GET') { $request = $this->api->read( diff --git a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsClient.php b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsClient.php index bbffc686a4..057f203bc7 100644 --- a/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsClient.php +++ b/clients/algoliasearch-client-php/lib/Api/QuerySuggestionsClient.php @@ -106,7 +106,7 @@ public function getClientConfig() * * @see \Algolia\AlgoliaSearch\Model\QuerySuggestions\QuerySuggestionsIndexWithIndexParam * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\SucessResponse */ @@ -127,16 +127,17 @@ public function createConfig( $resourcePath = '/1/configs'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($querySuggestionsIndexWithIndexParam)) { $httpBody = $querySuggestionsIndexWithIndexParam; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -148,7 +149,7 @@ public function createConfig( * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -163,6 +164,7 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -187,11 +189,10 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -202,7 +203,7 @@ public function del($path, $parameters = null, $requestOptions = []) * Delete a configuration. * * @param string $indexName The index in which to perform the request. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\SucessResponse */ @@ -220,6 +221,7 @@ public function deleteConfig($indexName, $requestOptions = []) $resourcePath = '/1/configs/{indexName}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -231,11 +233,10 @@ public function deleteConfig($indexName, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -247,7 +248,7 @@ public function deleteConfig($indexName, $requestOptions = []) * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -262,6 +263,7 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -286,11 +288,10 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -300,7 +301,7 @@ public function get($path, $parameters = null, $requestOptions = []) /** * List configurations. * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\QuerySuggestionsIndex[] */ @@ -308,13 +309,13 @@ public function getAllConfigs($requestOptions = []) { $resourcePath = '/1/configs'; $queryParameters = []; + $headers = []; $httpBody = []; - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -325,7 +326,7 @@ public function getAllConfigs($requestOptions = []) * Get a single configuration. * * @param string $indexName The index in which to perform the request. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\QuerySuggestionsIndex */ @@ -343,6 +344,7 @@ public function getConfig($indexName, $requestOptions = []) $resourcePath = '/1/configs/{indexName}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -354,11 +356,10 @@ public function getConfig($indexName, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -369,7 +370,7 @@ public function getConfig($indexName, $requestOptions = []) * Get configuration status. * * @param string $indexName The index in which to perform the request. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\Status */ @@ -387,6 +388,7 @@ public function getConfigStatus($indexName, $requestOptions = []) $resourcePath = '/1/configs/{indexName}/status'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -398,11 +400,10 @@ public function getConfigStatus($indexName, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -413,7 +414,7 @@ public function getConfigStatus($indexName, $requestOptions = []) * Get a log file. * * @param string $indexName The index in which to perform the request. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\LogFile[] */ @@ -431,6 +432,7 @@ public function getLogFile($indexName, $requestOptions = []) $resourcePath = '/1/logs/{indexName}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -442,11 +444,10 @@ public function getLogFile($indexName, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -459,7 +460,7 @@ public function getLogFile($indexName, $requestOptions = []) * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -478,6 +479,7 @@ public function post( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -505,11 +507,11 @@ public function post( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -522,7 +524,7 @@ public function post( * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -541,6 +543,7 @@ public function put( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -568,11 +571,11 @@ public function put( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -590,7 +593,7 @@ public function put( * * @see \Algolia\AlgoliaSearch\Model\QuerySuggestions\QuerySuggestionsIndexParam * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\QuerySuggestions\SucessResponse */ @@ -621,6 +624,7 @@ public function updateConfig( $resourcePath = '/1/configs/{indexName}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -635,11 +639,11 @@ public function updateConfig( if (isset($querySuggestionsIndexParam)) { $httpBody = $querySuggestionsIndexParam; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -649,11 +653,30 @@ public function updateConfig( private function sendRequest( $method, $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions ) { - $query = \GuzzleHttp\Psr7\Query::build($queryParameters); + if (!isset($requestOptions['headers'])) { + $requestOptions['headers'] = []; + } + if (!isset($requestOptions['queryParameters'])) { + $requestOptions['queryParameters'] = []; + } + + $requestOptions['headers'] = array_merge( + $headers, + $requestOptions['headers'] + ); + $requestOptions['queryParameters'] = array_merge( + $queryParameters, + $requestOptions['queryParameters'] + ); + + $query = \GuzzleHttp\Psr7\Query::build( + $requestOptions['queryParameters'] + ); if ($method === 'GET') { $request = $this->api->read( diff --git a/clients/algoliasearch-client-php/lib/Api/RecommendClient.php b/clients/algoliasearch-client-php/lib/Api/RecommendClient.php index fbb0a0d7c3..daa86e59e4 100644 --- a/clients/algoliasearch-client-php/lib/Api/RecommendClient.php +++ b/clients/algoliasearch-client-php/lib/Api/RecommendClient.php @@ -103,7 +103,7 @@ public function getClientConfig() * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -118,6 +118,7 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -142,11 +143,10 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -158,7 +158,7 @@ public function del($path, $parameters = null, $requestOptions = []) * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -173,6 +173,7 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -197,11 +198,10 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -216,7 +216,7 @@ public function get($path, $parameters = null, $requestOptions = []) * * @see \Algolia\AlgoliaSearch\Model\Recommend\GetRecommendationsParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Recommend\GetRecommendationsResponse */ @@ -237,16 +237,17 @@ public function getRecommendations( $resourcePath = '/1/indexes/*/recommendations'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($getRecommendationsParams)) { $httpBody = $getRecommendationsParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -259,7 +260,7 @@ public function getRecommendations( * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -278,6 +279,7 @@ public function post( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -305,11 +307,11 @@ public function post( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -322,7 +324,7 @@ public function post( * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -341,6 +343,7 @@ public function put( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -368,11 +371,11 @@ public function put( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -382,11 +385,30 @@ public function put( private function sendRequest( $method, $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions ) { - $query = \GuzzleHttp\Psr7\Query::build($queryParameters); + if (!isset($requestOptions['headers'])) { + $requestOptions['headers'] = []; + } + if (!isset($requestOptions['queryParameters'])) { + $requestOptions['queryParameters'] = []; + } + + $requestOptions['headers'] = array_merge( + $headers, + $requestOptions['headers'] + ); + $requestOptions['queryParameters'] = array_merge( + $queryParameters, + $requestOptions['queryParameters'] + ); + + $query = \GuzzleHttp\Psr7\Query::build( + $requestOptions['queryParameters'] + ); if ($method === 'GET') { $request = $this->api->read( diff --git a/clients/algoliasearch-client-php/lib/Api/SearchClient.php b/clients/algoliasearch-client-php/lib/Api/SearchClient.php index e89c48e5ac..62c9acd2f3 100644 --- a/clients/algoliasearch-client-php/lib/Api/SearchClient.php +++ b/clients/algoliasearch-client-php/lib/Api/SearchClient.php @@ -112,7 +112,7 @@ public function getClientConfig() * * @see \Algolia\AlgoliaSearch\Model\Search\ApiKey * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\AddApiKeyResponse */ @@ -127,16 +127,17 @@ public function addApiKey($apiKey, $requestOptions = []) $resourcePath = '/1/keys'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($apiKey)) { $httpBody = $apiKey; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -149,7 +150,7 @@ public function addApiKey($apiKey, $requestOptions = []) * @param string $indexName The index in which to perform the request. (required) * @param string $objectID Unique identifier of an object. (required) * @param array $body The Algolia object. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtWithObjectIdResponse */ @@ -186,6 +187,7 @@ public function addOrUpdateObject( $resourcePath = '/1/indexes/{indexName}/{objectID}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -209,11 +211,11 @@ public function addOrUpdateObject( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -227,7 +229,7 @@ public function addOrUpdateObject( * * @see \Algolia\AlgoliaSearch\Model\Search\Source * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\CreatedAtResponse */ @@ -242,16 +244,17 @@ public function appendSource($source, $requestOptions = []) $resourcePath = '/1/security/sources/append'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($source)) { $httpBody = $source; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -267,7 +270,7 @@ public function appendSource($source, $requestOptions = []) * * @see \Algolia\AlgoliaSearch\Model\Search\AssignUserIdParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\CreatedAtResponse */ @@ -303,17 +306,18 @@ public function assignUserId( $resourcePath = '/1/clusters/mapping'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($assignUserIdParams)) { $httpBody = $assignUserIdParams; } - $queryParameters['X-Algolia-User-ID'] = $xAlgoliaUserID; - $requestOptions += $queryParameters; + $headers['X-Algolia-User-ID'] = $xAlgoliaUserID; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -329,7 +333,7 @@ public function assignUserId( * * @see \Algolia\AlgoliaSearch\Model\Search\BatchWriteParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\BatchResponse */ @@ -356,6 +360,7 @@ public function batch($indexName, $batchWriteParams, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}/batch'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -370,11 +375,11 @@ public function batch($indexName, $batchWriteParams, $requestOptions = []) if (isset($batchWriteParams)) { $httpBody = $batchWriteParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -391,7 +396,7 @@ public function batch($indexName, $batchWriteParams, $requestOptions = []) * * @see \Algolia\AlgoliaSearch\Model\Search\BatchAssignUserIdsParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\CreatedAtResponse */ @@ -428,17 +433,18 @@ public function batchAssignUserIds( $resourcePath = '/1/clusters/mapping/batch'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($batchAssignUserIdsParams)) { $httpBody = $batchAssignUserIdsParams; } - $queryParameters['X-Algolia-User-ID'] = $xAlgoliaUserID; - $requestOptions += $queryParameters; + $headers['X-Algolia-User-ID'] = $xAlgoliaUserID; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -455,7 +461,7 @@ public function batchAssignUserIds( * * @see \Algolia\AlgoliaSearch\Model\Search\BatchDictionaryEntriesParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -486,6 +492,7 @@ public function batchDictionaryEntries( $resourcePath = '/1/dictionaries/{dictionaryName}/batch'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -500,11 +507,11 @@ public function batchDictionaryEntries( if (isset($batchDictionaryEntriesParams)) { $httpBody = $batchDictionaryEntriesParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -518,7 +525,7 @@ public function batchDictionaryEntries( * @param array $rule rule (required) * @param bool $forwardToReplicas When true, changes are also propagated to replicas of the given indexName. (optional) * @param bool $clearExistingRules When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -547,6 +554,7 @@ public function batchRules( $resourcePath = '/1/indexes/{indexName}/rules/batch'; $queryParameters = []; + $headers = []; $httpBody = []; if ($forwardToReplicas !== null) { @@ -595,11 +603,11 @@ public function batchRules( if (isset($rule)) { $httpBody = $rule; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -616,7 +624,7 @@ public function batchRules( * * @see \Algolia\AlgoliaSearch\Model\Search\BrowseRequest * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\BrowseResponse */ @@ -637,6 +645,7 @@ public function browse( $resourcePath = '/1/indexes/{indexName}/browse'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -651,11 +660,11 @@ public function browse( if (isset($browseRequest)) { $httpBody = $browseRequest; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -667,7 +676,7 @@ public function browse( * * @param string $indexName The index in which to perform the request. (required) * @param bool $forwardToReplicas When true, changes are also propagated to replicas of the given indexName. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -688,6 +697,7 @@ public function clearAllSynonyms( $resourcePath = '/1/indexes/{indexName}/synonyms/clear'; $queryParameters = []; + $headers = []; $httpBody = []; if ($forwardToReplicas !== null) { @@ -716,11 +726,10 @@ public function clearAllSynonyms( ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -731,7 +740,7 @@ public function clearAllSynonyms( * Clear all objects from an index. * * @param string $indexName The index in which to perform the request. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -749,6 +758,7 @@ public function clearObjects($indexName, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}/clear'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -760,11 +770,10 @@ public function clearObjects($indexName, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -776,7 +785,7 @@ public function clearObjects($indexName, $requestOptions = []) * * @param string $indexName The index in which to perform the request. (required) * @param bool $forwardToReplicas When true, changes are also propagated to replicas of the given indexName. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -797,6 +806,7 @@ public function clearRules( $resourcePath = '/1/indexes/{indexName}/rules/clear'; $queryParameters = []; + $headers = []; $httpBody = []; if ($forwardToReplicas !== null) { @@ -825,11 +835,10 @@ public function clearRules( ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -841,7 +850,7 @@ public function clearRules( * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -856,6 +865,7 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -880,11 +890,10 @@ public function del($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -895,7 +904,7 @@ public function del($path, $parameters = null, $requestOptions = []) * Delete an API key. * * @param string $key API Key string. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\DeleteApiKeyResponse */ @@ -910,6 +919,7 @@ public function deleteApiKey($key, $requestOptions = []) $resourcePath = '/1/keys/{key}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -921,11 +931,10 @@ public function deleteApiKey($key, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -940,7 +949,7 @@ public function deleteApiKey($key, $requestOptions = []) * * @see \Algolia\AlgoliaSearch\Model\Search\SearchParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\DeletedAtResponse */ @@ -967,6 +976,7 @@ public function deleteBy($indexName, $searchParams, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}/deleteByQuery'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -981,11 +991,11 @@ public function deleteBy($indexName, $searchParams, $requestOptions = []) if (isset($searchParams)) { $httpBody = $searchParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -996,7 +1006,7 @@ public function deleteBy($indexName, $searchParams, $requestOptions = []) * Delete index. * * @param string $indexName The index in which to perform the request. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\DeletedAtResponse */ @@ -1014,6 +1024,7 @@ public function deleteIndex($indexName, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -1025,11 +1036,10 @@ public function deleteIndex($indexName, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1041,7 +1051,7 @@ public function deleteIndex($indexName, $requestOptions = []) * * @param string $indexName The index in which to perform the request. (required) * @param string $objectID Unique identifier of an object. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\DeletedAtResponse */ @@ -1068,6 +1078,7 @@ public function deleteObject($indexName, $objectID, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}/{objectID}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -1088,11 +1099,10 @@ public function deleteObject($indexName, $objectID, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1105,7 +1115,7 @@ public function deleteObject($indexName, $objectID, $requestOptions = []) * @param string $indexName The index in which to perform the request. (required) * @param string $objectID Unique identifier of an object. (required) * @param bool $forwardToReplicas When true, changes are also propagated to replicas of the given indexName. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -1136,6 +1146,7 @@ public function deleteRule( $resourcePath = '/1/indexes/{indexName}/rules/{objectID}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($forwardToReplicas !== null) { @@ -1173,11 +1184,10 @@ public function deleteRule( ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1188,7 +1198,7 @@ public function deleteRule( * Remove a single source. * * @param string $source The IP range of the source. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\DeleteSourceResponse */ @@ -1203,6 +1213,7 @@ public function deleteSource($source, $requestOptions = []) $resourcePath = '/1/security/sources/{source}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -1214,11 +1225,10 @@ public function deleteSource($source, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1231,7 +1241,7 @@ public function deleteSource($source, $requestOptions = []) * @param string $indexName The index in which to perform the request. (required) * @param string $objectID Unique identifier of an object. (required) * @param bool $forwardToReplicas When true, changes are also propagated to replicas of the given indexName. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\DeletedAtResponse */ @@ -1262,6 +1272,7 @@ public function deleteSynonym( $resourcePath = '/1/indexes/{indexName}/synonyms/{objectID}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($forwardToReplicas !== null) { @@ -1299,11 +1310,10 @@ public function deleteSynonym( ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1315,7 +1325,7 @@ public function deleteSynonym( * * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @param array $parameters Query parameters to be applied to the current query. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -1330,6 +1340,7 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -1354,11 +1365,10 @@ public function get($path, $parameters = null, $requestOptions = []) $resourcePath = str_replace('{path}', $path, $resourcePath); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1369,7 +1379,7 @@ public function get($path, $parameters = null, $requestOptions = []) * Get an API key. * * @param string $key API Key string. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\Key */ @@ -1384,6 +1394,7 @@ public function getApiKey($key, $requestOptions = []) $resourcePath = '/1/keys/{key}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -1395,11 +1406,10 @@ public function getApiKey($key, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1409,7 +1419,7 @@ public function getApiKey($key, $requestOptions = []) /** * List available languages. * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|array */ @@ -1417,13 +1427,13 @@ public function getDictionaryLanguages($requestOptions = []) { $resourcePath = '/1/dictionaries/*/languages'; $queryParameters = []; + $headers = []; $httpBody = []; - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1433,7 +1443,7 @@ public function getDictionaryLanguages($requestOptions = []) /** * Retrieve dictionaries settings. * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\GetDictionarySettingsResponse */ @@ -1441,13 +1451,13 @@ public function getDictionarySettings($requestOptions = []) { $resourcePath = '/1/dictionaries/*/settings'; $queryParameters = []; + $headers = []; $httpBody = []; - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1461,7 +1471,7 @@ public function getDictionarySettings($requestOptions = []) * @param int $length Maximum number of entries to retrieve. The maximum allowed value is 1000. (optional, default to 10) * @param string $indexName Index for which log entries should be retrieved. When omitted, log entries are retrieved across all indices. (optional) * @param array $type Type of log entries to retrieve. When omitted, all log entries are retrieved. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\GetLogsResponse */ @@ -1480,6 +1490,7 @@ public function getLogs( $resourcePath = '/1/logs'; $queryParameters = []; + $headers = []; $httpBody = []; if ($offset !== null) { @@ -1550,11 +1561,10 @@ public function getLogs( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1567,7 +1577,7 @@ public function getLogs( * @param string $indexName The index in which to perform the request. (required) * @param string $objectID Unique identifier of an object. (required) * @param array $attributesToRetrieve List of attributes to retrieve. If not specified, all retrievable attributes are returned. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|array */ @@ -1598,6 +1608,7 @@ public function getObject( $resourcePath = '/1/indexes/{indexName}/{objectID}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($attributesToRetrieve !== null) { @@ -1637,11 +1648,10 @@ public function getObject( ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1656,7 +1666,7 @@ public function getObject( * * @see \Algolia\AlgoliaSearch\Model\Search\GetObjectsParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\GetObjectsResponse */ @@ -1674,16 +1684,17 @@ public function getObjects($getObjectsParams, $requestOptions = []) $resourcePath = '/1/indexes/*/objects'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($getObjectsParams)) { $httpBody = $getObjectsParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1695,7 +1706,7 @@ public function getObjects($getObjectsParams, $requestOptions = []) * * @param string $indexName The index in which to perform the request. (required) * @param string $objectID Unique identifier of an object. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\Rule */ @@ -1722,6 +1733,7 @@ public function getRule($indexName, $objectID, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}/rules/{objectID}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -1742,11 +1754,10 @@ public function getRule($indexName, $objectID, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1757,7 +1768,7 @@ public function getRule($indexName, $objectID, $requestOptions = []) * Retrieve settings of an index. * * @param string $indexName The index in which to perform the request. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\IndexSettings */ @@ -1775,6 +1786,7 @@ public function getSettings($indexName, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}/settings'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -1786,11 +1798,10 @@ public function getSettings($indexName, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1800,7 +1811,7 @@ public function getSettings($indexName, $requestOptions = []) /** * List all allowed sources. * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\Source[] */ @@ -1808,13 +1819,13 @@ public function getSources($requestOptions = []) { $resourcePath = '/1/security/sources'; $queryParameters = []; + $headers = []; $httpBody = []; - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1826,7 +1837,7 @@ public function getSources($requestOptions = []) * * @param string $indexName The index in which to perform the request. (required) * @param string $objectID Unique identifier of an object. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\SynonymHit */ @@ -1853,6 +1864,7 @@ public function getSynonym($indexName, $objectID, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}/synonyms/{objectID}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -1873,11 +1885,10 @@ public function getSynonym($indexName, $objectID, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1889,7 +1900,7 @@ public function getSynonym($indexName, $objectID, $requestOptions = []) * * @param string $indexName The index in which to perform the request. (required) * @param int $taskID Unique identifier of an task. Numeric value (up to 64bits). (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\GetTaskResponse */ @@ -1913,6 +1924,7 @@ public function getTask($indexName, $taskID, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}/task/{taskID}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -1933,11 +1945,10 @@ public function getTask($indexName, $taskID, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1947,7 +1958,7 @@ public function getTask($indexName, $taskID, $requestOptions = []) /** * Get top userID. * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\GetTopUserIdsResponse */ @@ -1955,13 +1966,13 @@ public function getTopUserIds($requestOptions = []) { $resourcePath = '/1/clusters/mapping/top'; $queryParameters = []; + $headers = []; $httpBody = []; - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -1972,7 +1983,7 @@ public function getTopUserIds($requestOptions = []) * Get userID. * * @param string $userID userID to assign. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UserId */ @@ -1992,6 +2003,7 @@ public function getUserId($userID, $requestOptions = []) $resourcePath = '/1/clusters/mapping/{userID}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -2003,11 +2015,10 @@ public function getUserId($userID, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2018,7 +2029,7 @@ public function getUserId($userID, $requestOptions = []) * Get migration status. * * @param bool $getClusters Whether to get clusters or not. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\CreatedAtResponse */ @@ -2028,6 +2039,7 @@ public function hasPendingMappings( ) { $resourcePath = '/1/clusters/mapping/pending'; $queryParameters = []; + $headers = []; $httpBody = []; if ($getClusters !== null) { @@ -2047,11 +2059,10 @@ public function hasPendingMappings( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2061,7 +2072,7 @@ public function hasPendingMappings( /** * List API Keys. * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\ListApiKeysResponse */ @@ -2069,13 +2080,13 @@ public function listApiKeys($requestOptions = []) { $resourcePath = '/1/keys'; $queryParameters = []; + $headers = []; $httpBody = []; - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2085,7 +2096,7 @@ public function listApiKeys($requestOptions = []) /** * List clusters. * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\ListClustersResponse */ @@ -2093,13 +2104,13 @@ public function listClusters($requestOptions = []) { $resourcePath = '/1/clusters'; $queryParameters = []; + $headers = []; $httpBody = []; - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2110,7 +2121,7 @@ public function listClusters($requestOptions = []) * List existing indexes. * * @param int $page Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination). (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\ListIndicesResponse */ @@ -2118,6 +2129,7 @@ public function listIndices($page = null, $requestOptions = []) { $resourcePath = '/1/indexes'; $queryParameters = []; + $headers = []; $httpBody = []; if ($page !== null) { @@ -2137,11 +2149,10 @@ public function listIndices($page = null, $requestOptions = []) } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2153,7 +2164,7 @@ public function listIndices($page = null, $requestOptions = []) * * @param int $page Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination). (optional) * @param int $hitsPerPage Maximum number of objects to retrieve. (optional, default to 100) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\ListUserIdsResponse */ @@ -2164,6 +2175,7 @@ public function listUserIds( ) { $resourcePath = '/1/clusters/mapping'; $queryParameters = []; + $headers = []; $httpBody = []; if ($page !== null) { @@ -2200,11 +2212,10 @@ public function listUserIds( } } - $requestOptions += $queryParameters; - return $this->sendRequest( 'GET', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2219,7 +2230,7 @@ public function listUserIds( * * @see \Algolia\AlgoliaSearch\Model\Search\BatchParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\MultipleBatchResponse */ @@ -2237,16 +2248,17 @@ public function multipleBatch($batchParams, $requestOptions = []) $resourcePath = '/1/indexes/*/batch'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($batchParams)) { $httpBody = $batchParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2262,7 +2274,7 @@ public function multipleBatch($batchParams, $requestOptions = []) * * @see \Algolia\AlgoliaSearch\Model\Search\MultipleQueriesParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\MultipleQueriesResponse */ @@ -2283,16 +2295,17 @@ public function multipleQueries( $resourcePath = '/1/indexes/*/queries'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($multipleQueriesParams)) { $httpBody = $multipleQueriesParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2310,7 +2323,7 @@ public function multipleQueries( * * @see \Algolia\AlgoliaSearch\Model\Search\OperationIndexParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -2341,6 +2354,7 @@ public function operationIndex( $resourcePath = '/1/indexes/{indexName}/operation'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -2355,11 +2369,11 @@ public function operationIndex( if (isset($operationIndexParams)) { $httpBody = $operationIndexParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2373,7 +2387,7 @@ public function operationIndex( * @param string $objectID Unique identifier of an object. (required) * @param array $attributeOrBuiltInOperation List of attributes to update. (required) * @param bool $createIfNotExists Creates the record if it does not exist yet. (optional, default to true) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtWithObjectIdResponse */ @@ -2415,6 +2429,7 @@ public function partialUpdateObject( $resourcePath = '/1/indexes/{indexName}/{objectID}/partial'; $queryParameters = []; + $headers = []; $httpBody = []; if ($createIfNotExists !== null) { @@ -2455,11 +2470,11 @@ public function partialUpdateObject( if (isset($attributeOrBuiltInOperation)) { $httpBody = $attributeOrBuiltInOperation; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2472,7 +2487,7 @@ public function partialUpdateObject( * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -2491,6 +2506,7 @@ public function post( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -2518,11 +2534,11 @@ public function post( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2535,7 +2551,7 @@ public function post( * @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required) * @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) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|object */ @@ -2554,6 +2570,7 @@ public function put( $resourcePath = '/1{path}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($parameters !== null) { @@ -2581,11 +2598,11 @@ public function put( if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2596,7 +2613,7 @@ public function put( * Remove userID. * * @param string $userID userID to assign. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\RemoveUserIdResponse */ @@ -2616,6 +2633,7 @@ public function removeUserId($userID, $requestOptions = []) $resourcePath = '/1/clusters/mapping/{userID}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -2627,11 +2645,10 @@ public function removeUserId($userID, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'DELETE', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2642,7 +2659,7 @@ public function removeUserId($userID, $requestOptions = []) * Replace all allowed sources. * * @param array $source The sources to allow. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\ReplaceSourceResponse */ @@ -2657,16 +2674,17 @@ public function replaceSources($source, $requestOptions = []) $resourcePath = '/1/security/sources'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($source)) { $httpBody = $source; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2677,7 +2695,7 @@ public function replaceSources($source, $requestOptions = []) * Restore an API key. * * @param string $key API Key string. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\AddApiKeyResponse */ @@ -2692,6 +2710,7 @@ public function restoreApiKey($key, $requestOptions = []) $resourcePath = '/1/keys/{key}/restore'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -2703,11 +2722,10 @@ public function restoreApiKey($key, $requestOptions = []) ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2719,7 +2737,7 @@ public function restoreApiKey($key, $requestOptions = []) * * @param string $indexName The index in which to perform the request. (required) * @param array $body The Algolia record. (required) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\SaveObjectResponse */ @@ -2743,6 +2761,7 @@ public function saveObject($indexName, $body, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -2757,11 +2776,11 @@ public function saveObject($indexName, $body, $requestOptions = []) if (isset($body)) { $httpBody = $body; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2784,7 +2803,7 @@ public function saveObject($indexName, $body, $requestOptions = []) * @see \Algolia\AlgoliaSearch\Model\Search\Rule * * @param bool $forwardToReplicas When true, changes are also propagated to replicas of the given indexName. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedRuleResponse */ @@ -2822,6 +2841,7 @@ public function saveRule( $resourcePath = '/1/indexes/{indexName}/rules/{objectID}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($forwardToReplicas !== null) { @@ -2862,11 +2882,11 @@ public function saveRule( if (isset($rule)) { $httpBody = $rule; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2892,7 +2912,7 @@ public function saveRule( * @see \Algolia\AlgoliaSearch\Model\Search\SynonymHit * * @param bool $forwardToReplicas When true, changes are also propagated to replicas of the given indexName. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\SaveSynonymResponse */ @@ -2933,6 +2953,7 @@ public function saveSynonym( $resourcePath = '/1/indexes/{indexName}/synonyms/{objectID}'; $queryParameters = []; + $headers = []; $httpBody = []; if ($forwardToReplicas !== null) { @@ -2973,11 +2994,11 @@ public function saveSynonym( if (isset($synonymHit)) { $httpBody = $synonymHit; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -2991,7 +3012,7 @@ public function saveSynonym( * @param array $synonymHit synonymHit (required) * @param bool $forwardToReplicas When true, changes are also propagated to replicas of the given indexName. (optional) * @param bool $replaceExistingSynonyms Replace all synonyms of the index with the ones sent with this request. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -3023,6 +3044,7 @@ public function saveSynonyms( $resourcePath = '/1/indexes/{indexName}/synonyms/batch'; $queryParameters = []; + $headers = []; $httpBody = []; if ($forwardToReplicas !== null) { @@ -3073,11 +3095,11 @@ public function saveSynonyms( if (isset($synonymHit)) { $httpBody = $synonymHit; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -3092,7 +3114,7 @@ public function saveSynonyms( * * @see \Algolia\AlgoliaSearch\Model\Search\SearchParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\SearchResponse */ @@ -3119,6 +3141,7 @@ public function search($indexName, $searchParams, $requestOptions = []) $resourcePath = '/1/indexes/{indexName}/query'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -3133,11 +3156,11 @@ public function search($indexName, $searchParams, $requestOptions = []) if (isset($searchParams)) { $httpBody = $searchParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -3156,7 +3179,7 @@ public function search($indexName, $searchParams, $requestOptions = []) * * @see \Algolia\AlgoliaSearch\Model\Search\SearchDictionaryEntriesParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -3187,6 +3210,7 @@ public function searchDictionaryEntries( $resourcePath = '/1/dictionaries/{dictionaryName}/search'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -3201,11 +3225,11 @@ public function searchDictionaryEntries( if (isset($searchDictionaryEntriesParams)) { $httpBody = $searchDictionaryEntriesParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -3224,7 +3248,7 @@ public function searchDictionaryEntries( * * @see \Algolia\AlgoliaSearch\Model\Search\SearchForFacetValuesRequest * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\SearchForFacetValuesResponse */ @@ -3255,6 +3279,7 @@ public function searchForFacetValues( $resourcePath = '/1/indexes/{indexName}/facets/{facetName}/query'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -3278,11 +3303,11 @@ public function searchForFacetValues( if (isset($searchForFacetValuesRequest)) { $httpBody = $searchForFacetValuesRequest; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -3304,7 +3329,7 @@ public function searchForFacetValues( * * @see \Algolia\AlgoliaSearch\Model\Search\SearchRulesParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\SearchRulesResponse */ @@ -3334,6 +3359,7 @@ public function searchRules( $resourcePath = '/1/indexes/{indexName}/rules/search'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -3348,11 +3374,11 @@ public function searchRules( if (isset($searchRulesParams)) { $httpBody = $searchRulesParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -3367,7 +3393,7 @@ public function searchRules( * @param array $type Only search for specific types of synonyms. (optional) * @param int $page Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination). (optional, default to 0) * @param int $hitsPerPage Maximum number of objects to retrieve. (optional, default to 100) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\SearchSynonymsResponse */ @@ -3391,6 +3417,7 @@ public function searchSynonyms( $resourcePath = '/1/indexes/{indexName}/synonyms/search'; $queryParameters = []; + $headers = []; $httpBody = []; if ($query !== null) { @@ -3470,11 +3497,10 @@ public function searchSynonyms( ); } - $requestOptions += $queryParameters; - return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -3492,7 +3518,7 @@ public function searchSynonyms( * * @see \Algolia\AlgoliaSearch\Model\Search\SearchUserIdsParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\SearchUserIdsResponse */ @@ -3511,16 +3537,17 @@ public function searchUserIds($searchUserIdsParams, $requestOptions = []) $resourcePath = '/1/clusters/mapping/search'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($searchUserIdsParams)) { $httpBody = $searchUserIdsParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'POST', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -3535,7 +3562,7 @@ public function searchUserIds($searchUserIdsParams, $requestOptions = []) * * @see \Algolia\AlgoliaSearch\Model\Search\DictionarySettingsParams * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -3556,16 +3583,17 @@ public function setDictionarySettings( $resourcePath = '/1/dictionaries/*/settings'; $queryParameters = []; + $headers = []; $httpBody = []; if (isset($dictionarySettingsParams)) { $httpBody = $dictionarySettingsParams; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -3581,7 +3609,7 @@ public function setDictionarySettings( * @see \Algolia\AlgoliaSearch\Model\Search\IndexSettings * * @param bool $forwardToReplicas When true, changes are also propagated to replicas of the given indexName. (optional) - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdatedAtResponse */ @@ -3612,6 +3640,7 @@ public function setSettings( $resourcePath = '/1/indexes/{indexName}/settings'; $queryParameters = []; + $headers = []; $httpBody = []; if ($forwardToReplicas !== null) { @@ -3643,11 +3672,11 @@ public function setSettings( if (isset($indexSettings)) { $httpBody = $indexSettings; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -3670,7 +3699,7 @@ public function setSettings( * * @see \Algolia\AlgoliaSearch\Model\Search\ApiKey * - * @param array $requestOptions Request Options + * @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions * * @return array|\Algolia\AlgoliaSearch\Model\Search\UpdateApiKeyResponse */ @@ -3691,6 +3720,7 @@ public function updateApiKey($key, $apiKey, $requestOptions = []) $resourcePath = '/1/keys/{key}'; $queryParameters = []; + $headers = []; $httpBody = []; // path params @@ -3705,11 +3735,11 @@ public function updateApiKey($key, $apiKey, $requestOptions = []) if (isset($apiKey)) { $httpBody = $apiKey; } - $requestOptions += $queryParameters; return $this->sendRequest( 'PUT', $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions @@ -3719,11 +3749,30 @@ public function updateApiKey($key, $apiKey, $requestOptions = []) private function sendRequest( $method, $resourcePath, + $headers, $queryParameters, $httpBody, $requestOptions ) { - $query = \GuzzleHttp\Psr7\Query::build($queryParameters); + if (!isset($requestOptions['headers'])) { + $requestOptions['headers'] = []; + } + if (!isset($requestOptions['queryParameters'])) { + $requestOptions['queryParameters'] = []; + } + + $requestOptions['headers'] = array_merge( + $headers, + $requestOptions['headers'] + ); + $requestOptions['queryParameters'] = array_merge( + $queryParameters, + $requestOptions['queryParameters'] + ); + + $query = \GuzzleHttp\Psr7\Query::build( + $requestOptions['queryParameters'] + ); if ($method === 'GET') { $request = $this->api->read( diff --git a/clients/algoliasearch-client-php/lib/RequestOptions/RequestOptionsFactory.php b/clients/algoliasearch-client-php/lib/RequestOptions/RequestOptionsFactory.php index 3b7a14f48e..ecf9baebec 100644 --- a/clients/algoliasearch-client-php/lib/RequestOptions/RequestOptionsFactory.php +++ b/clients/algoliasearch-client-php/lib/RequestOptions/RequestOptionsFactory.php @@ -50,8 +50,7 @@ private function normalize($options) 'headers' => [ 'X-Algolia-Application-Id' => $this->config->getAppId(), 'X-Algolia-API-Key' => $this->config->getAlgoliaApiKey(), - 'User-Agent' => - $this->config->getUserAgent() !== null + 'User-Agent' => $this->config->getUserAgent() !== null ? $this->config->getUserAgent() : UserAgent::get(), 'Content-Type' => 'application/json',