Skip to content

Commit f027b52

Browse files
Merge pull request #608 from HubSpot/codegen/oauth2
Codegen: OAuth
2 parents 993996c + 27dcc01 commit f027b52

4 files changed

Lines changed: 66 additions & 18 deletions

File tree

codegen/Oauth/Api/TokensApi.php

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,17 @@ public function getConfig()
136136
* @param string|null $client_id client_id (optional)
137137
* @param string|null $client_secret client_secret (optional)
138138
* @param string|null $refresh_token refresh_token (optional)
139+
* @param string|null $code_verifier code_verifier (optional)
140+
* @param string|null $scope scope (optional)
139141
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation
140142
*
141143
* @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format
142144
* @throws \InvalidArgumentException
143145
* @return \HubSpot\Client\Oauth\Model\TokenResponseIF|\HubSpot\Client\Oauth\Model\Error
144146
*/
145-
public function create($grant_type = null, $code = null, $redirect_uri = null, $client_id = null, $client_secret = null, $refresh_token = null, string $contentType = self::contentTypes['create'][0])
147+
public function create($grant_type = null, $code = null, $redirect_uri = null, $client_id = null, $client_secret = null, $refresh_token = null, $code_verifier = null, $scope = null, string $contentType = self::contentTypes['create'][0])
146148
{
147-
list($response) = $this->createWithHttpInfo($grant_type, $code, $redirect_uri, $client_id, $client_secret, $refresh_token, $contentType);
149+
list($response) = $this->createWithHttpInfo($grant_type, $code, $redirect_uri, $client_id, $client_secret, $refresh_token, $code_verifier, $scope, $contentType);
148150
return $response;
149151
}
150152

@@ -159,15 +161,17 @@ public function create($grant_type = null, $code = null, $redirect_uri = null, $
159161
* @param string|null $client_id (optional)
160162
* @param string|null $client_secret (optional)
161163
* @param string|null $refresh_token (optional)
164+
* @param string|null $code_verifier (optional)
165+
* @param string|null $scope (optional)
162166
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation
163167
*
164168
* @throws \HubSpot\Client\Oauth\ApiException on non-2xx response or if the response body is not in the expected format
165169
* @throws \InvalidArgumentException
166170
* @return array of \HubSpot\Client\Oauth\Model\TokenResponseIF|\HubSpot\Client\Oauth\Model\Error, HTTP status code, HTTP response headers (array of strings)
167171
*/
168-
public function createWithHttpInfo($grant_type = null, $code = null, $redirect_uri = null, $client_id = null, $client_secret = null, $refresh_token = null, string $contentType = self::contentTypes['create'][0])
172+
public function createWithHttpInfo($grant_type = null, $code = null, $redirect_uri = null, $client_id = null, $client_secret = null, $refresh_token = null, $code_verifier = null, $scope = null, string $contentType = self::contentTypes['create'][0])
169173
{
170-
$request = $this->createRequest($grant_type, $code, $redirect_uri, $client_id, $client_secret, $refresh_token, $contentType);
174+
$request = $this->createRequest($grant_type, $code, $redirect_uri, $client_id, $client_secret, $refresh_token, $code_verifier, $scope, $contentType);
171175

172176
try {
173177
$options = $this->createHttpClientOption();
@@ -207,7 +211,7 @@ public function createWithHttpInfo($grant_type = null, $code = null, $redirect_u
207211
);
208212
}
209213

210-
214+
211215

212216
if ($statusCode < 200 || $statusCode > 299) {
213217
throw new ApiException(
@@ -246,7 +250,7 @@ public function createWithHttpInfo($grant_type = null, $code = null, $redirect_u
246250
$e->setResponseObject($data);
247251
throw $e;
248252
}
249-
253+
250254

251255
throw $e;
252256
}
@@ -263,14 +267,16 @@ public function createWithHttpInfo($grant_type = null, $code = null, $redirect_u
263267
* @param string|null $client_id (optional)
264268
* @param string|null $client_secret (optional)
265269
* @param string|null $refresh_token (optional)
270+
* @param string|null $code_verifier (optional)
271+
* @param string|null $scope (optional)
266272
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation
267273
*
268274
* @throws \InvalidArgumentException
269275
* @return \GuzzleHttp\Promise\PromiseInterface
270276
*/
271-
public function createAsync($grant_type = null, $code = null, $redirect_uri = null, $client_id = null, $client_secret = null, $refresh_token = null, string $contentType = self::contentTypes['create'][0])
277+
public function createAsync($grant_type = null, $code = null, $redirect_uri = null, $client_id = null, $client_secret = null, $refresh_token = null, $code_verifier = null, $scope = null, string $contentType = self::contentTypes['create'][0])
272278
{
273-
return $this->createAsyncWithHttpInfo($grant_type, $code, $redirect_uri, $client_id, $client_secret, $refresh_token, $contentType)
279+
return $this->createAsyncWithHttpInfo($grant_type, $code, $redirect_uri, $client_id, $client_secret, $refresh_token, $code_verifier, $scope, $contentType)
274280
->then(
275281
function ($response) {
276282
return $response[0];
@@ -289,15 +295,17 @@ function ($response) {
289295
* @param string|null $client_id (optional)
290296
* @param string|null $client_secret (optional)
291297
* @param string|null $refresh_token (optional)
298+
* @param string|null $code_verifier (optional)
299+
* @param string|null $scope (optional)
292300
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation
293301
*
294302
* @throws \InvalidArgumentException
295303
* @return \GuzzleHttp\Promise\PromiseInterface
296304
*/
297-
public function createAsyncWithHttpInfo($grant_type = null, $code = null, $redirect_uri = null, $client_id = null, $client_secret = null, $refresh_token = null, string $contentType = self::contentTypes['create'][0])
305+
public function createAsyncWithHttpInfo($grant_type = null, $code = null, $redirect_uri = null, $client_id = null, $client_secret = null, $refresh_token = null, $code_verifier = null, $scope = null, string $contentType = self::contentTypes['create'][0])
298306
{
299307
$returnType = '\HubSpot\Client\Oauth\Model\TokenResponseIF';
300-
$request = $this->createRequest($grant_type, $code, $redirect_uri, $client_id, $client_secret, $refresh_token, $contentType);
308+
$request = $this->createRequest($grant_type, $code, $redirect_uri, $client_id, $client_secret, $refresh_token, $code_verifier, $scope, $contentType);
301309

302310
return $this->client
303311
->sendAsync($request, $this->createHttpClientOption())
@@ -344,12 +352,14 @@ function ($exception) {
344352
* @param string|null $client_id (optional)
345353
* @param string|null $client_secret (optional)
346354
* @param string|null $refresh_token (optional)
355+
* @param string|null $code_verifier (optional)
356+
* @param string|null $scope (optional)
347357
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['create'] to see the possible values for this operation
348358
*
349359
* @throws \InvalidArgumentException
350360
* @return \GuzzleHttp\Psr7\Request
351361
*/
352-
public function createRequest($grant_type = null, $code = null, $redirect_uri = null, $client_id = null, $client_secret = null, $refresh_token = null, string $contentType = self::contentTypes['create'][0])
362+
public function createRequest($grant_type = null, $code = null, $redirect_uri = null, $client_id = null, $client_secret = null, $refresh_token = null, $code_verifier = null, $scope = null, string $contentType = self::contentTypes['create'][0])
353363
{
354364

355365

@@ -359,6 +369,8 @@ public function createRequest($grant_type = null, $code = null, $redirect_uri =
359369

360370

361371

372+
373+
362374
$resourcePath = '/oauth/v1/token';
363375
$formParams = [];
364376
$queryParams = [];
@@ -379,6 +391,8 @@ public function createRequest($grant_type = null, $code = null, $redirect_uri =
379391
'client_id' => $client_id,
380392
'client_secret' => $client_secret,
381393
'refresh_token' => $refresh_token,
394+
'code_verifier' => $code_verifier,
395+
'scope' => $scope,
382396
]);
383397

384398
$formParams = $formDataProcessor->flatten($formData);

codegen/Oauth/Model/AccessTokenInfoResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public function getScopes()
528528
/**
529529
* Sets scopes
530530
*
531-
* @param string[] $scopes scopes
531+
* @param string[] $scopes An array of strings indicating the scopes
532532
*
533533
* @return self
534534
*/

codegen/Oauth/Model/RefreshTokenInfoResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public function getScopes()
450450
/**
451451
* Sets scopes
452452
*
453-
* @param string[] $scopes scopes
453+
* @param string[] $scopes An array of strings detailing the scopes
454454
*
455455
* @return self
456456
*/

codegen/Oauth/Model/TokenResponseIF.php

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class TokenResponseIF implements ModelInterface, ArrayAccess, \JsonSerializable
5858
*/
5959
protected static $openAPITypes = [
6060
'access_token' => 'string',
61+
'refresh_token' => 'string',
6162
'expires_in' => 'int',
6263
'hub_id' => 'int',
6364
'id_token' => 'string',
@@ -75,6 +76,7 @@ class TokenResponseIF implements ModelInterface, ArrayAccess, \JsonSerializable
7576
*/
7677
protected static $openAPIFormats = [
7778
'access_token' => null,
79+
'refresh_token' => null,
7880
'expires_in' => 'int64',
7981
'hub_id' => 'int32',
8082
'id_token' => null,
@@ -90,6 +92,7 @@ class TokenResponseIF implements ModelInterface, ArrayAccess, \JsonSerializable
9092
*/
9193
protected static array $openAPINullables = [
9294
'access_token' => false,
95+
'refresh_token' => false,
9396
'expires_in' => false,
9497
'hub_id' => false,
9598
'id_token' => false,
@@ -184,12 +187,13 @@ public function isNullableSetToNull(string $property): bool
184187
* @var string[]
185188
*/
186189
protected static $attributeMap = [
187-
'access_token' => 'accessToken',
188-
'expires_in' => 'expiresIn',
189-
'hub_id' => 'hubId',
190+
'access_token' => 'access_token',
191+
'refresh_token' => 'refresh_token',
192+
'expires_in' => 'expires_in',
193+
'hub_id' => 'hub_id',
190194
'id_token' => 'idToken',
191195
'scopes' => 'scopes',
192-
'token_type' => 'tokenType',
196+
'token_type' => 'token_type',
193197
'user_id' => 'userId'
194198
];
195199

@@ -200,6 +204,7 @@ public function isNullableSetToNull(string $property): bool
200204
*/
201205
protected static $setters = [
202206
'access_token' => 'setAccessToken',
207+
'refresh_token' => 'setRefreshToken',
203208
'expires_in' => 'setExpiresIn',
204209
'hub_id' => 'setHubId',
205210
'id_token' => 'setIdToken',
@@ -215,6 +220,7 @@ public function isNullableSetToNull(string $property): bool
215220
*/
216221
protected static $getters = [
217222
'access_token' => 'getAccessToken',
223+
'refresh_token' => 'getRefreshToken',
218224
'expires_in' => 'getExpiresIn',
219225
'hub_id' => 'getHubId',
220226
'id_token' => 'getIdToken',
@@ -281,6 +287,7 @@ public function getModelName()
281287
public function __construct(?array $data = null)
282288
{
283289
$this->setIfExists('access_token', $data ?? [], null);
290+
$this->setIfExists('refresh_token', $data ?? [], null);
284291
$this->setIfExists('expires_in', $data ?? [], null);
285292
$this->setIfExists('hub_id', $data ?? [], null);
286293
$this->setIfExists('id_token', $data ?? [], null);
@@ -358,6 +365,33 @@ public function setAccessToken($access_token)
358365
return $this;
359366
}
360367

368+
/**
369+
* Gets refresh_token
370+
*
371+
* @return string|null
372+
*/
373+
public function getRefreshToken()
374+
{
375+
return $this->container['refresh_token'];
376+
}
377+
378+
/**
379+
* Sets refresh_token
380+
*
381+
* @param string|null $refresh_token refresh_token
382+
*
383+
* @return self
384+
*/
385+
public function setRefreshToken($refresh_token)
386+
{
387+
if (is_null($refresh_token)) {
388+
throw new \InvalidArgumentException('non-nullable refresh_token cannot be null');
389+
}
390+
$this->container['refresh_token'] = $refresh_token;
391+
392+
return $this;
393+
}
394+
361395
/**
362396
* Gets expires_in
363397
*
@@ -452,7 +486,7 @@ public function getScopes()
452486
/**
453487
* Sets scopes
454488
*
455-
* @param string[]|null $scopes scopes
489+
* @param string[]|null $scopes An array of strings indicating the scopes
456490
*
457491
* @return self
458492
*/

0 commit comments

Comments
 (0)