@designliquido/delegua-http 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fontes/cliente-http.d.ts +6 -5
- package/fontes/cliente-http.js +10 -5
- package/fontes/cliente-http.js.map +1 -1
- package/fontes/interfaces/argumento-interface.d.ts +4 -0
- package/fontes/interfaces/argumento-interface.js +3 -0
- package/fontes/interfaces/argumento-interface.js.map +1 -0
- package/fontes/interfaces/index.d.ts +1 -0
- package/fontes/interfaces/index.js +18 -0
- package/fontes/interfaces/index.js.map +1 -0
- package/package.json +1 -1
- package/testes/cliente-http.test.js +1 -1
- package/testes/cliente-http.test.js.map +1 -1
package/fontes/cliente-http.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AxiosInstance, RawAxiosRequestHeaders } from "axios";
|
|
2
2
|
import { RespostaHttp } from "./resposta-http";
|
|
3
|
+
import { ArgumentoInterface } from "./interfaces";
|
|
3
4
|
export declare class ClienteHttp {
|
|
4
5
|
instanciaAxios: AxiosInstance;
|
|
5
6
|
constructor(urlBase?: string, tempoMaximo?: number, cabecalhos?: any);
|
|
6
|
-
requisicaoGet(sufixoUrl: string, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
|
|
7
|
-
requisicaoPost(sufixoUrl: string, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
|
|
8
|
-
requisicaoPut(sufixoUrl: string, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
|
|
9
|
-
requisicaoDelete(sufixoUrl: string, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
|
|
10
|
-
requisicaoPatch(sufixoUrl: string, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
|
|
7
|
+
requisicaoGet(sufixoUrl: string | ArgumentoInterface, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
|
|
8
|
+
requisicaoPost(sufixoUrl: string | ArgumentoInterface, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
|
|
9
|
+
requisicaoPut(sufixoUrl: string | ArgumentoInterface, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
|
|
10
|
+
requisicaoDelete(sufixoUrl: string | ArgumentoInterface, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
|
|
11
|
+
requisicaoPatch(sufixoUrl: string | ArgumentoInterface, corpo: any, cabecalhos?: RawAxiosRequestHeaders): Promise<RespostaHttp>;
|
|
11
12
|
}
|
package/fontes/cliente-http.js
CHANGED
|
@@ -15,31 +15,36 @@ class ClienteHttp {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
async requisicaoGet(sufixoUrl, cabecalhos) {
|
|
18
|
-
const
|
|
18
|
+
const sufixoUrlResolvido = sufixoUrl.hasOwnProperty("valor") ? sufixoUrl.valor : sufixoUrl;
|
|
19
|
+
const respostaAxios = await this.instanciaAxios.get(`${sufixoUrlResolvido}`, {
|
|
19
20
|
headers: Object.assign({}, cabecalhos)
|
|
20
21
|
});
|
|
21
22
|
return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
|
|
22
23
|
}
|
|
23
24
|
async requisicaoPost(sufixoUrl, corpo, cabecalhos) {
|
|
24
|
-
const
|
|
25
|
+
const sufixoUrlResolvido = sufixoUrl.hasOwnProperty("valor") ? sufixoUrl.valor : sufixoUrl;
|
|
26
|
+
const respostaAxios = await this.instanciaAxios.post(`${sufixoUrlResolvido}`, corpo, {
|
|
25
27
|
headers: Object.assign({}, cabecalhos)
|
|
26
28
|
});
|
|
27
29
|
return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
|
|
28
30
|
}
|
|
29
31
|
async requisicaoPut(sufixoUrl, corpo, cabecalhos) {
|
|
30
|
-
const
|
|
32
|
+
const sufixoUrlResolvido = sufixoUrl.hasOwnProperty("valor") ? sufixoUrl.valor : sufixoUrl;
|
|
33
|
+
const respostaAxios = await this.instanciaAxios.put(`${sufixoUrlResolvido}`, corpo, {
|
|
31
34
|
headers: Object.assign({}, cabecalhos)
|
|
32
35
|
});
|
|
33
36
|
return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
|
|
34
37
|
}
|
|
35
38
|
async requisicaoDelete(sufixoUrl, cabecalhos) {
|
|
36
|
-
const
|
|
39
|
+
const sufixoUrlResolvido = sufixoUrl.hasOwnProperty("valor") ? sufixoUrl.valor : sufixoUrl;
|
|
40
|
+
const respostaAxios = await this.instanciaAxios.delete(`${sufixoUrlResolvido}`, {
|
|
37
41
|
headers: Object.assign({}, cabecalhos)
|
|
38
42
|
});
|
|
39
43
|
return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
|
|
40
44
|
}
|
|
41
45
|
async requisicaoPatch(sufixoUrl, corpo, cabecalhos) {
|
|
42
|
-
const
|
|
46
|
+
const sufixoUrlResolvido = sufixoUrl.hasOwnProperty("valor") ? sufixoUrl.valor : sufixoUrl;
|
|
47
|
+
const respostaAxios = await this.instanciaAxios.patch(`${sufixoUrlResolvido}`, corpo, {
|
|
43
48
|
headers: Object.assign({}, cabecalhos)
|
|
44
49
|
});
|
|
45
50
|
return new resposta_http_1.RespostaHttp(respostaAxios.status, respostaAxios.statusText, respostaAxios.data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cliente-http.js","sourceRoot":"","sources":["../../fontes/cliente-http.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAoF;AACpF,mDAA+C;
|
|
1
|
+
{"version":3,"file":"cliente-http.js","sourceRoot":"","sources":["../../fontes/cliente-http.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAoF;AACpF,mDAA+C;AAG/C,MAAa,WAAW;IAGpB,YAAY,UAAkB,EAAE,EAAE,cAAsB,IAAI,E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;CACJ;AAvGD,kCAuGC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argumento-interface.js","sourceRoot":"","sources":["../../../fontes/interfaces/argumento-interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './argumento-interface';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./argumento-interface"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../fontes/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ const __1 = require("..");
|
|
|
4
4
|
describe('Cliente HTTP', () => {
|
|
5
5
|
it('Deve trazer dados com sucesso', async () => {
|
|
6
6
|
const clienteHttp = (0, __1.novoClienteHttp)(undefined, "https://github.com");
|
|
7
|
-
const resultado = await clienteHttp.requisicaoGet("/DesignLiquido/delegua");
|
|
7
|
+
const resultado = await clienteHttp.requisicaoGet({ nome: undefined, valor: "/DesignLiquido/delegua" });
|
|
8
8
|
expect(resultado).toBeTruthy();
|
|
9
9
|
expect(resultado.codigoStatus).toBe(200);
|
|
10
10
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cliente-http.test.js","sourceRoot":"","sources":["../../testes/cliente-http.test.ts"],"names":[],"mappings":";;AAAA,0BAAqC;AAErC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,WAAW,GAAG,IAAA,mBAAe,EAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QACrE,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"cliente-http.test.js","sourceRoot":"","sources":["../../testes/cliente-http.test.ts"],"names":[],"mappings":";;AAAA,0BAAqC;AAErC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,WAAW,GAAG,IAAA,mBAAe,EAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QACrE,MAAM,SAAS,GAAG,MAAM,WAAW,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,wBAAwB,EAAC,CAAC,CAAC;QACvG,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,CAAC;QAC/B,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|