From 8588dae6c21456af655466cc91c07c8b8592a125 Mon Sep 17 00:00:00 2001 From: Aleksey Kuznietsov Date: Sun, 10 Apr 2022 23:52:20 -0400 Subject: [PATCH 1/2] Added possibility to provide GET-parameters for UserApi::getContectById requests. --- src/Api/UsersApi.php | 54 ++++++++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 20 deletions(-) diff --git a/src/Api/UsersApi.php b/src/Api/UsersApi.php index c4b7180d..504fbdb9 100644 --- a/src/Api/UsersApi.php +++ b/src/Api/UsersApi.php @@ -1974,14 +1974,17 @@ public function deleteSignatureImageWithHttpInfo($account_id, $image_type, $sign * * @param ?string $account_id The external account number (int) or account ID Guid. * @param ?string $contact_id The unique identifier of a person in the contacts address book. + * @param ?array $queryParams (optional) GET-parameters to HTTP request. + 2-dimensional representation of "keys (parameter names)" => "values".\ + (If the value has "object" type, it's considered as $options, for backward compatibility.) * @param \DocuSign\eSign\Api\UsersApi\GetContactByIdOptions $options for modifying the behavior of the function. (optional) * * @throws ApiException on non-2xx response * @return \DocuSign\eSign\Model\ContactGetResponse */ - public function getContactById($account_id, $contact_id, \DocuSign\eSign\Api\UsersApi\GetContactByIdOptions $options = null) + public function getContactById($account_id, $contact_id, $queryParams = [], \DocuSign\eSign\Api\UsersApi\GetContactByIdOptions $options = null) { - list($response) = $this->getContactByIdWithHttpInfo($account_id, $contact_id, $options); + list($response) = $this->getContactByIdWithHttpInfo($account_id, $contact_id, $queryParams, $options); return $response; } @@ -1992,12 +1995,15 @@ public function getContactById($account_id, $contact_id, \DocuSign\eSign\Api\Use * * @param ?string $account_id The external account number (int) or account ID Guid. * @param ?string $contact_id The unique identifier of a person in the contacts address book. + * @param ?array $queryParams (optional) GET-parameters to HTTP request. + 2-dimensional representation of "keys (parameter names)" => "values".\ + (If the value has "object" type, it's considered as $options, for backward compatibility.) * @param \DocuSign\eSign\Api\UsersApi\GetContactByIdOptions $options for modifying the behavior of the function. (optional) * * @throws ApiException on non-2xx response * @return array of \DocuSign\eSign\Model\ContactGetResponse, HTTP status code, HTTP response headers (array of strings) */ - public function getContactByIdWithHttpInfo($account_id, $contact_id, \DocuSign\eSign\Api\UsersApi\GetContactByIdOptions $options = null): array + public function getContactByIdWithHttpInfo($account_id, $contact_id, $queryParams = [], \DocuSign\eSign\Api\UsersApi\GetContactByIdOptions $options = null): array { // verify the required parameter 'account_id' is set if ($account_id === null) { @@ -2007,19 +2013,21 @@ public function getContactByIdWithHttpInfo($account_id, $contact_id, \DocuSign\e if ($contact_id === null) { throw new \InvalidArgumentException('Missing the required parameter $contact_id when calling getContactById'); } - // parse inputs - $resourcePath = "/v2.1/accounts/{accountId}/contacts/{contactId}"; - $httpBody = $_tempBody ?? ''; // $_tempBody is the method argument, if present - $queryParams = $headerParams = $formParams = []; - $headerParams['Accept'] ??= $this->apiClient->selectHeaderAccept(['application/json']); - $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType([]); - if ($options != null) - { - // query params - if ($options->getCloudProvider() != 'null') { - $queryParams['cloud_provider'] = $this->apiClient->getSerializer()->toQueryValue($options->getCloudProvider()); + // parse inputs + $resourcePath = '/v2.1/accounts/{accountId}/contacts/{contactId}'; + //$httpBody = $_tempBody ?? ''; // $_tempBody is the method argument, if present // AK 2022-04-10: odd. + // $headerParams = $formParams = []; // AK 2022-04-10: odd. + + if ($options === null) { + if ('object' === gettype($queryParams)) { // if $queryParams is 'object', consider it as $options, for backward compatibility. + $options = $queryParams; + $queryParams = null; } + + }elseif ($options->getCloudProvider() !== 'null') { + if (empty($queryParams)) $queryParams = []; + $queryParams['cloud_provider'] = $this->apiClient->getSerializer()->toQueryValue($options->getCloudProvider()); } // path params @@ -2031,26 +2039,32 @@ public function getContactByIdWithHttpInfo($account_id, $contact_id, \DocuSign\e $resourcePath = self::updateResourcePath($resourcePath, "contactId", $contact_id); } + /* // AK 2022-04-10: something odd and impossible here, so commented out. // default format to json $resourcePath = str_replace("{format}", "json", $resourcePath); - + // for model (json/xml) if (isset($_tempBody)) { $httpBody = $_tempBody; // $_tempBody is the method argument, if present } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) + }*/ + + $headerParams = [ + 'Accept' => $this->apiClient->selectHeaderAccept(['application/json']), + // 'Content-Type' => $this->apiClient->selectHeaderContentType([]), // AK 2022-04-10: no need to include empty value, so commented out. + ]; + if ($token = $this->apiClient->getConfig()->getAccessToken()) { // this endpoint requires OAuth (access token) + $headerParams['Authorization'] = 'Bearer ' . $token; } - // this endpoint requires OAuth (access token) - if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); - } + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'GET', $queryParams, - $httpBody, + '', // $httpBody, $headerParams, '\DocuSign\eSign\Model\ContactGetResponse', '/v2.1/accounts/{accountId}/contacts/{contactId}' From dfa5974bc70a3e096d20466311ef01deb6fed03c Mon Sep 17 00:00:00 2001 From: Aleksey Kuznietsov Date: Mon, 11 Apr 2022 18:08:31 -0400 Subject: [PATCH 2/2] Update UsersApi.php --- src/Api/UsersApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/UsersApi.php b/src/Api/UsersApi.php index 504fbdb9..205b20d1 100644 --- a/src/Api/UsersApi.php +++ b/src/Api/UsersApi.php @@ -2022,7 +2022,7 @@ public function getContactByIdWithHttpInfo($account_id, $contact_id, $queryParam if ($options === null) { if ('object' === gettype($queryParams)) { // if $queryParams is 'object', consider it as $options, for backward compatibility. $options = $queryParams; - $queryParams = null; + $queryParams = []; } }elseif ($options->getCloudProvider() !== 'null') {