Skip to content

Commit 04dc746

Browse files
committed
Oauth2 API's refactored
1 parent aca5a22 commit 04dc746

File tree

1 file changed

+23
-275
lines changed

1 file changed

+23
-275
lines changed

api/defaultApi.ts

Lines changed: 23 additions & 275 deletions
Original file line numberDiff line numberDiff line change
@@ -998,105 +998,15 @@ export class DefaultApi {
998998
authorization: string,
999999
generateTokenRequest: GenerateTokenRequest,
10001000
options: { headers: { [name: string]: string } } = { headers: {} }
1001-
): Promise<{
1002-
response: http.IncomingMessage;
1003-
body: GenerateToken200Response;
1004-
}> {
1005-
const localVarPath = this.basePath + "/auth/oauth2/v2/token";
1006-
let localVarQueryParameters: any = {};
1007-
let localVarHeaderParams: any = (<any>Object).assign(
1008-
{},
1009-
this._defaultHeaders
1010-
);
1011-
const produces = ["application/json"];
1012-
// give precedence to 'application/json'
1013-
if (produces.indexOf("application/json") >= 0) {
1014-
localVarHeaderParams.Accept = "application/json";
1015-
} else {
1016-
localVarHeaderParams.Accept = produces.join(",");
1017-
}
1018-
let localVarFormParams: any = {};
1019-
1020-
// verify required parameter 'authorization' is not null or undefined
1021-
if (authorization === null || authorization === undefined) {
1022-
throw new Error(
1023-
"Required parameter authorization was null or undefined when calling generateToken."
1024-
);
1025-
}
1026-
1027-
// verify required parameter 'generateTokenRequest' is not null or undefined
1028-
if (generateTokenRequest === null || generateTokenRequest === undefined) {
1029-
throw new Error(
1030-
"Required parameter generateTokenRequest was null or undefined when calling generateToken."
1031-
);
1032-
}
1033-
1034-
localVarHeaderParams["Authorization"] = ObjectSerializer.serialize(
1001+
): Promise<{ response: http.IncomingMessage; body: GenerateToken200Response }> {
1002+
return this.request<GenerateToken200Response>(
1003+
"POST",
1004+
"/auth/oauth2/v2/token",
10351005
authorization,
1036-
"string"
1037-
);
1038-
(<any>Object).assign(localVarHeaderParams, options.headers);
1039-
1040-
let localVarUseFormData = false;
1041-
1042-
let localVarRequestOptions: localVarRequest.Options = {
1043-
method: "POST",
1044-
qs: localVarQueryParameters,
1045-
headers: localVarHeaderParams,
1046-
uri: localVarPath,
1047-
useQuerystring: this._useQuerystring,
1048-
json: true,
1049-
body: ObjectSerializer.serialize(
1050-
generateTokenRequest,
1051-
"GenerateTokenRequest"
1052-
),
1053-
};
1054-
1055-
let authenticationPromise = Promise.resolve();
1056-
authenticationPromise = authenticationPromise.then(() =>
1057-
this.authentications.default.applyToRequest(localVarRequestOptions)
1006+
generateTokenRequest,
1007+
{},
1008+
options
10581009
);
1059-
1060-
let interceptorPromise = authenticationPromise;
1061-
for (const interceptor of this.interceptors) {
1062-
interceptorPromise = interceptorPromise.then(() =>
1063-
interceptor(localVarRequestOptions)
1064-
);
1065-
}
1066-
1067-
return interceptorPromise.then(() => {
1068-
if (Object.keys(localVarFormParams).length) {
1069-
if (localVarUseFormData) {
1070-
(<any>localVarRequestOptions).formData = localVarFormParams;
1071-
} else {
1072-
localVarRequestOptions.form = localVarFormParams;
1073-
}
1074-
}
1075-
return new Promise<{
1076-
response: http.IncomingMessage;
1077-
body: GenerateToken200Response;
1078-
}>((resolve, reject) => {
1079-
localVarRequest(localVarRequestOptions, (error, response, body) => {
1080-
if (error) {
1081-
reject(error);
1082-
} else {
1083-
if (
1084-
response.statusCode &&
1085-
response.statusCode >= 200 &&
1086-
response.statusCode <= 299
1087-
) {
1088-
body = ObjectSerializer.deserialize(
1089-
body,
1090-
"GenerateToken200Response"
1091-
);
1092-
resolve({ response: response, body: body });
1093-
} else {
1094-
reject(new HttpError(response, body, response.statusCode));
1095-
}
1096-
}
1097-
});
1098-
});
1099-
});
11001010
}
11011011
/**
11021012
*
@@ -1308,94 +1218,15 @@ export class DefaultApi {
13081218
public async getRateLimit(
13091219
authorization: string,
13101220
options: { headers: { [name: string]: string } } = { headers: {} }
1311-
): Promise<{
1312-
response: http.IncomingMessage;
1313-
body: GetRateLimit200Response;
1314-
}> {
1315-
const localVarPath = this.basePath + "/auth/rate_limit";
1316-
let localVarQueryParameters: any = {};
1317-
let localVarHeaderParams: any = (<any>Object).assign(
1318-
{},
1319-
this._defaultHeaders
1320-
);
1321-
const produces = ["application/json"];
1322-
// give precedence to 'application/json'
1323-
if (produces.indexOf("application/json") >= 0) {
1324-
localVarHeaderParams.Accept = "application/json";
1325-
} else {
1326-
localVarHeaderParams.Accept = produces.join(",");
1327-
}
1328-
let localVarFormParams: any = {};
1329-
1330-
// verify required parameter 'authorization' is not null or undefined
1331-
if (authorization === null || authorization === undefined) {
1332-
throw new Error(
1333-
"Required parameter authorization was null or undefined when calling getRateLimit."
1334-
);
1335-
}
1336-
1337-
localVarHeaderParams["Authorization"] = ObjectSerializer.serialize(
1221+
): Promise<{ response: http.IncomingMessage; body: GetRateLimit200Response }> {
1222+
return this.request<GetRateLimit200Response>(
1223+
"GET",
1224+
"/auth/rate_limit",
13381225
authorization,
1339-
"string"
1340-
);
1341-
(<any>Object).assign(localVarHeaderParams, options.headers);
1342-
1343-
let localVarUseFormData = false;
1344-
1345-
let localVarRequestOptions: localVarRequest.Options = {
1346-
method: "GET",
1347-
qs: localVarQueryParameters,
1348-
headers: localVarHeaderParams,
1349-
uri: localVarPath,
1350-
useQuerystring: this._useQuerystring,
1351-
json: true,
1352-
};
1353-
1354-
let authenticationPromise = Promise.resolve();
1355-
authenticationPromise = authenticationPromise.then(() =>
1356-
this.authentications.default.applyToRequest(localVarRequestOptions)
1226+
undefined, //No Body For GET Request
1227+
{}, // No QueryParams
1228+
options
13571229
);
1358-
1359-
let interceptorPromise = authenticationPromise;
1360-
for (const interceptor of this.interceptors) {
1361-
interceptorPromise = interceptorPromise.then(() =>
1362-
interceptor(localVarRequestOptions)
1363-
);
1364-
}
1365-
1366-
return interceptorPromise.then(() => {
1367-
if (Object.keys(localVarFormParams).length) {
1368-
if (localVarUseFormData) {
1369-
(<any>localVarRequestOptions).formData = localVarFormParams;
1370-
} else {
1371-
localVarRequestOptions.form = localVarFormParams;
1372-
}
1373-
}
1374-
return new Promise<{
1375-
response: http.IncomingMessage;
1376-
body: GetRateLimit200Response;
1377-
}>((resolve, reject) => {
1378-
localVarRequest(localVarRequestOptions, (error, response, body) => {
1379-
if (error) {
1380-
reject(error);
1381-
} else {
1382-
if (
1383-
response.statusCode &&
1384-
response.statusCode >= 200 &&
1385-
response.statusCode <= 299
1386-
) {
1387-
body = ObjectSerializer.deserialize(
1388-
body,
1389-
"GetRateLimit200Response"
1390-
);
1391-
resolve({ response: response, body: body });
1392-
} else {
1393-
reject(new HttpError(response, body, response.statusCode));
1394-
}
1395-
}
1396-
});
1397-
});
1398-
});
13991230
}
14001231
/**
14011232
*
@@ -2417,98 +2248,15 @@ export class DefaultApi {
24172248
authorization: string,
24182249
revokeTokenRequest?: RevokeTokenRequest,
24192250
options: { headers: { [name: string]: string } } = { headers: {} }
2420-
): Promise<{
2421-
response: http.IncomingMessage;
2422-
body: GenerateToken400Response;
2423-
}> {
2424-
const localVarPath = this.basePath + "/auth/oauth2/revoke";
2425-
let localVarQueryParameters: any = {};
2426-
let localVarHeaderParams: any = (<any>Object).assign(
2427-
{},
2428-
this._defaultHeaders
2429-
);
2430-
const produces = ["application/json"];
2431-
// give precedence to 'application/json'
2432-
if (produces.indexOf("application/json") >= 0) {
2433-
localVarHeaderParams.Accept = "application/json";
2434-
} else {
2435-
localVarHeaderParams.Accept = produces.join(",");
2436-
}
2437-
let localVarFormParams: any = {};
2438-
2439-
// verify required parameter 'authorization' is not null or undefined
2440-
if (authorization === null || authorization === undefined) {
2441-
throw new Error(
2442-
"Required parameter authorization was null or undefined when calling revokeToken."
2443-
);
2444-
}
2445-
2446-
localVarHeaderParams["Authorization"] = ObjectSerializer.serialize(
2251+
): Promise<{ response: http.IncomingMessage; body: GenerateToken400Response }> {
2252+
return this.request<GenerateToken400Response>(
2253+
"POST",
2254+
"/auth/oauth2/revoke",
24472255
authorization,
2448-
"string"
2449-
);
2450-
(<any>Object).assign(localVarHeaderParams, options.headers);
2451-
2452-
let localVarUseFormData = false;
2453-
2454-
let localVarRequestOptions: localVarRequest.Options = {
2455-
method: "POST",
2456-
qs: localVarQueryParameters,
2457-
headers: localVarHeaderParams,
2458-
uri: localVarPath,
2459-
useQuerystring: this._useQuerystring,
2460-
json: true,
2461-
body: ObjectSerializer.serialize(
2462-
revokeTokenRequest,
2463-
"RevokeTokenRequest"
2464-
),
2465-
};
2466-
2467-
let authenticationPromise = Promise.resolve();
2468-
authenticationPromise = authenticationPromise.then(() =>
2469-
this.authentications.default.applyToRequest(localVarRequestOptions)
2256+
revokeTokenRequest,
2257+
{},
2258+
options
24702259
);
2471-
2472-
let interceptorPromise = authenticationPromise;
2473-
for (const interceptor of this.interceptors) {
2474-
interceptorPromise = interceptorPromise.then(() =>
2475-
interceptor(localVarRequestOptions)
2476-
);
2477-
}
2478-
2479-
return interceptorPromise.then(() => {
2480-
if (Object.keys(localVarFormParams).length) {
2481-
if (localVarUseFormData) {
2482-
(<any>localVarRequestOptions).formData = localVarFormParams;
2483-
} else {
2484-
localVarRequestOptions.form = localVarFormParams;
2485-
}
2486-
}
2487-
return new Promise<{
2488-
response: http.IncomingMessage;
2489-
body: GenerateToken400Response;
2490-
}>((resolve, reject) => {
2491-
localVarRequest(localVarRequestOptions, (error, response, body) => {
2492-
if (error) {
2493-
reject(error);
2494-
} else {
2495-
if (
2496-
response.statusCode &&
2497-
response.statusCode >= 200 &&
2498-
response.statusCode <= 299
2499-
) {
2500-
body = ObjectSerializer.deserialize(
2501-
body,
2502-
"GenerateToken400Response"
2503-
);
2504-
resolve({ response: response, body: body });
2505-
} else {
2506-
reject(new HttpError(response, body, response.statusCode));
2507-
}
2508-
}
2509-
});
2510-
});
2511-
});
25122260
}
25132261
/**
25142262
*
@@ -3299,8 +3047,8 @@ export class DefaultApi {
32993047
"POST",
33003048
"/api/2/branding/brands",
33013049
authorization,
3302-
accountBrand,
3303-
{},
3050+
accountBrand, //Request body of API
3051+
{}, // Query params of request
33043052
options
33053053
);
33063054
}

0 commit comments

Comments
 (0)