refactor: delegando os parametros padrão para o executarRequest

This commit is contained in:
Leandro Costa 2023-11-10 09:07:36 -03:00
parent 436b5c5b7f
commit 2d32904a40

View file

@ -146,6 +146,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
data, data,
params, params,
contentType = ContentType.APPLICATION_JSON, contentType = ContentType.APPLICATION_JSON,
...opt
}: ExecutarRequestParams): Promise<ResponseType> { }: ExecutarRequestParams): Promise<ResponseType> {
try { try {
await this.getAccessToken(); await this.getAccessToken();
@ -163,6 +164,7 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
headers, headers,
data, data,
params, params,
...opt,
}); });
return response.data; return response.data;
@ -183,7 +185,6 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
async get<ResponseType>(opt: ExecutarRequestParams) { async get<ResponseType>(opt: ExecutarRequestParams) {
return this.executarRequest<ResponseType>({ return this.executarRequest<ResponseType>({
method: "GET", method: "GET",
contentType: opt.contentType || ContentType.APPLICATION_JSON,
...opt, ...opt,
}); });
} }
@ -191,7 +192,6 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
async put<ResponseType>(opt: ExecutarRequestParams) { async put<ResponseType>(opt: ExecutarRequestParams) {
return this.executarRequest<ResponseType>({ return this.executarRequest<ResponseType>({
method: "PUT", method: "PUT",
contentType: opt.contentType || ContentType.APPLICATION_JSON,
...opt, ...opt,
}); });
} }
@ -199,7 +199,6 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
async patch<ResponseType>(opt: ExecutarRequestParams) { async patch<ResponseType>(opt: ExecutarRequestParams) {
return this.executarRequest<ResponseType>({ return this.executarRequest<ResponseType>({
method: "PATCH", method: "PATCH",
contentType: opt.contentType || ContentType.APPLICATION_JSON,
...opt, ...opt,
}); });
} }
@ -207,7 +206,6 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
async post<ResponseType>(opt: ExecutarRequestParams) { async post<ResponseType>(opt: ExecutarRequestParams) {
return this.executarRequest<ResponseType>({ return this.executarRequest<ResponseType>({
method: "POST", method: "POST",
contentType: opt.contentType || ContentType.APPLICATION_JSON,
...opt, ...opt,
}); });
} }
@ -215,7 +213,6 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
async delete<ResponseType>(opt: ExecutarRequestParams) { async delete<ResponseType>(opt: ExecutarRequestParams) {
return this.executarRequest<ResponseType>({ return this.executarRequest<ResponseType>({
method: "DELETE", method: "DELETE",
contentType: opt.contentType || ContentType.APPLICATION_JSON,
...opt, ...opt,
}); });
} }