7vsdk-pessoas 1.0.7 → 1.0.12
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/dist/clients/base/CrudClientBase.d.ts +13 -0
- package/dist/clients/base/CrudClientBase.js +68 -0
- package/dist/clients/base/index.d.ts +1 -0
- package/dist/clients/base/index.js +17 -0
- package/dist/clients/enderecos/EnderecoBairroClient.d.ts +10 -0
- package/dist/clients/enderecos/EnderecoBairroClient.js +15 -0
- package/dist/clients/enderecos/EnderecoCidadeClient.d.ts +10 -0
- package/dist/clients/enderecos/EnderecoCidadeClient.js +15 -0
- package/dist/clients/enderecos/EnderecoSdk.d.ts +10 -0
- package/dist/clients/enderecos/EnderecoSdk.js +38 -0
- package/dist/clients/enderecos/UfClient.d.ts +5 -0
- package/dist/clients/enderecos/UfClient.js +10 -0
- package/dist/clients/enderecos/index.d.ts +1 -0
- package/dist/clients/enderecos/index.js +17 -0
- package/dist/clients/index.d.ts +3 -0
- package/dist/clients/index.js +19 -0
- package/dist/clients/pessoas/PessoaClient.d.ts +21 -0
- package/dist/clients/pessoas/PessoaClient.js +30 -0
- package/dist/clients/pessoas/PessoaCnpjClient.d.ts +7 -0
- package/dist/clients/pessoas/PessoaCnpjClient.js +10 -0
- package/dist/clients/pessoas/PessoaCpfClient.d.ts +7 -0
- package/dist/clients/pessoas/PessoaCpfClient.js +10 -0
- package/dist/clients/pessoas/PessoaEmailClient.d.ts +7 -0
- package/dist/clients/pessoas/PessoaEmailClient.js +10 -0
- package/dist/clients/pessoas/PessoaEnderecoClient.d.ts +7 -0
- package/dist/clients/pessoas/PessoaEnderecoClient.js +10 -0
- package/dist/clients/pessoas/PessoaNascimentoClient.d.ts +7 -0
- package/dist/clients/pessoas/PessoaNascimentoClient.js +10 -0
- package/dist/clients/pessoas/PessoaNecessidadeEspecial.d.ts +7 -0
- package/dist/clients/pessoas/PessoaNecessidadeEspecial.js +10 -0
- package/dist/clients/pessoas/PessoaProcedimentoClient.d.ts +7 -0
- package/dist/clients/pessoas/PessoaProcedimentoClient.js +10 -0
- package/dist/clients/pessoas/PessoaRelacaoClient.d.ts +7 -0
- package/dist/clients/pessoas/PessoaRelacaoClient.js +10 -0
- package/dist/clients/pessoas/PessoaRelacaoGrupoClient.d.ts +7 -0
- package/dist/clients/pessoas/PessoaRelacaoGrupoClient.js +10 -0
- package/dist/clients/pessoas/PessoaRelacaoTipoClient.d.ts +7 -0
- package/dist/clients/pessoas/PessoaRelacaoTipoClient.js +10 -0
- package/dist/clients/pessoas/PessoaTelefoneClient.d.ts +11 -0
- package/dist/clients/pessoas/PessoaTelefoneClient.js +15 -0
- package/dist/clients/pessoas/PessoaTipoClient.d.ts +7 -0
- package/dist/clients/pessoas/PessoaTipoClient.js +10 -0
- package/dist/clients/pessoas/index.d.ts +12 -0
- package/dist/clients/pessoas/index.js +28 -0
- package/dist/clients/portalContador/ImpostoEstadualSdk.d.ts +11 -0
- package/dist/clients/portalContador/ImpostoEstadualSdk.js +13 -0
- package/dist/clients/portalContador/ImpostoFederalSdk.d.ts +11 -0
- package/dist/clients/portalContador/ImpostoFederalSdk.js +16 -0
- package/dist/clients/portalContador/index.d.ts +1 -0
- package/dist/clients/portalContador/index.js +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +27 -0
- package/package.json +13 -15
- package/src/clients/base/CrudClientBase.ts +23 -3
- package/src/clients/enderecos/EnderecoBairroClient.ts +6 -5
- package/src/clients/enderecos/EnderecoCidadeClient.ts +9 -7
- package/src/clients/enderecos/EnderecoSdk.ts +53 -0
- package/src/clients/enderecos/UfClient.ts +6 -5
- package/src/clients/enderecos/index.ts +1 -5
- package/src/clients/index.ts +1 -2
- package/src/clients/pessoas/PessoaClient.ts +40 -4
- package/src/clients/portalContador/EmpresaSdk.ts +14 -0
- package/src/clients/portalContador/ImpostoEstadualSdk.ts +25 -0
- package/src/clients/portalContador/ImpostoFederalSdk.ts +27 -0
- package/tsconfig.json +5 -6
- package/tsconfig.tsbuildinfo +1 -0
- package/src/clients/enderecos/EnderecoClient.ts +0 -21
- package/src/clients/enderecos/EnderecoTipoClient.ts +0 -20
- package/src/clients/portalContador/empresaClient.ts +0 -40
- package/src/test.ts +0 -61
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ImpostoEstadualRequest, ImpostoEstadualResponse } from "7vdomain";
|
|
2
|
+
import { CrudClientBase } from "clients/base";
|
|
3
|
+
interface IImpostoEstadualSdk {
|
|
4
|
+
criarImpostoEstadual(request: ImpostoEstadualRequest): Promise<ImpostoEstadualResponse>;
|
|
5
|
+
pegarImpostoEstadual(id: number): Promise<ImpostoEstadualResponse>;
|
|
6
|
+
}
|
|
7
|
+
export declare class ImpostoEstadualSdk extends CrudClientBase<ImpostoEstadualRequest, ImpostoEstadualResponse> implements IImpostoEstadualSdk {
|
|
8
|
+
criarImpostoEstadual(request: ImpostoEstadualRequest): Promise<ImpostoEstadualResponse>;
|
|
9
|
+
pegarImpostoEstadual(id: number): Promise<ImpostoEstadualResponse>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImpostoEstadualSdk = void 0;
|
|
4
|
+
const base_1 = require("clients/base");
|
|
5
|
+
class ImpostoEstadualSdk extends base_1.CrudClientBase {
|
|
6
|
+
async criarImpostoEstadual(request) {
|
|
7
|
+
return await this.postAsync(request);
|
|
8
|
+
}
|
|
9
|
+
async pegarImpostoEstadual(id) {
|
|
10
|
+
return await this.getAsync(id);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ImpostoEstadualSdk = ImpostoEstadualSdk;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CrudClientBase } from "clients/base";
|
|
2
|
+
interface IImpostoFederalSdk {
|
|
3
|
+
criarImpostoEstadual(request: ImpostoFederalRequest): Promise<ImpostoFederalResponse>;
|
|
4
|
+
pegarImpostoEstadual(id: number): Promise<ImpostoFederalResponse>;
|
|
5
|
+
}
|
|
6
|
+
export declare class ImpostoEstadualSdk extends CrudClientBase<ImpostoFederalRequest, ImpostoEstadualResponse> implements IImpostoFederalSdk {
|
|
7
|
+
constructor(Url: string, tokenJwt: string);
|
|
8
|
+
criarImpostoEstadual(request: ImpostoFederalRequest): Promise<ImpostoFederalResponse>;
|
|
9
|
+
pegarImpostoEstadual(id: number): Promise<ImpostoFederalResponse>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImpostoEstadualSdk = void 0;
|
|
4
|
+
const base_1 = require("clients/base");
|
|
5
|
+
class ImpostoEstadualSdk extends base_1.CrudClientBase {
|
|
6
|
+
constructor(Url, tokenJwt) {
|
|
7
|
+
super(Url, "portal-contador/imposto/estadual", tokenJwt);
|
|
8
|
+
}
|
|
9
|
+
async criarImpostoEstadual(request) {
|
|
10
|
+
return await this.postAsync(request);
|
|
11
|
+
}
|
|
12
|
+
async pegarImpostoEstadual(id) {
|
|
13
|
+
return await this.getAsync(id);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.ImpostoEstadualSdk = ImpostoEstadualSdk;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ImpostoFederalSdk";
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./ImpostoFederalSdk"), exports);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./clients";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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("./clients"), exports);
|
package/dist/test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/test.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const _7vdomain_1 = require("7vdomain");
|
|
4
|
+
const _7vsdk_usuarios_1 = require("7vsdk-usuarios");
|
|
5
|
+
const clients_1 = require("./clients");
|
|
6
|
+
async function main() {
|
|
7
|
+
const auth = new _7vsdk_usuarios_1.AuthClient("http://localhost:7292");
|
|
8
|
+
const usuario = {
|
|
9
|
+
Nome: "teste da silva",
|
|
10
|
+
Senha: "7192",
|
|
11
|
+
PerfilId: 1,
|
|
12
|
+
PessoaRelacaoId: 1
|
|
13
|
+
};
|
|
14
|
+
const token = await auth.gerarToken(usuario);
|
|
15
|
+
console.log("Token gerado:", token);
|
|
16
|
+
const pessoac = new clients_1.PessoaClient("http://localhost:7292", token);
|
|
17
|
+
const req = new clients_1.PessoaClient("http://localhost:7292", token);
|
|
18
|
+
const endereco = new clients_1.EnderecoSdk("http://localhost:7292", token);
|
|
19
|
+
const enderecReq = {
|
|
20
|
+
CodigoIbge: "235353",
|
|
21
|
+
Nome: 'Cidade Exemplo',
|
|
22
|
+
UfId: _7vdomain_1.UfEnum.Bahia
|
|
23
|
+
};
|
|
24
|
+
await endereco.criarEndereco(enderecReq, "Bairro Exemplo", "Rua Exemplo", 1);
|
|
25
|
+
return { auth, usuario, token };
|
|
26
|
+
}
|
|
27
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "7vsdk-pessoas",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"license": "ISC",
|
|
13
|
-
"description": "",
|
|
14
|
-
"devDependencies": {
|
|
15
|
-
"@types/node": "^24.10.1",
|
|
16
|
-
"ts-node": "^10.9.2",
|
|
17
|
-
"typescript": "^5.9.3"
|
|
3
|
+
"version": "1.0.12",
|
|
4
|
+
"description": "SDK de clientes para a API de Pessoas da 7Virtual.",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"target": "es6",
|
|
7
|
+
"module": "commonjs",
|
|
8
|
+
"outDir": "out",
|
|
9
|
+
"rootDir": "src",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"esModuleInterop": true
|
|
18
12
|
},
|
|
13
|
+
"include": [
|
|
14
|
+
"src/**/*"
|
|
15
|
+
],
|
|
19
16
|
"dependencies": {
|
|
17
|
+
"7vdomain": "^1.1.14",
|
|
20
18
|
"7vsdk-usuarios": "^1.0.10"
|
|
21
19
|
}
|
|
22
20
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { ResultDto } from "7vdomain";
|
|
1
|
+
import type { ResultDto } from "7vdomain";
|
|
2
|
+
|
|
3
|
+
// essa classe base pode ser reutilizada para qualquer cliente CRUD
|
|
2
4
|
|
|
3
5
|
export abstract class CrudClientBase<TRequest, TResponse> {
|
|
4
6
|
protected baseUrl: string;
|
|
@@ -6,18 +8,25 @@ export abstract class CrudClientBase<TRequest, TResponse> {
|
|
|
6
8
|
protected tokenJwt?: string;
|
|
7
9
|
|
|
8
10
|
constructor(baseUrl: string, endpoint: string, tokenJwt: string) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
baseUrl = baseUrl.replace(/\/+$/, ""); // remove todas as barras do final
|
|
12
|
+
endpoint = "/" + endpoint.replace(/^\/+/, ""); // garante só uma barra no começo
|
|
13
|
+
|
|
14
|
+
this.baseUrl = baseUrl;
|
|
15
|
+
this.endpointBase = endpoint;
|
|
11
16
|
this.tokenJwt = tokenJwt;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
|
|
20
|
+
// cabeçalhos comuns para todas as requisições
|
|
21
|
+
|
|
15
22
|
private get headers(): HeadersInit {
|
|
16
23
|
const h: HeadersInit = { "Content-Type": "application/json" };
|
|
17
24
|
if (this.tokenJwt) h["Authorization"] = `Bearer ${this.tokenJwt}`;
|
|
18
25
|
return h;
|
|
19
26
|
}
|
|
20
27
|
|
|
28
|
+
// método para tratar respostas e erros comuns
|
|
29
|
+
|
|
21
30
|
private async handleResponse<T>(res: Response): Promise<T> {
|
|
22
31
|
if (!res.ok) throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
23
32
|
const envelope: ResultDto<T> = await res.json();
|
|
@@ -25,6 +34,12 @@ export abstract class CrudClientBase<TRequest, TResponse> {
|
|
|
25
34
|
return envelope.data;
|
|
26
35
|
}
|
|
27
36
|
|
|
37
|
+
// métodos CRUD genéricos
|
|
38
|
+
|
|
39
|
+
// OBS: perceba que eles são protegidos, ou seja, só podem ser chamados por classes derivadas
|
|
40
|
+
// não deve ser publico justamente porque eles acessam diretamente o endpoint base e são anêmicos
|
|
41
|
+
// as classes derivadas devem implementar métodos mais específicos
|
|
42
|
+
|
|
28
43
|
protected async getAsync(id: number): Promise<TResponse> {
|
|
29
44
|
const res = await fetch(`${this.baseUrl}${this.endpointBase}/${id}`, { headers: this.headers });
|
|
30
45
|
return this.handleResponse<TResponse>(res);
|
|
@@ -44,6 +59,11 @@ export abstract class CrudClientBase<TRequest, TResponse> {
|
|
|
44
59
|
headers: this.headers,
|
|
45
60
|
body: JSON.stringify(request),
|
|
46
61
|
});
|
|
62
|
+
|
|
63
|
+
console.log("URL chamada:", `${this.baseUrl}${this.endpointBase}`);
|
|
64
|
+
console.log("BODY:", JSON.stringify(request));
|
|
65
|
+
|
|
66
|
+
|
|
47
67
|
return this.handleResponse<TResponse>(res);
|
|
48
68
|
}
|
|
49
69
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnderecoBairroRequest, EnderecoBairroResponse } from "7vdomain";
|
|
2
|
-
import { CrudClientBase } from "../base/CrudClientBase
|
|
2
|
+
import { CrudClientBase } from "../base/CrudClientBase";
|
|
3
3
|
|
|
4
4
|
interface IEnderecoBairroClient
|
|
5
5
|
{
|
|
@@ -9,13 +9,14 @@ interface IEnderecoBairroClient
|
|
|
9
9
|
export class EnderecoBairroClient extends CrudClientBase<EnderecoBairroRequest, EnderecoBairroResponse>
|
|
10
10
|
implements IEnderecoBairroClient
|
|
11
11
|
{
|
|
12
|
-
constructor(
|
|
13
|
-
super(
|
|
12
|
+
constructor(Url: string, tokenJwt: string) {
|
|
13
|
+
super(Url, "api/endereco/bairro", tokenJwt);
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
|
|
15
17
|
public async postarBairro(nome: string, cidadeId: number): Promise<EnderecoBairroResponse> {
|
|
16
18
|
const _req: EnderecoBairroRequest = { Nome: nome, CidadeId: cidadeId };
|
|
17
19
|
const response = await this.postAsync(_req);
|
|
18
20
|
return response;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
+
}
|
|
21
22
|
}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import type { EnderecoCidadeRequest, EnderecoCidadeResponse } from "7vdomain";
|
|
2
|
-
import { CrudClientBase } from "../base/CrudClientBase
|
|
2
|
+
import { CrudClientBase } from "../base/CrudClientBase";
|
|
3
3
|
|
|
4
4
|
interface IEnderecoCidadeClient
|
|
5
5
|
{
|
|
6
|
-
postarEndereco(nome: string, codigoIbge:
|
|
6
|
+
postarEndereco(nome: string, codigoIbge: string, ufId: number): Promise<EnderecoCidadeResponse>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export class EnderecoCidadeClient
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
extends CrudClientBase<EnderecoCidadeRequest, EnderecoCidadeResponse>
|
|
11
|
+
implements IEnderecoCidadeClient
|
|
12
12
|
{
|
|
13
|
-
constructor(
|
|
14
|
-
|
|
13
|
+
constructor(Url: string , tokenJwt: string)
|
|
14
|
+
{
|
|
15
|
+
super(Url, "api/endereco/cidade", tokenJwt);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
public async postarEndereco(nome: string, codigoIbge:
|
|
18
|
+
public async postarEndereco(nome: string, codigoIbge: string, ufId: number): Promise<EnderecoCidadeResponse>
|
|
19
|
+
{
|
|
18
20
|
const _req: EnderecoCidadeRequest = { Nome: nome, CodigoIbge: codigoIbge, UfId: ufId };
|
|
19
21
|
const response = await this.postAsync(_req);
|
|
20
22
|
return response;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { EnderecoBairroRequest, EnderecoCidadeRequest, EnderecoRequest, EnderecoResponse, EnderecoTipoEnum } from "7vdomain";
|
|
2
|
+
import { CrudClientBase } from "../base/CrudClientBase";
|
|
3
|
+
|
|
4
|
+
import { EnderecoBairroClient } from "./EnderecoBairroClient";
|
|
5
|
+
import { EnderecoCidadeClient } from "./EnderecoCidadeClient";
|
|
6
|
+
|
|
7
|
+
interface IEnderecoSdk {
|
|
8
|
+
criarEndereco(enderecoCidade: EnderecoCidadeRequest, nomeBairro: string, nomeRua: string, enderecoTipo: EnderecoTipoEnum): Promise<EnderecoResponse>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class EnderecoSdk extends CrudClientBase<EnderecoRequest, EnderecoResponse>
|
|
12
|
+
implements IEnderecoSdk {
|
|
13
|
+
constructor(Url: string, tokenJwt: string) {
|
|
14
|
+
super(Url, "api/endereco/bairro", tokenJwt);
|
|
15
|
+
}
|
|
16
|
+
async criarEndereco(enderecoCidade: EnderecoCidadeRequest, nomeBairro: string, nomeRua: string, enderecoTipo: EnderecoTipoEnum): Promise<EnderecoResponse> {
|
|
17
|
+
const cidade: EnderecoCidadeRequest =
|
|
18
|
+
{
|
|
19
|
+
UfId: enderecoCidade.UfId,
|
|
20
|
+
Nome: enderecoCidade.Nome,
|
|
21
|
+
CodigoIbge: enderecoCidade.CodigoIbge
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const sendCidade = new EnderecoCidadeClient(this.baseUrl, this.tokenJwt);
|
|
25
|
+
// isso retornara um EnderecoCidadeResponse, que tem o Id necessario para criar o endereco
|
|
26
|
+
const cidadeResponse = await sendCidade.postarEndereco(cidade.Nome, cidade.CodigoIbge, cidade.UfId);
|
|
27
|
+
|
|
28
|
+
const bairro: EnderecoBairroRequest =
|
|
29
|
+
{
|
|
30
|
+
CidadeId: cidadeResponse.CidadeId,
|
|
31
|
+
Nome: nomeBairro
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
console.log("cidadeResponse:", cidadeResponse);
|
|
35
|
+
console.log("keys:", Object.keys(cidadeResponse));
|
|
36
|
+
const sendBairro = new EnderecoBairroClient(this.baseUrl, this.tokenJwt);
|
|
37
|
+
// isso retornara um EnderecoBairroResponse, que tem o Id necessario para criar o endereco
|
|
38
|
+
|
|
39
|
+
const bairroResponse = await sendBairro.postarBairro(bairro.Nome, bairro.CidadeId);
|
|
40
|
+
|
|
41
|
+
const endereco: EnderecoRequest =
|
|
42
|
+
{
|
|
43
|
+
BairroId: bairroResponse.EnderecoBairroId,
|
|
44
|
+
NomeRuaLogradouro: nomeRua,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// isso retornara um EnderecoResponse, que tem o Id necessario para criar o endereco
|
|
48
|
+
|
|
49
|
+
const enderecoResponse = await this.postAsync(endereco);
|
|
50
|
+
return enderecoResponse;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { UfRequest, UfResponse } from "7vdomain";
|
|
2
2
|
import { CrudClientBase } from "7vsdk-usuarios";
|
|
3
3
|
|
|
4
|
-
export class UfClient extends CrudClientBase<UfRequest, UfResponse>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
4
|
+
export class UfClient extends CrudClientBase<UfRequest, UfResponse>
|
|
5
|
+
{
|
|
6
|
+
constructor(Url: string , tokenJwt: string) {
|
|
7
|
+
super(Url, "api/endereco/uf", tokenJwt);
|
|
8
|
+
}
|
|
9
|
+
}
|
package/src/clients/index.ts
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import { PessoaResponse } from "7vdomain";
|
|
1
|
+
import { EnderecoRequest, PessoaResponse, PessoaTelefoneRequest } from "7vdomain";
|
|
2
2
|
import { PessoaRequest } from "7vdomain";
|
|
3
3
|
import { CrudClientBase } from "../base/CrudClientBase.js";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
interface IincluirClientes
|
|
6
|
+
{
|
|
7
|
+
incluirClientePj(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string): any
|
|
8
|
+
incluirClientePjCompleto(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string, enderecos: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): any
|
|
9
|
+
incluirClientePf(cnpjPai: string, cpfFilho: string, nome: string): any
|
|
10
|
+
incluirClientePfCompleto(cnpjPai: string, cpfFilho: string, nome: string, enderecos: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): any
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class PessoaClient extends CrudClientBase<PessoaRequest, PessoaResponse>
|
|
14
|
+
implements IincluirClientes
|
|
15
|
+
{
|
|
6
16
|
constructor(urlServer: string, tokenJwt: string);
|
|
7
17
|
constructor(server: { Url: string }, tokenJwt: string);
|
|
8
|
-
|
|
9
|
-
|
|
18
|
+
|
|
19
|
+
constructor(urlOrServer: string | { Url: string }, tokenJwt: string)
|
|
20
|
+
{
|
|
10
21
|
if (typeof urlOrServer === 'string') {
|
|
11
22
|
super(urlOrServer, '/api/pessoa', tokenJwt);
|
|
12
23
|
} else {
|
|
@@ -14,6 +25,31 @@ export class PessoaClient extends CrudClientBase<PessoaResponse, PessoaRequest>
|
|
|
14
25
|
}
|
|
15
26
|
}
|
|
16
27
|
|
|
28
|
+
async postarPessoa(nome: string, sexo: string): Promise<PessoaResponse> {
|
|
29
|
+
if (sexo !== "H" && sexo !== "M") throw new Error("Sexo inválido");
|
|
30
|
+
const req: PessoaRequest = { Nome: nome, Sexo: sexo };
|
|
31
|
+
const res = await this.postAsync(req);
|
|
32
|
+
return res;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async incluirClientePj(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string)
|
|
36
|
+
{
|
|
37
|
+
|
|
38
|
+
}
|
|
17
39
|
|
|
40
|
+
async incluirClientePjCompleto(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string, enderecos: EnderecoRequest[], telefones: PessoaTelefoneRequest[])
|
|
41
|
+
{
|
|
42
|
+
|
|
43
|
+
}
|
|
18
44
|
|
|
45
|
+
async incluirClientePf(cnpjPai: string, cpfFilho: string, nome: string)
|
|
46
|
+
{
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async incluirClientePfCompleto(cnpjPai: string, cpfFilho: string, nome: string, enderecos: EnderecoRequest[], telefones: PessoaTelefoneRequest[])
|
|
51
|
+
{
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
19
55
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EmpresaRequest, EmpresaResponse } from "7vdomain";
|
|
2
|
+
import { CrudClientBase } from "clients/base";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class EmpresaSdk extends CrudClientBase<EmpresaRequest, EmpresaResponse>
|
|
7
|
+
{
|
|
8
|
+
constructor(Url: string, tokenJwt: string) {
|
|
9
|
+
super(Url, "api/portalcontador/empresa", tokenJwt);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ImpostoEstadualRequest, ImpostoEstadualResponse, ImpostoFederalRequest } from "7vdomain";
|
|
2
|
+
import { CrudClientBase } from "clients/base";
|
|
3
|
+
|
|
4
|
+
interface IImpostoFederalSdk
|
|
5
|
+
{
|
|
6
|
+
criarImpostoEstadual(request: ImpostoEstadualRequest): Promise<ImpostoEstadualResponse>;
|
|
7
|
+
pegarImpostoEstadual(id: number): Promise<ImpostoEstadualResponse>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class ImpostoEstadualSdk extends CrudClientBase<ImpostoEstadualRequest, ImpostoEstadualResponse>
|
|
11
|
+
implements IImpostoFederalSdk
|
|
12
|
+
{
|
|
13
|
+
constructor(Url: string , tokenJwt: string) {
|
|
14
|
+
super(Url, "portal-contador/imposto/estadual", tokenJwt);
|
|
15
|
+
}
|
|
16
|
+
async criarImpostoEstadual(request: ImpostoEstadualRequest): Promise<ImpostoEstadualResponse> {
|
|
17
|
+
return await this.postAsync(request);
|
|
18
|
+
}
|
|
19
|
+
async pegarImpostoEstadual(id: number): Promise<ImpostoEstadualResponse> {
|
|
20
|
+
return await this.getAsync(id);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ImpostoFederalRequest, ImpostoFederalResponse } from "7vdomain";
|
|
2
|
+
import { CrudClientBase } from "clients/base";
|
|
3
|
+
|
|
4
|
+
interface IImpostoFederalSdk
|
|
5
|
+
{
|
|
6
|
+
criarImpostoFederal(request: ImpostoFederalRequest): Promise<ImpostoFederalResponse>;
|
|
7
|
+
pegarImpostoFederal(id: number): Promise<ImpostoFederalResponse>;
|
|
8
|
+
deletarImpostoFederal(id: number): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class ImpostoFederalSdk extends CrudClientBase<ImpostoFederalRequest, ImpostoFederalResponse>
|
|
12
|
+
implements IImpostoFederalSdk
|
|
13
|
+
{
|
|
14
|
+
constructor(Url: string, tokenJwt: string) {
|
|
15
|
+
super(Url, "portal-contador/imposto/federal", tokenJwt);
|
|
16
|
+
}
|
|
17
|
+
async criarImpostoFederal(request: ImpostoFederalRequest): Promise<ImpostoFederalResponse> {
|
|
18
|
+
return await this.postAsync(request);
|
|
19
|
+
}
|
|
20
|
+
async pegarImpostoFederal(id: number): Promise<ImpostoFederalResponse> {
|
|
21
|
+
return await this.getAsync(id);
|
|
22
|
+
}
|
|
23
|
+
async deletarImpostoFederal(id: number): Promise<void> {
|
|
24
|
+
return await this.deleteAsync(id);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"module": "CommonJS",
|
|
4
4
|
"target": "ES2020",
|
|
5
|
-
"
|
|
5
|
+
"baseUrl": "src",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"declaration": true,
|
|
6
9
|
"esModuleInterop": true,
|
|
7
|
-
"
|
|
8
|
-
"baseUrl": ".",
|
|
9
|
-
"paths": {
|
|
10
|
-
"*": ["node_modules/*"]
|
|
11
|
-
}
|
|
10
|
+
"moduleResolution": "Node"
|
|
12
11
|
},
|
|
13
12
|
"include": ["src"]
|
|
14
13
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./src/index.ts","./src/test.ts","./src/clients/index.ts","./src/clients/base/crudclientbase.ts","./src/clients/base/index.ts","./src/clients/enderecos/enderecobairroclient.ts","./src/clients/enderecos/enderecocidadeclient.ts","./src/clients/enderecos/enderecosdk.ts","./src/clients/enderecos/ufclient.ts","./src/clients/enderecos/index.ts","./src/clients/pessoas/pessoaclient.ts","./src/clients/pessoas/pessoacnpjclient.ts","./src/clients/pessoas/pessoacpfclient.ts","./src/clients/pessoas/pessoaemailclient.ts","./src/clients/pessoas/pessoaenderecoclient.ts","./src/clients/pessoas/pessoanascimentoclient.ts","./src/clients/pessoas/pessoanecessidadeespecial.ts","./src/clients/pessoas/pessoaprocedimentoclient.ts","./src/clients/pessoas/pessoarelacaoclient.ts","./src/clients/pessoas/pessoarelacaogrupoclient.ts","./src/clients/pessoas/pessoarelacaotipoclient.ts","./src/clients/pessoas/pessoatelefoneclient.ts","./src/clients/pessoas/pessoatipoclient.ts","./src/clients/pessoas/index.ts"],"version":"5.9.3"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { EnderecoRequest, EnderecoResponse } from "7vdomain";
|
|
2
|
-
import { CrudClientBase } from "../base/CrudClientBase.js";
|
|
3
|
-
|
|
4
|
-
interface IEnderecoClient
|
|
5
|
-
{
|
|
6
|
-
postarEndereco(nomeRuaLog: string, bairroId: number): Promise<EnderecoResponse>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class EnderecoClient extends CrudClientBase<EnderecoRequest,EnderecoResponse>
|
|
10
|
-
implements IEnderecoClient
|
|
11
|
-
{
|
|
12
|
-
constructor(Url: string , tokenJwt: string) {
|
|
13
|
-
super(Url, "api/endereco/bairro", tokenJwt);
|
|
14
|
-
}
|
|
15
|
-
async postarEndereco(nomeRuaLog: string, bairroId: number): Promise<EnderecoResponse> {
|
|
16
|
-
const _req: EnderecoRequest = {NomeRuaLogradouro: nomeRuaLog, BairroId: bairroId}
|
|
17
|
-
const _res = await this.postAsync(_req);
|
|
18
|
-
return _res;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { EnderecoTipoRequest, EnderecoTipoResponse } from "7vdomain";
|
|
2
|
-
import { CrudClientBase } from "../base/CrudClientBase.js";
|
|
3
|
-
|
|
4
|
-
interface IEnderecoTipoClient
|
|
5
|
-
{
|
|
6
|
-
postarEnderecoTipo(nome: string): Promise<EnderecoTipoResponse>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export class EnderecoTipoClient extends CrudClientBase<EnderecoTipoRequest, EnderecoTipoResponse>
|
|
10
|
-
implements IEnderecoTipoClient
|
|
11
|
-
{
|
|
12
|
-
constructor(server: { Url: string }, tokenJwt: string) {
|
|
13
|
-
super(server.Url, "api/endereco/bairro", tokenJwt);
|
|
14
|
-
}
|
|
15
|
-
async postarEnderecoTipo(nome: string): Promise<EnderecoTipoResponse> {
|
|
16
|
-
const _req: EnderecoTipoRequest = {Nome: nome}
|
|
17
|
-
const res = await this.postAsync(_req);
|
|
18
|
-
return res;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { EnderecoClient } from "../enderecos";
|
|
2
|
-
import { EmpresaRequest, EmpresaResponse, EnderecoRequest, PessoaTelefoneRequest } from "7vdomain"
|
|
3
|
-
import { CrudClientBase } from "7vsdk-usuarios";
|
|
4
|
-
import { PesosaTelefoneClient } from "../pessoas/PessoaTelefoneClient";
|
|
5
|
-
|
|
6
|
-
export class EmpresaClient extends CrudClientBase<EmpresaRequest, EmpresaResponse>
|
|
7
|
-
{
|
|
8
|
-
private empresa: EmpresaRequest;
|
|
9
|
-
private _url: string;
|
|
10
|
-
private _tok: string;
|
|
11
|
-
|
|
12
|
-
constructor(url: string, token: string) {
|
|
13
|
-
super(url, "portal-contador/empresas", token);
|
|
14
|
-
this._url = url;
|
|
15
|
-
this._tok = token;
|
|
16
|
-
this.empresa = {} as EmpresaRequest;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public async incluirEmpresaRoot(cnpj: string, razaoSocial: string)
|
|
20
|
-
{
|
|
21
|
-
this.empresa.Cnpj = cnpj;
|
|
22
|
-
this.empresa.RazaoSocial = razaoSocial;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public async incluirEmpresaRootCompleto(cnpj: string, razaoSocial: string, enderecos: EnderecoRequest[], telefones: PessoaTelefoneRequest[])
|
|
26
|
-
{
|
|
27
|
-
this.empresa.Cnpj = cnpj;
|
|
28
|
-
this.empresa.RazaoSocial = razaoSocial;
|
|
29
|
-
const _endereco: EnderecoClient = new EnderecoClient(this._url, this._tok);
|
|
30
|
-
const _telefone: PesosaTelefoneClient = new PesosaTelefoneClient(this._url, this._tok);
|
|
31
|
-
for(const endereco of enderecos)
|
|
32
|
-
{
|
|
33
|
-
await _endereco.postarEndereco(endereco.NomeRuaLogradouro, endereco.BairroId);
|
|
34
|
-
}
|
|
35
|
-
for(const pessoaTelefone of telefones)
|
|
36
|
-
{
|
|
37
|
-
await _telefone.postarTelefone(pessoaTelefone.Numero, pessoaTelefone.PessoaId, pessoaTelefone.TelefoneTipoId);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|