7vsdk-pessoas 1.0.20 → 1.0.22

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.
@@ -7,9 +7,6 @@ class PessoaClient extends CrudClientBase_js_1.CrudClientBase {
7
7
  if (typeof urlOrServer === 'string') {
8
8
  super(urlOrServer, '/api/pessoa', tokenJwt);
9
9
  }
10
- else {
11
- super(urlOrServer.Url, '/api/pessoa', tokenJwt);
12
- }
13
10
  }
14
11
  async postarPessoa(nome, sexo) {
15
12
  return this.postAsync({ Nome: nome, Sexo: sexo });
package/dist/index.d.ts CHANGED
@@ -1,4 +1 @@
1
- export * from "./clients/pessoas";
2
- export * from "./clients/enderecos";
3
- export * from "./clients/base";
4
- export * from "./clients/portalContador";
1
+ export * from "./clients";
package/dist/index.js CHANGED
@@ -14,7 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./clients/pessoas"), exports); // exporta todos os clients de pessoas
18
- __exportStar(require("./clients/enderecos"), exports); // exporta todos os clients de endereços
19
- __exportStar(require("./clients/base"), exports); // exporta classes base, se necessário
20
- __exportStar(require("./clients/portalContador"), exports);
17
+ __exportStar(require("./clients"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "7vsdk-pessoas",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -3,6 +3,7 @@ import type { ResultDto } from "7vdomain";
3
3
  // essa classe base pode ser reutilizada para qualquer cliente CRUD
4
4
 
5
5
  export abstract class CrudClientBase<TRequest, TResponse> {
6
+
6
7
  protected baseUrl: string;
7
8
  protected endpointBase: string;
8
9
  protected tokenJwt?: string;
@@ -20,16 +20,12 @@ implements IPessoaClient
20
20
  {
21
21
  if (typeof urlOrServer === 'string') {
22
22
  super(urlOrServer, '/api/pessoa', tokenJwt);
23
- } else {
24
- super(urlOrServer.Url, '/api/pessoa', tokenJwt);
25
23
  }
26
24
  }
27
25
 
28
26
  async postarPessoa(nome: string, sexo: string): Promise<PessoaResponse> {
29
27
  return this.postAsync({ Nome: nome, Sexo: sexo } as PessoaRequest);
30
28
  }
31
-
32
-
33
29
  async pegarPessoa(id: number): Promise<PessoaResponse> {
34
30
  return await this.getAsync(id);
35
31
  }
@@ -1,8 +1,22 @@
1
1
  import type { PessoaCnpjRequest, PessoaCnpjResponse } from "7vdomain";
2
2
  import { CrudClientBase } from "../base/CrudClientBase.js";
3
3
 
4
- export class PessoaCnpjClient extends CrudClientBase<PessoaCnpjResponse, PessoaCnpjRequest> {
5
- constructor(server: { Url: string }, tokenJwt: string) {
6
- super(server.Url, "api/pessoa/cnpj", tokenJwt);
4
+ export class PessoaCnpjClient extends CrudClientBase<PessoaCnpjRequest, PessoaCnpjResponse> {
5
+ constructor(Url: string, tokenJwt: string) {
6
+ super(Url, "api/pessoa/cnpj", tokenJwt);
7
+ }
8
+
9
+ async postarPessoaCnpj(pessoaId: number, numero: string, ie: string, regimeTributario: number, lucroReal: boolean, industria: boolean): Promise<PessoaCnpjResponse> {
10
+ const request: PessoaCnpjRequest = {
11
+ Ie: ie,
12
+ Numero: numero,
13
+ PessoaId: pessoaId,
14
+ RegimeTributario: regimeTributario,
15
+ LucroReal: lucroReal,
16
+ Industria: industria
17
+ };
18
+ return await this.postAsync(request);
7
19
  }
8
20
  }
21
+
22
+
@@ -1,42 +1,48 @@
1
- import { EmpresaRequest, EmpresaResponse } from "7vdomain";
1
+ import { EmpresaRequest, EmpresaResponse, EnderecoRequest, PessoaResponse, PessoaTelefoneRequest } from "7vdomain";
2
2
  import { CrudClientBase } from "../base";
3
-
4
- interface IEmpresaSdk
5
- {
6
- criarEmpresa(request: EmpresaRequest): Promise<EmpresaResponse>;
7
- pegarEmpresa(id: number): Promise<EmpresaResponse>;
8
- deletarEmpresa(id: number): Promise<void>;
9
- pegarEmpresaPaginacao(page: number, size: number): Promise<EmpresaResponse[]>;
10
- }
3
+ import { PessoaClient, PessoaCnpjClient } from "../pessoas";
4
+ import { EnderecoCidadeClient } from "../enderecos/EnderecoCidadeClient";
11
5
 
12
6
  export class EmpresaSdk extends CrudClientBase<EmpresaRequest, EmpresaResponse>
13
- implements IEmpresaSdk
14
7
  {
8
+ private pessoaSdk: PessoaClient = new PessoaClient(this.baseUrl, this.tokenJwt!);
9
+ private enderecoSdk: EnderecoCidadeClient = new EnderecoCidadeClient(this.baseUrl, this.tokenJwt!);
10
+ private pessoaCnpj: PessoaCnpjClient = new PessoaCnpjClient(this.baseUrl, this.tokenJwt!);
11
+
15
12
  constructor(Url: string, tokenJwt: string) {
16
13
  super(Url, "portal-contador/empresa", tokenJwt);
17
14
  }
18
15
 
19
- async criarEmpresa(request: EmpresaRequest): Promise<EmpresaResponse> {
20
-
21
- return await this.postAsync(request);
22
-
16
+ async criarEmpresaRoot(cnpj: string, ie: string, regimeTributario: number, razaoSocial: string, lucroReal: boolean, industria: boolean): Promise<void>
17
+ {
18
+ if(regimeTributario < 1 || regimeTributario > 3)
19
+ throw new Error("Regime tributário inválido. Use 1 para Simples Nacional, 2 para Lucro Presumido ou 3 para Lucro Real.");
20
+ const pessoaMandou: PessoaResponse = await this.pessoaSdk.postarPessoa(razaoSocial, "I");
21
+ await this.pessoaCnpj.postarPessoaCnpj(pessoaMandou.PessoaId, cnpj, ie, regimeTributario, lucroReal, industria);
23
22
  }
24
23
 
25
- async pegarEmpresa(id: number): Promise<EmpresaResponse> {
24
+ async incluirEmpresaRootCompleto(cnpj: string, razaoSocial: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>
25
+ {
26
+
27
+ }
26
28
 
27
- return await this.getAsync(id);
29
+ async incluirClientePj(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string): Promise<void>
30
+ {
28
31
 
29
32
  }
30
33
 
31
- async deletarEmpresa(id: number): Promise<void> {
34
+ async incluirClientePjCompleto(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>
35
+ {
32
36
 
33
- return await this.deleteAsync(id);
37
+ }
34
38
 
35
- }
39
+ async incluirClientePf(cnpjPai: string, cpfFilho: string, nomeCompletoFilho: string): Promise<void>
40
+ {
36
41
 
37
- async pegarEmpresaPaginacao(page: number, size: number): Promise<EmpresaResponse[]> {
42
+ }
38
43
 
39
- return await this.getPagedAsync(page, size);
44
+ async incluirClientePfCompleto(cnpjPai: string, cpfFilho: string, nomeCompletoFilho: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>
45
+ {
40
46
 
41
- }
47
+ }
42
48
  }
package/dist/test.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/test.js DELETED
@@ -1,27 +0,0 @@
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();