7vsdk-pessoas 1.0.21 → 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/package.json
CHANGED
|
@@ -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<
|
|
5
|
-
constructor(
|
|
6
|
-
super(
|
|
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
|
-
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
24
|
+
async incluirEmpresaRootCompleto(cnpj: string, razaoSocial: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>
|
|
25
|
+
{
|
|
26
|
+
|
|
27
|
+
}
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
async incluirClientePj(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string): Promise<void>
|
|
30
|
+
{
|
|
28
31
|
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
async incluirClientePjCompleto(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>
|
|
35
|
+
{
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
}
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
async incluirClientePf(cnpjPai: string, cpfFilho: string, nomeCompletoFilho: string): Promise<void>
|
|
40
|
+
{
|
|
36
41
|
|
|
37
|
-
|
|
42
|
+
}
|
|
38
43
|
|
|
39
|
-
|
|
44
|
+
async incluirClientePfCompleto(cnpjPai: string, cpfFilho: string, nomeCompletoFilho: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>
|
|
45
|
+
{
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
}
|
|
42
48
|
}
|