11<?php
2+
23/**
34 * ApiClient
45 *
5- * PHP version 5
6+ * PHP version 7.4
67 *
78 * @category Class
89 * @package DocuSign\eSign
1112 */
1213
1314/**
14- * DocuSign REST API
15+ * Docusign eSignature REST API
1516 *
16- * The DocuSign REST API provides you with a powerful, convenient, and simple Web services API for interacting with DocuSign .
17+ * The Docusign eSignature REST API provides you with a powerful, convenient, and simple Web services API for interacting with Docusign .
1718 *
18- * OpenAPI spec version: v2
19+ * OpenAPI spec version: v2.1
1920 * Contact: devcenter@docusign.com
2021 * Generated by: https://github.com/swagger-api/swagger-codegen.git
22+ * Swagger Codegen version: 2.4.21
2123 */
2224
2325/**
3234use \DocuSign \eSign \Configuration ;
3335use \DocuSign \eSign \ObjectSerializer ;
3436use SebastianBergmann \RecursionContext \InvalidArgumentException ;
35- use Firebase \JWT \JWT ;
36-
37+ use Ahc \Jwt \JWT ;
3738
3839/**
3940 * ApiClient Class Doc Comment
4041 *
4142 * @category Class
4243 * @package DocuSign\eSign
43- * @author Swagger Codegen team
44+ * @author Swagger Codegen team <apihelp@docusign.com>
45+ * @license The Docusign PHP Client SDK is licensed under the MIT License.
4446 * @link https://github.com/swagger-api/swagger-codegen
4547 */
4648class ApiClient
@@ -53,8 +55,6 @@ class ApiClient
5355 public static $ PUT = "PUT " ;
5456 public static $ DELETE = "DELETE " ;
5557
56-
57-
5858 public static $ SCOPE_SIGNATURE = "signature " ;
5959 public static $ SCOPE_EXTENDED = "extended " ;
6060 public static $ SCOPE_IMPERSONATION = "impersonation " ;
@@ -170,14 +170,14 @@ public function getApiKeyWithPrefix($apiKeyIdentifier)
170170 * @param string $endpointPath path to method endpoint before expanding parameters
171171 * @param bool $oAuth pass true in case of oAuth requests
172172 *
173- * @throws ApiException on a non 2xx response
173+ * @throws DocuSign\eSign\Client\ ApiException on a non 2xx response
174174 * @return mixed
175175 */
176176 public function callApi ($ resourcePath , $ method , $ queryParams , $ postData , $ headerParams , $ responseType = null , $ endpointPath = null , $ oAuth = false )
177177 {
178178 $ headers = [];
179179
180- // DocuSign : Add DocuSign tracking headers
180+ // Docusign : Add Docusign tracking headers
181181 $ this ->config ->addDefaultHeader ("X-DocuSign-SDK " , "PHP " );
182182
183183 $ url = $ this ->config ->getHost () . $ resourcePath ;
@@ -220,11 +220,12 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
220220 if ($ this ->config ->getCurlTimeout () !== 0 ) {
221221 curl_setopt ($ curl , CURLOPT_TIMEOUT , $ this ->config ->getCurlTimeout ());
222222 }
223+
223224 // set connect timeout, if needed
224225 if ($ this ->config ->getCurlConnectTimeout () != 0 ) {
225226 curl_setopt ($ curl , CURLOPT_CONNECTTIMEOUT , $ this ->config ->getCurlConnectTimeout ());
226227 }
227-
228+
228229 // return the result on success, rather than just true
229230 curl_setopt ($ curl , CURLOPT_RETURNTRANSFER , true );
230231
@@ -337,6 +338,7 @@ public function callApi($resourcePath, $method, $queryParams, $postData, $header
337338 if (json_last_error () > 0 ) { // if response is a string
338339 $ data = $ http_body ;
339340 }
341+
340342 if (is_object ($ serializedData )){
341343 $ serializedData = serialize ($ serializedData );
342344 }
@@ -429,7 +431,7 @@ protected function httpParseHeaders($raw_headers)
429431 /**
430432 * Helper method to configure the OAuth accessCode/implicit flow parameters
431433 *
432- * @param string $client_id DocuSign OAuth Client Id(AKA Integrator Key)
434+ * @param string $client_id Docusign OAuth Client Id(AKA Integrator Key)
433435 * @param string|array $scopes the list of requested scopes. Client applications may be scoped to a limited set of system access.
434436 * @param string $redirect_uri This determines where to deliver the response containing the authorization code
435437 * @param string $response_type Determines the response type of the authorization request, NOTE: these response types are
@@ -465,8 +467,8 @@ public function getAuthorizationURI($client_id, $scopes, $redirect_uri, $respons
465467 /**
466468 * GenerateAccessToken will exchange the authorization code for an access token and refresh tokens.
467469 *
468- * @param string $client_id DocuSign OAuth Client Id(AKA Integrator Key)
469- * @param string $client_secret The secret key you generated when you set up the integration in DocuSign Admin console.
470+ * @param string $client_id Docusign OAuth Client Id(AKA Integrator Key)
471+ * @param string $client_secret The secret key you generated when you set up the integration in Docusign Admin console.
470472 * @param string $code The authorization code
471473 *
472474 * @return array
@@ -505,8 +507,8 @@ public function generateAccessToken($client_id = null, $client_secret = null, $c
505507 /**
506508 * Refresh Access Token
507509 *
508- * @param string $client_id DocuSign OAuth Client Id(AKA Integrator Key)
509- * @param string $client_secret The secret key you generated when you set up the integration in DocuSign Admin console.
510+ * @param string $client_id Docusign OAuth Client Id(AKA Integrator Key)
511+ * @param string $client_secret The secret key you generated when you set up the integration in Docusign Admin console.
510512 * @param string $code The authorization code
511513 *
512514 * @return array
@@ -544,7 +546,7 @@ public function refreshAccessToken($client_id = null, $client_secret = null, $re
544546 /**
545547 * Request JWT User Token
546548 *
547- * @param string $client_id DocuSign OAuth Client Id(AKA Integrator Key)
549+ * @param string $client_id Docusign OAuth Client Id(AKA Integrator Key)
548550 * @param string $rsa_private_key the RSA private key
549551 * @param string|string[] $scopes array optional The list of requested scopes may include (but not limited to) You can also pass any advanced scope.
550552 * @param string $user_id
@@ -583,7 +585,15 @@ public function requestJWTUserToken($client_id, $user_id, $rsa_private_key, $sco
583585 "scope " => is_array ($ scopes )?implode (" " , $ scopes ): $ scopes
584586 ];
585587
586- $ jwt = JWT ::encode ($ claim , $ rsa_private_key , 'RS256 ' );
588+ $ private_key = openssl_pkey_get_private ($ rsa_private_key );
589+ if ($ private_key === false && is_file ($ rsa_private_key )) {
590+ $ private_key = openssl_pkey_get_private ('file:// ' . $ rsa_private_key );
591+ }
592+ if ($ private_key === false ) {
593+ throw new \InvalidArgumentException ('Invalid RSA private key provided when calling requestJWTUserToken ' );
594+ }
595+
596+ $ jwt = (new JWT ($ private_key , 'RS256 ' ))->encode ($ claim );
587597
588598 $ resourcePath = "/oauth/token " ;
589599 $ queryParams = [];
@@ -605,7 +615,7 @@ public function requestJWTUserToken($client_id, $user_id, $rsa_private_key, $sco
605615 /**
606616 * Request JWT Application Token
607617 *
608- * @param string $client_id DocuSign OAuth Client Id(AKA Integrator Key)
618+ * @param string $client_id Docusign OAuth Client Id(AKA Integrator Key)
609619 * @param string $rsa_private_key the RSA private key
610620 * @param string|string[] $scopes array optional The list of requested scopes may include (but not limited to) You can also pass any advanced scope.
611621 * @param int $expires_in int Number of minutes token will be valid
@@ -639,7 +649,15 @@ public function requestJWTApplicationToken($client_id, $rsa_private_key, $scopes
639649 "scope " => is_array ($ scopes )?implode (" " , $ scopes ):$ scopes
640650 ];
641651
642- $ jwt = JWT ::encode ($ claim , $ rsa_private_key , 'RS256 ' );
652+ $ private_key = openssl_pkey_get_private ($ rsa_private_key );
653+ if ($ private_key === false && is_file ($ rsa_private_key )) {
654+ $ private_key = openssl_pkey_get_private ('file:// ' . $ rsa_private_key );
655+ }
656+ if ($ private_key === false ) {
657+ throw new \InvalidArgumentException ('Invalid RSA private key provided when calling requestJWTApplicationToken ' );
658+ }
659+
660+ $ jwt = (new JWT ($ private_key , 'RS256 ' ))->encode ($ claim );
643661
644662 $ resourcePath = "/oauth/token " ;
645663 $ queryParams = [];
@@ -694,4 +712,4 @@ public function getUserInfo($access_token)
694712 $ httpHeader
695713 ];
696714 }
697- }
715+ }
0 commit comments