Merged in development (pull request #15)

Development
This commit is contained in:
Leandro Costa 2023-11-10 12:09:41 +00:00
commit 5fe65798d8
3 changed files with 15 additions and 22 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "lhisp-oauth-client", "name": "lhisp-oauth-client",
"version": "1.0.23", "version": "1.0.24",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "lhisp-oauth-client", "name": "lhisp-oauth-client",
"version": "1.0.23", "version": "1.0.24",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"axios": "^1.6.1", "axios": "^1.6.1",

View file

@ -1,6 +1,6 @@
{ {
"name": "lhisp-oauth-client", "name": "lhisp-oauth-client",
"version": "1.0.23", "version": "1.0.24",
"main": "src/index", "main": "src/index",
"types": "src/index.d.ts", "types": "src/index.d.ts",
"repository": "git@bitbucket.org:leandro_costa/lhisp-oauth-client.git", "repository": "git@bitbucket.org:leandro_costa/lhisp-oauth-client.git",

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;
@ -180,47 +182,38 @@ export class LhispOauthClient<iAccessToken extends AccessToken = AccessToken> {
} }
} }
async get<ResponseType>({ path, contentType = ContentType.APPLICATION_JSON, params }: ExecutarRequestParams) { async get<ResponseType>(opt: ExecutarRequestParams) {
return this.executarRequest<ResponseType>({ return this.executarRequest<ResponseType>({
method: "GET", method: "GET",
path, ...opt,
contentType,
params,
}); });
} }
async put<ResponseType>({ path, data, contentType = ContentType.APPLICATION_JSON }: ExecutarRequestParams) { async put<ResponseType>(opt: ExecutarRequestParams) {
return this.executarRequest<ResponseType>({ return this.executarRequest<ResponseType>({
method: "PUT", method: "PUT",
path, ...opt,
data,
contentType,
}); });
} }
async patch<ResponseType>({ path, data, contentType = ContentType.APPLICATION_JSON }: ExecutarRequestParams) { async patch<ResponseType>(opt: ExecutarRequestParams) {
return this.executarRequest<ResponseType>({ return this.executarRequest<ResponseType>({
method: "PATCH", method: "PATCH",
path, ...opt,
data,
contentType,
}); });
} }
async post<ResponseType>({ path, data, contentType = ContentType.APPLICATION_JSON }: ExecutarRequestParams) { async post<ResponseType>(opt: ExecutarRequestParams) {
return this.executarRequest<ResponseType>({ return this.executarRequest<ResponseType>({
method: "POST", method: "POST",
path, ...opt,
data,
contentType,
}); });
} }
async delete<ResponseType>({ path, contentType = ContentType.APPLICATION_JSON }: ExecutarRequestParams) { async delete<ResponseType>(opt: ExecutarRequestParams) {
return this.executarRequest<ResponseType>({ return this.executarRequest<ResponseType>({
method: "DELETE", method: "DELETE",
path, ...opt,
contentType,
}); });
} }
} }