sgp-sdk 0.0.0-stage → 1.2.0

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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +303 -2
  3. package/dist/client.d.ts +228 -0
  4. package/dist/endpoint.d.ts +66 -0
  5. package/dist/endpoints/crm/address.d.ts +20 -0
  6. package/dist/endpoints/crm/create-contract.d.ts +109 -0
  7. package/dist/endpoints/crm/create-customer.d.ts +65 -0
  8. package/dist/endpoints/crm/update-customer-status.d.ts +43 -0
  9. package/dist/endpoints/os/list-occurrence-reasons.d.ts +24 -0
  10. package/dist/endpoints/os/list-occurrence-types.d.ts +25 -0
  11. package/dist/endpoints/precadastro/list-due-days.d.ts +19 -0
  12. package/dist/endpoints/precadastro/list-sellers.d.ts +21 -0
  13. package/dist/endpoints/suporte/add-customer-document.d.ts +24 -0
  14. package/dist/endpoints/suporte/list-customer-documents.d.ts +25 -0
  15. package/dist/endpoints/ura/check-coverage.d.ts +46 -0
  16. package/dist/endpoints/ura/list-annotations.d.ts +32 -0
  17. package/dist/endpoints/ura/list-clients.d.ts +58 -0
  18. package/dist/endpoints/ura/list-contracts.d.ts +45 -0
  19. package/dist/endpoints/ura/list-invoices.d.ts +107 -0
  20. package/dist/endpoints/ura/list-nas.d.ts +29 -0
  21. package/dist/endpoints/ura/list-occurrence-methods.d.ts +19 -0
  22. package/dist/endpoints/ura/list-payment-carriers.d.ts +20 -0
  23. package/dist/endpoints/ura/list-plans.d.ts +70 -0
  24. package/dist/endpoints/ura/list-pops.d.ts +19 -0
  25. package/dist/endpoints/ura/list-service-orders.d.ts +64 -0
  26. package/dist/endpoints/ura/lookup-customer.d.ts +121 -0
  27. package/dist/endpoints/ura/open-ticket.d.ts +81 -0
  28. package/dist/errors.d.ts +59 -0
  29. package/dist/index.d.ts +50 -0
  30. package/dist/index.js +1449 -0
  31. package/dist/result.d.ts +55 -0
  32. package/dist/schema/parse.d.ts +19 -0
  33. package/dist/schema/paths.d.ts +38 -0
  34. package/dist/sensitivity.d.ts +7 -0
  35. package/dist/transport.d.ts +65 -0
  36. package/package.json +34 -4
@@ -0,0 +1,107 @@
1
+ import { z } from "zod";
2
+ import type { EndpointDefinition } from "../../endpoint.js";
3
+ /** Response of `POST /api/ura/titulos/`: one page of invoices (titulos). */
4
+ export declare const listInvoicesSchema: z.ZodObject<{
5
+ paginacao: z.ZodObject<{
6
+ offset: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
7
+ limit: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
8
+ parcial: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
9
+ total: z.ZodNumber;
10
+ }, z.core.$strip>;
11
+ titulos: z.ZodArray<z.ZodObject<{
12
+ id: z.ZodNumber;
13
+ status: z.ZodString;
14
+ valor: z.ZodNumber;
15
+ dataVencimento: z.ZodString;
16
+ clienteNome: z.ZodNullable<z.ZodOptional<z.ZodString>>;
17
+ clienteCpfcnpj: z.ZodNullable<z.ZodOptional<z.ZodString>>;
18
+ clienteContrato: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
19
+ portador: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
+ numeroDocumento: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
21
+ nossoNumero: z.ZodNullable<z.ZodOptional<z.ZodString>>;
22
+ link: z.ZodNullable<z.ZodOptional<z.ZodString>>;
23
+ link_cobranca: z.ZodNullable<z.ZodOptional<z.ZodString>>;
24
+ valorDesconto: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
25
+ valorCorrigido: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
26
+ valorPago: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
27
+ valorPagoParcial: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
28
+ codigoBarras: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
+ linhaDigitavel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
30
+ codigoPix: z.ZodNullable<z.ZodOptional<z.ZodString>>;
31
+ dataEmissao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
32
+ dataPagamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
33
+ dataCancelamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
34
+ demonstrativo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
35
+ acordoPagamento: z.ZodNullable<z.ZodOptional<z.ZodObject<{
36
+ acordados: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
37
+ cobrados: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
38
+ }, z.core.$strip>>>;
39
+ formaPagamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
40
+ usuario_baixa: z.ZodNullable<z.ZodOptional<z.ZodString>>;
41
+ }, z.core.$strip>>;
42
+ }, z.core.$strip>;
43
+ /** Key fields of `ura/titulos`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
44
+ export declare const listInvoicesKeyFields: readonly ["paginacao.total", "titulos", "titulos[].id", "titulos[].status", "titulos[].valor", "titulos[].dataVencimento"];
45
+ /** Normalized path of each invoice in the `ura/titulos` response. */
46
+ export declare const invoiceItemPath = "titulos[]";
47
+ /** Keys of an invoice holding secrets (none in `ura/titulos`). */
48
+ export declare const invoiceSecretKeys: readonly [];
49
+ /**
50
+ * Keys of an invoice holding personal data: customer name and CPF/CNPJ, the statement text, the
51
+ * payment links and the PIX code.
52
+ *
53
+ * `link` and `link_cobranca` open the boleto, which prints the payer's name, CPF/CNPJ and address,
54
+ * and a dynamic PIX code may resolve to the debtor. `codigoBarras`, `linhaDigitavel`, `nossoNumero`
55
+ * and `usuario_baixa` are deliberately not classified.
56
+ */
57
+ export declare const invoicePersonalKeys: readonly ["clienteNome", "clienteCpfcnpj", "demonstrativo", "link", "link_cobranca", "codigoPix"];
58
+ /**
59
+ * Body parameters of `POST /api/ura/titulos/` (besides credentials); all optional filters, paging
60
+ * and ordering, with the names and choices of SGP's public Postman collection.
61
+ */
62
+ export interface ListInvoicesParams {
63
+ /** Offset of the query; SGP starts at 0. */
64
+ offset?: number;
65
+ /** Page size; SGP documents a maximum of 250. */
66
+ limit?: number;
67
+ /** Invoice (titulo) ID. */
68
+ titulo_id?: number;
69
+ /** ID of the client linked to the invoices. */
70
+ cliente_id?: number;
71
+ /** CPF or CNPJ of the client linked to the invoices. */
72
+ cpfcnpj?: string;
73
+ /** ID of the service contract linked to the invoices. */
74
+ contrato?: number;
75
+ /** Invoice status filter. */
76
+ status?: "abertos" | "pagos" | "cancelados";
77
+ /** ID of the payment carrier (portador) that generated the invoices. */
78
+ portador?: number;
79
+ /** Field the invoices are ordered by. */
80
+ ordenar?: "data_documento" | "data_vencimento" | "data_pagamento";
81
+ /** Ascending or descending order. */
82
+ ordenar_ordem?: "asc" | "desc";
83
+ /** CNPJ of the company that issued the invoices; several allowed, separated by comma. */
84
+ empresa_cnpj?: string;
85
+ /** Person type linked to the invoices: F (individual), J (company), E (foreign individual), EJ (foreign company). */
86
+ tipo_pessoa?: "F" | "J" | "E" | "EJ";
87
+ /** Initial due date, `AAAA-MM-DD`; required when `data_vencimento_fim` is sent. */
88
+ data_vencimento_inicio?: string;
89
+ /** Final due date, `AAAA-MM-DD`. */
90
+ data_vencimento_fim?: string;
91
+ /** Initial payment date, `AAAA-MM-DD`; required when `data_pagamento_fim` is sent. */
92
+ data_pagamento_inicio?: string;
93
+ /** Final payment date, `AAAA-MM-DD`. */
94
+ data_pagamento_fim?: string;
95
+ /** Initial cancellation date, `AAAA-MM-DD`; alone, matches invoices cancelled on that day. */
96
+ data_cancelamento_inicio?: string;
97
+ /** Final cancellation date, `AAAA-MM-DD`; use with the initial one. */
98
+ data_cancelamento_fim?: string;
99
+ /** Initial date on which payment-agreement invoices were generated, `AAAA-MM-DD`; alone, matches that day. */
100
+ data_acordo_inicio?: string;
101
+ /** Final date on which payment-agreement invoices were generated, `AAAA-MM-DD`. */
102
+ data_acordo_fim?: string;
103
+ }
104
+ /** Parsed response of `POST /api/ura/titulos/`. */
105
+ export type ListInvoicesResponse = z.output<typeof listInvoicesSchema>;
106
+ /** Definition of `POST /api/ura/titulos/`. */
107
+ export declare const listInvoicesDefinition: EndpointDefinition<typeof listInvoicesSchema>;
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ import type { EndpointDefinition } from "../../endpoint.js";
3
+ /** Response of `POST /api/ura/nas/list/`: a bare array with the NAS (network access servers) and the POPs each serves. */
4
+ export declare const listNasSchema: z.ZodArray<z.ZodObject<{
5
+ id: z.ZodNumber;
6
+ descricao: z.ZodString;
7
+ identificador: z.ZodString;
8
+ endereco_ip: z.ZodNullable<z.ZodOptional<z.ZodString>>;
9
+ ativo: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
10
+ pops: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
11
+ id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
12
+ cidade: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
+ uf: z.ZodNullable<z.ZodOptional<z.ZodString>>;
14
+ codigo_ibge: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
15
+ ativo: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
16
+ }, z.core.$strip>>>>;
17
+ }, z.core.$strip>>;
18
+ /** Key fields of `ura/nas/list`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
19
+ export declare const listNasKeyFields: readonly ["[].id", "[].descricao", "[].identificador"];
20
+ /** Normalized path of each NAS in the `ura/nas/list` response (the root array). */
21
+ export declare const nasItemPath = "[]";
22
+ /** Keys of a NAS holding secrets: its IP address, which is network infrastructure. */
23
+ export declare const nasSecretKeys: readonly ["endereco_ip"];
24
+ /** Keys of a NAS holding personal data (none in `ura/nas/list`). */
25
+ export declare const nasPersonalKeys: readonly [];
26
+ /** Parsed response of `POST /api/ura/nas/list/`. */
27
+ export type ListNasResponse = z.output<typeof listNasSchema>;
28
+ /** Definition of `POST /api/ura/nas/list/`. */
29
+ export declare const listNasDefinition: EndpointDefinition<typeof listNasSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ import type { EndpointDefinition } from "../../endpoint.js";
3
+ /** Response of `GET /api/ura/ocorrencia/metodo/list/`: a bare array with the occurrence methods. */
4
+ export declare const listOccurrenceMethodsSchema: z.ZodArray<z.ZodObject<{
5
+ codigo: z.ZodNumber;
6
+ descricao: z.ZodString;
7
+ }, z.core.$strip>>;
8
+ /** Key fields of `ura/ocorrencia/metodo/list`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
9
+ export declare const listOccurrenceMethodsKeyFields: readonly ["[].codigo", "[].descricao"];
10
+ /** Normalized path of each method in the `ura/ocorrencia/metodo/list` response (the root array). */
11
+ export declare const occurrenceMethodItemPath = "[]";
12
+ /** Keys of an occurrence method holding secrets (none in `ura/ocorrencia/metodo/list`). */
13
+ export declare const occurrenceMethodSecretKeys: readonly [];
14
+ /** Keys of an occurrence method holding personal data (none in `ura/ocorrencia/metodo/list`). */
15
+ export declare const occurrenceMethodPersonalKeys: readonly [];
16
+ /** Parsed response of `GET /api/ura/ocorrencia/metodo/list/`. */
17
+ export type ListOccurrenceMethodsResponse = z.output<typeof listOccurrenceMethodsSchema>;
18
+ /** Definition of `GET /api/ura/ocorrencia/metodo/list/`. */
19
+ export declare const listOccurrenceMethodsDefinition: EndpointDefinition<typeof listOccurrenceMethodsSchema>;
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+ import type { EndpointDefinition } from "../../endpoint.js";
3
+ /** Response of `GET /api/ura/portador/`: a bare array with the payment carriers (portadores). */
4
+ export declare const listPaymentCarriersSchema: z.ZodArray<z.ZodObject<{
5
+ id: z.ZodNumber;
6
+ descricao: z.ZodString;
7
+ codigo_banco: z.ZodNullable<z.ZodOptional<z.ZodString>>;
8
+ }, z.core.$strip>>;
9
+ /** Key fields of `ura/portador`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
10
+ export declare const listPaymentCarriersKeyFields: readonly ["[].id", "[].descricao"];
11
+ /** Normalized path of each carrier in the `ura/portador` response (the root array). */
12
+ export declare const paymentCarrierItemPath = "[]";
13
+ /** Keys of a payment carrier holding secrets (none in `ura/portador`). */
14
+ export declare const paymentCarrierSecretKeys: readonly [];
15
+ /** Keys of a payment carrier holding personal data (none in `ura/portador`). */
16
+ export declare const paymentCarrierPersonalKeys: readonly [];
17
+ /** Parsed response of `GET /api/ura/portador/`. */
18
+ export type ListPaymentCarriersResponse = z.output<typeof listPaymentCarriersSchema>;
19
+ /** Definition of `GET /api/ura/portador/`. */
20
+ export declare const listPaymentCarriersDefinition: EndpointDefinition<typeof listPaymentCarriersSchema>;
@@ -0,0 +1,70 @@
1
+ import { z } from "zod";
2
+ import type { EndpointDefinition } from "../../endpoint.js";
3
+ /** Response of `GET /api/ura/consultaplano/`: the plan catalog with its totals. */
4
+ export declare const listPlansSchema: z.ZodObject<{
5
+ planos: z.ZodArray<z.ZodObject<{
6
+ id: z.ZodNumber;
7
+ descricao: z.ZodString;
8
+ preco: z.ZodNumber;
9
+ ativo: z.ZodBoolean;
10
+ grupo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
11
+ tipo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
12
+ pos_pago: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
13
+ desconto: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
14
+ desconto_venc: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
15
+ desconto_venc_modo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
16
+ valor_desconto_temporario: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
17
+ desconto_temporario_modo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
18
+ desconto_temporario_quantidade: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
19
+ descricao_desconto_temporario: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
+ desconto_temporario_proporcional: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
21
+ observacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
22
+ instalacao_qtd_parcelas: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
23
+ instalacao_valor: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
24
+ instalacao_desconto_max: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
25
+ instalacao_desconto_min: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
26
+ disponivel_pre_cadastro: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
27
+ disponivel_pre_cadastro_publico: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
28
+ data_validade: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
+ pops: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
30
+ id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
31
+ uf: z.ZodNullable<z.ZodOptional<z.ZodString>>;
32
+ pop: z.ZodNullable<z.ZodOptional<z.ZodString>>;
33
+ }, z.core.$strip>>>>;
34
+ auto_bloqueio: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
35
+ dias_bloqueio_pos_venc: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
36
+ dias_bloqueio_aviso: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
37
+ dias_reducao_velocidade: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
38
+ download: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
39
+ upload: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
40
+ trafego_mensal: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
41
+ contabilizacao_trafego_mensal: z.ZodNullable<z.ZodOptional<z.ZodString>>;
42
+ trafego_excedente_acao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
43
+ valor_trafego_excedido: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
44
+ duplicacao_noturna: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
45
+ inicio_duplicacao_noturna: z.ZodNullable<z.ZodOptional<z.ZodString>>;
46
+ fim_duplicacao_noturna: z.ZodNullable<z.ZodOptional<z.ZodString>>;
47
+ modo_velocidade_reduzida: z.ZodNullable<z.ZodOptional<z.ZodString>>;
48
+ download_red_financeiro: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
49
+ upload_red_financeiro: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
50
+ modo_velocidade_red_franquia: z.ZodNullable<z.ZodOptional<z.ZodString>>;
51
+ download_red_franquia: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
52
+ upload_red_franquia: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
53
+ combo: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
54
+ qtd_servicos: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
55
+ }, z.core.$strip>>;
56
+ total_planos: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
57
+ total_qtd_servicos: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
58
+ }, z.core.$strip>;
59
+ /** Key fields of `ura/consultaplano`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
60
+ export declare const listPlansKeyFields: readonly ["planos", "planos[].id", "planos[].descricao", "planos[].preco", "planos[].ativo"];
61
+ /** Normalized path of each plan in the `ura/consultaplano` response. */
62
+ export declare const planItemPath = "planos[]";
63
+ /** Keys of a plan holding secrets (none in `ura/consultaplano`). */
64
+ export declare const planSecretKeys: readonly [];
65
+ /** Keys of a plan holding personal data (none in `ura/consultaplano`). */
66
+ export declare const planPersonalKeys: readonly [];
67
+ /** Parsed response of `GET /api/ura/consultaplano/`. */
68
+ export type ListPlansResponse = z.output<typeof listPlansSchema>;
69
+ /** Definition of `GET /api/ura/consultaplano/`. */
70
+ export declare const listPlansDefinition: EndpointDefinition<typeof listPlansSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ import type { EndpointDefinition } from "../../endpoint.js";
3
+ /** Response of `POST /api/ura/pops/`: a bare array with the POPs (points of presence). */
4
+ export declare const listPopsSchema: z.ZodArray<z.ZodObject<{
5
+ id: z.ZodNumber;
6
+ pop: z.ZodString;
7
+ }, z.core.$strip>>;
8
+ /** Key fields of `ura/pops`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
9
+ export declare const listPopsKeyFields: readonly ["[].id", "[].pop"];
10
+ /** Normalized path of each POP in the `ura/pops` response (the root array). */
11
+ export declare const popItemPath = "[]";
12
+ /** Keys of a POP holding secrets (none in `ura/pops`). */
13
+ export declare const popSecretKeys: readonly [];
14
+ /** Keys of a POP holding personal data (none in `ura/pops`). */
15
+ export declare const popPersonalKeys: readonly [];
16
+ /** Parsed response of `POST /api/ura/pops/`. */
17
+ export type ListPopsResponse = z.output<typeof listPopsSchema>;
18
+ /** Definition of `POST /api/ura/pops/`. */
19
+ export declare const listPopsDefinition: EndpointDefinition<typeof listPopsSchema>;
@@ -0,0 +1,64 @@
1
+ import { z } from "zod";
2
+ import type { EndpointDefinition } from "../../endpoint.js";
3
+ /** Response of `POST /api/ura/ordemservico/list/`: one page of service orders (OS). */
4
+ export declare const listServiceOrdersSchema: z.ZodObject<{
5
+ paginacao: z.ZodObject<{
6
+ offset: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
7
+ limit: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
8
+ parcial: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
9
+ total: z.ZodNumber;
10
+ }, z.core.$strip>;
11
+ ordens_servicos: z.ZodArray<z.ZodObject<{
12
+ id: z.ZodNumber;
13
+ contrato: z.ZodNumber;
14
+ status_id: z.ZodNumber;
15
+ status: z.ZodString;
16
+ tipo_id: z.ZodNumber;
17
+ data_cadastro: z.ZodString;
18
+ cliente: z.ZodNullable<z.ZodOptional<z.ZodString>>;
19
+ contrato_status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
+ contrato_status_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
21
+ ocorrencia: z.ZodNullable<z.ZodOptional<z.ZodString>>;
22
+ hora_cadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
23
+ data_agendamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
24
+ hora_agendamento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
25
+ data_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
26
+ hora_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
27
+ tipo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
28
+ motivo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
+ pop: z.ZodNullable<z.ZodOptional<z.ZodString>>;
30
+ conteudo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
31
+ responsavel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
32
+ tecnicos_auxiliares: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
33
+ usuario: z.ZodNullable<z.ZodOptional<z.ZodString>>;
34
+ usuario_finalizacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
35
+ classificacoes: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
36
+ }, z.core.$strip>>;
37
+ }, z.core.$strip>;
38
+ /** Key fields of `ura/ordemservico/list`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
39
+ export declare const listServiceOrdersKeyFields: readonly ["paginacao.total", "ordens_servicos", "ordens_servicos[].id", "ordens_servicos[].contrato", "ordens_servicos[].status_id", "ordens_servicos[].status", "ordens_servicos[].tipo_id", "ordens_servicos[].data_cadastro"];
40
+ /** Normalized path of each service order in the `ura/ordemservico/list` response. */
41
+ export declare const serviceOrderItemPath = "ordens_servicos[]";
42
+ /** Keys of a service order holding secrets (none in `ura/ordemservico/list`). */
43
+ export declare const serviceOrderSecretKeys: readonly [];
44
+ /** Keys of a service order holding personal data: customer name and the free-text content. */
45
+ export declare const serviceOrderPersonalKeys: readonly ["cliente", "conteudo"];
46
+ /** Body parameters of `POST /api/ura/ordemservico/list/` (besides credentials); all optional filters and paging. */
47
+ export interface ListServiceOrdersParams {
48
+ offset?: number;
49
+ limit?: number;
50
+ /** ID of the occurrence (the OS). */
51
+ ordem_servico?: number;
52
+ /** Service order status ID. */
53
+ status?: number;
54
+ /** POP ID. */
55
+ pop?: number;
56
+ /** Occurrence reason ID. */
57
+ motivo?: number;
58
+ /** Contract ID. */
59
+ contrato?: number;
60
+ }
61
+ /** Parsed response of `POST /api/ura/ordemservico/list/`. */
62
+ export type ListServiceOrdersResponse = z.output<typeof listServiceOrdersSchema>;
63
+ /** Definition of `POST /api/ura/ordemservico/list/`. */
64
+ export declare const listServiceOrdersDefinition: EndpointDefinition<typeof listServiceOrdersSchema>;
@@ -0,0 +1,121 @@
1
+ import { z } from "zod";
2
+ import type { EndpointDefinition } from "../../endpoint.js";
3
+ /** Response of `POST /api/ura/consultacliente/`: the contracts that match the filter. */
4
+ export declare const lookupCustomerSchema: z.ZodObject<{
5
+ msg: z.ZodNullable<z.ZodOptional<z.ZodString>>;
6
+ contratos: z.ZodArray<z.ZodObject<{
7
+ contratoId: z.ZodNumber;
8
+ clienteId: z.ZodNumber;
9
+ contratoStatus: z.ZodNumber;
10
+ contratoStatusDisplay: z.ZodString;
11
+ contratoValorAberto: z.ZodNumber;
12
+ contratoTitulosAReceber: z.ZodNumber;
13
+ cobVencimento: z.ZodNumber;
14
+ contratoStatusModo: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
15
+ motivo_status: z.ZodNullable<z.ZodOptional<z.ZodString>>;
16
+ dataCadastro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
17
+ dataAlteracao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
18
+ popId: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
19
+ popNome: z.ZodNullable<z.ZodOptional<z.ZodString>>;
20
+ cobPermuta: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
21
+ cobIsento: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
22
+ promessasPagamentoMes: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
23
+ link_quitacao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
24
+ planointernet: z.ZodNullable<z.ZodOptional<z.ZodString>>;
25
+ fidelidade: z.ZodNullable<z.ZodOptional<z.ZodObject<{
26
+ data_inicio: z.ZodNullable<z.ZodOptional<z.ZodString>>;
27
+ descricao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
28
+ data_fim: z.ZodNullable<z.ZodOptional<z.ZodString>>;
29
+ }, z.core.$strip>>>;
30
+ contrato_unificado_principal: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
31
+ contrato_unificado_filhos: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodNumber>>>;
32
+ tags: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
33
+ color: z.ZodNullable<z.ZodOptional<z.ZodString>>;
34
+ font: z.ZodNullable<z.ZodOptional<z.ZodString>>;
35
+ tag: z.ZodNullable<z.ZodOptional<z.ZodString>>;
36
+ id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
37
+ categoria_id: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
38
+ }, z.core.$strip>>>>;
39
+ anotacoes: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
40
+ contratoCentralLogin: z.ZodNullable<z.ZodOptional<z.ZodString>>;
41
+ contratoCentralSenha: z.ZodNullable<z.ZodOptional<z.ZodString>>;
42
+ servico_login: z.ZodNullable<z.ZodOptional<z.ZodString>>;
43
+ servico_senha: z.ZodNullable<z.ZodOptional<z.ZodString>>;
44
+ servico_plano: z.ZodNullable<z.ZodOptional<z.ZodString>>;
45
+ servico_grupo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
46
+ servico_tipo_conexao: z.ZodNullable<z.ZodOptional<z.ZodString>>;
47
+ servico_vlan: z.ZodNullable<z.ZodOptional<z.ZodString>>;
48
+ servico_mac: z.ZodNullable<z.ZodOptional<z.ZodString>>;
49
+ servico_mac2: z.ZodNullable<z.ZodOptional<z.ZodString>>;
50
+ servico_wifi_ssid: z.ZodNullable<z.ZodOptional<z.ZodString>>;
51
+ servico_wifi_ssid_5: z.ZodNullable<z.ZodOptional<z.ZodString>>;
52
+ servico_wifi_password: z.ZodNullable<z.ZodOptional<z.ZodString>>;
53
+ servico_wifi_password_5: z.ZodNullable<z.ZodOptional<z.ZodString>>;
54
+ servico_wifi_channel: z.ZodNullable<z.ZodOptional<z.ZodString>>;
55
+ servico_wifi_channel_5: z.ZodNullable<z.ZodOptional<z.ZodString>>;
56
+ razaoSocial: z.ZodNullable<z.ZodOptional<z.ZodString>>;
57
+ cpfCnpj: z.ZodNullable<z.ZodOptional<z.ZodString>>;
58
+ dataNascimento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
59
+ telefones: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
60
+ inscricoes: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString>>>;
61
+ tipoContato: z.ZodNullable<z.ZodOptional<z.ZodString>>;
62
+ contato: z.ZodNullable<z.ZodOptional<z.ZodString>>;
63
+ }, z.core.$strip>>>>;
64
+ telefones_cargos: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
65
+ emails: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
66
+ inscricoes: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString>>>;
67
+ tipoContato: z.ZodNullable<z.ZodOptional<z.ZodString>>;
68
+ contato: z.ZodNullable<z.ZodOptional<z.ZodString>>;
69
+ }, z.core.$strip>>>>;
70
+ outros: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{}, z.core.$strip>>>>;
71
+ endereco_logradouro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
72
+ endereco_numero: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
73
+ endereco_complemento: z.ZodNullable<z.ZodOptional<z.ZodString>>;
74
+ endereco_bairro: z.ZodNullable<z.ZodOptional<z.ZodString>>;
75
+ endereco_cidade: z.ZodNullable<z.ZodOptional<z.ZodString>>;
76
+ endereco_uf: z.ZodNullable<z.ZodOptional<z.ZodString>>;
77
+ endereco_cep: z.ZodNullable<z.ZodOptional<z.ZodString>>;
78
+ endereco_pontoreferencia: z.ZodNullable<z.ZodOptional<z.ZodString>>;
79
+ endereco_ll: z.ZodNullable<z.ZodOptional<z.ZodString>>;
80
+ }, z.core.$strip>>;
81
+ }, z.core.$strip>;
82
+ /** Key fields of `ura/consultacliente`: required and strict; any mismatch is `SCHEMA_MISMATCH`. */
83
+ export declare const lookupCustomerKeyFields: readonly ["contratos", "contratos[].contratoId", "contratos[].clienteId", "contratos[].contratoStatus", "contratos[].contratoStatusDisplay", "contratos[].contratoValorAberto", "contratos[].contratoTitulosAReceber", "contratos[].cobVencimento"];
84
+ /** Normalized path of each contract item in the `ura/consultacliente` response. */
85
+ export declare const customerContractItemPath = "contratos[]";
86
+ /** Keys of a contract item holding secrets: Central and PPPoE credentials, Wi-Fi, MACs, payoff link. */
87
+ export declare const customerContractSecretKeys: readonly ["contratoCentralLogin", "contratoCentralSenha", "servico_login", "servico_senha", "servico_wifi_password", "servico_wifi_password_5", "servico_wifi_ssid", "servico_wifi_ssid_5", "servico_mac", "servico_mac2", "link_quitacao"];
88
+ /** Keys of a contract item holding personal data: name, CPF/CNPJ, birth date, contacts, address, notes, status reason. */
89
+ export declare const customerContractPersonalKeys: readonly ["motivo_status", "razaoSocial", "cpfCnpj", "dataNascimento", "telefones", "telefones_cargos", "emails", "outros", "anotacoes", "endereco_logradouro", "endereco_numero", "endereco_complemento", "endereco_bairro", "endereco_cidade", "endereco_uf", "endereco_cep", "endereco_pontoreferencia", "endereco_ll"];
90
+ interface LookupCustomerFilters {
91
+ /** CPF or CNPJ of the customer. */
92
+ cpfcnpj?: string;
93
+ /** Contract ID. */
94
+ contrato?: number;
95
+ /** Customer name. */
96
+ nome?: string;
97
+ /** Service login (PPPoE). */
98
+ login?: string;
99
+ telefone?: string;
100
+ }
101
+ /**
102
+ * Body parameters of `POST /api/ura/consultacliente/` (besides credentials).
103
+ *
104
+ * At least one of `cpfcnpj`, `contrato`, `nome`, `login` or `telefone` is required; the others are optional.
105
+ */
106
+ export type LookupCustomerParams = (LookupCustomerFilters & {
107
+ cpfcnpj: string;
108
+ }) | (LookupCustomerFilters & {
109
+ contrato: number;
110
+ }) | (LookupCustomerFilters & {
111
+ nome: string;
112
+ }) | (LookupCustomerFilters & {
113
+ login: string;
114
+ }) | (LookupCustomerFilters & {
115
+ telefone: string;
116
+ });
117
+ /** Parsed response of `POST /api/ura/consultacliente/`. */
118
+ export type LookupCustomerResponse = z.output<typeof lookupCustomerSchema>;
119
+ /** Definition of `POST /api/ura/consultacliente/`. */
120
+ export declare const lookupCustomerDefinition: EndpointDefinition<typeof lookupCustomerSchema>;
121
+ export {};
@@ -0,0 +1,81 @@
1
+ import { z } from "zod";
2
+ import type { WriteEndpointDefinition } from "../../endpoint.js";
3
+ /**
4
+ * Success body of `POST /api/ura/chamado/`: `status` 1, the ticket protocol and the ID of the
5
+ * occurrence, plus the contract and customer SGP echoes back. `status` 0 is SGP's refusal.
6
+ */
7
+ export declare const openTicketSchema: z.ZodObject<{
8
+ status: z.ZodLiteral<1>;
9
+ protocolo: z.ZodString;
10
+ id: z.ZodNumber;
11
+ contratoId: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
12
+ razaoSocial: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
+ cpfCnpj: z.ZodNullable<z.ZodOptional<z.ZodString>>;
14
+ msg: z.ZodNullable<z.ZodOptional<z.ZodString>>;
15
+ }, z.core.$strip>;
16
+ /**
17
+ * Key fields of `ura/chamado`: required and strict. A 2xx is only a success with `status` 1 and a
18
+ * `protocolo`; anything else (e.g. `status` 0 with a `msg`) is `VALIDATION` with `outcome: "unknown"`.
19
+ */
20
+ export declare const openTicketKeyFields: readonly ["status", "protocolo", "id"];
21
+ /** Normalized path of the opened ticket in the response (the root object). */
22
+ export declare const ticketOpenedItemPath = "";
23
+ /** Keys of the response holding secrets (none in `ura/chamado`). */
24
+ export declare const ticketOpenedSecretKeys: readonly [];
25
+ /** Keys of the response holding personal data: the customer's name and CPF/CNPJ. */
26
+ export declare const ticketOpenedPersonalKeys: readonly ["razaoSocial", "cpfCnpj"];
27
+ /** Parsed response of `POST /api/ura/chamado/`. */
28
+ export type OpenTicketResponse = z.output<typeof openTicketSchema>;
29
+ /**
30
+ * Params of `POST /api/ura/chamado/`; only `contrato` is required. `contato_nome` and
31
+ * `contato_telefone` are personal data.
32
+ */
33
+ export interface OpenTicketParams {
34
+ /** Contract ID. */
35
+ contrato: number;
36
+ /** Content of the occurrence and the service order. */
37
+ conteudo?: string;
38
+ /** 1 removes SGP's default opening message ("via URA"). */
39
+ conteudolimpo?: 0 | 1;
40
+ observacao?: string;
41
+ /** Occurrence type code (SGP's default is 5). */
42
+ ocorrenciatipo?: number;
43
+ /** Classification IDs linked to the occurrence. */
44
+ tipoclassificacoes?: number[];
45
+ /** Occurrence method code (see `ura.listOccurrenceMethods`). */
46
+ metodo?: number;
47
+ /** Sector ID. */
48
+ setor?: number;
49
+ /** Username shown as who opened the occurrence. */
50
+ usuario?: string;
51
+ /** Username of the occurrence's responsible. */
52
+ responsaveloc?: string;
53
+ contato_nome?: string;
54
+ contato_telefone?: string;
55
+ /** 1 does not open a service order. */
56
+ desativa_os?: 0 | 1;
57
+ /** 1 creates the occurrence and the service order already closed. */
58
+ status_encerrado?: 0 | 1;
59
+ /** 1 notifies the customer of the closing, when created already closed. */
60
+ notificar_cliente?: 0 | 1;
61
+ /** Service order reason code; each SGP instance has its own (see `os.listOccurrenceReasons`). */
62
+ motivoos?: number;
63
+ /** Classification IDs linked to the service order. */
64
+ motivoclassificacoes?: number[];
65
+ /** Username of the service order's responsible technician. */
66
+ responsavel?: string;
67
+ /** Usernames of the auxiliary technicians. */
68
+ tecnicos?: string[];
69
+ /** Schedules the occurrence and the service order: `"AAAA-MM-DD HH:MM"`. */
70
+ data_hora_agendamento?: string;
71
+ /** 1 warns the responsible technician of the new service order; needs `data_hora_agendamento` and a messaging gateway in SGP. */
72
+ sms_tecnico?: 0 | 1;
73
+ /** With `servico_id`, links a specific contract service to the occurrence. */
74
+ tipo_servico?: "internet" | "telefonia" | "tv" | "multimidia" | "generico";
75
+ /** ID of the contract's service; use with `tipo_servico`. */
76
+ servico_id?: number;
77
+ /** ID of the company to link. */
78
+ empresa_id?: number;
79
+ }
80
+ /** Definition of `POST /api/ura/chamado/` (trailing slash required by the token whitelist). */
81
+ export declare const openTicketDefinition: WriteEndpointDefinition<typeof openTicketSchema>;
@@ -0,0 +1,59 @@
1
+ import type { SgpError, SgpErrorCode, SgpWriteError } from "./result.js";
2
+ /** SGP `detail` for 401/403 caused by wrong token/app credentials. */
3
+ export declare const DETAIL_UNAUTHORIZED = "Credenciais de autentica\u00E7\u00E3o incorretas.";
4
+ /** SGP `detail` for 401/403 when the app has no permission for the route (credentials "not provided"). */
5
+ export declare const DETAIL_ROUTE_NOT_ALLOWED = "As credenciais de autentica\u00E7\u00E3o n\u00E3o foram fornecidas.";
6
+ /** `message` of a write whose 2xx answer does not confirm it: the write may have been applied. */
7
+ export declare const MESSAGE_WRITE_NOT_CONFIRMED = "SGP answered with a success status but the response does not confirm the write; it may have been applied.";
8
+ /** `message` of a write SGP answered with its generic exception wrapper (a 4xx `errors` list): it may have been applied. */
9
+ export declare const MESSAGE_WRITE_FAILED_GENERICALLY = "SGP reported an error while processing the write; it may have been applied.";
10
+ /** `message` of a request the SDK refused before sending it (nothing left the process). */
11
+ export declare const MESSAGE_REJECTED_LOCALLY = "The SDK rejected the request before sending it.";
12
+ /**
13
+ * Reads the SGP error text from a response body: a string `detail`, else a non-empty string `msg`,
14
+ * else `errors`, else a non-empty string `error` (see {@link mapHttpFailure}). `undefined` when the
15
+ * body carries none.
16
+ */
17
+ export declare const readSgpDetail: (body: unknown) => string | undefined;
18
+ /**
19
+ * Whether the body is SGP's generic exception wrapper: `errors` is an array (e.g.
20
+ * `{"errors":["Ocorreu um erro: ..."]}`), as opposed to an object of field messages.
21
+ */
22
+ export declare const hasErrorList: (body: unknown) => boolean;
23
+ /**
24
+ * Builds a normalized error with the SDK-authored message for `code`, or with `message` when given.
25
+ *
26
+ * The `detail` key is omitted when `detail` is undefined.
27
+ */
28
+ export declare const createError: (code: SgpErrorCode, status: number, endpoint: string, detail?: string, message?: string) => SgpError;
29
+ /**
30
+ * Maps a non-2xx SGP response to a normalized error.
31
+ *
32
+ * `detail` is read from the first of these that yields text: a string `detail` (SGP's DRF message),
33
+ * a non-empty string `msg` (e.g. `{"msg":"Informe um Raio válido."}`), then `errors` (the CRM format):
34
+ * an array of strings joined by `"; "`, or an object of string values as `"key: value"` joined by
35
+ * `"; "` in key order. Non-string items and values are ignored. Last, a non-empty string `error`
36
+ * (e.g. `{"error":"Cadastro não encontrado"}`, a 404 on CRM routes). A body with none of these
37
+ * leaves `detail` undefined. The raw body is never retained.
38
+ */
39
+ export declare const mapHttpFailure: (status: number, body: unknown, endpoint: string) => SgpError;
40
+ /**
41
+ * Maps an exception thrown by `fetch` to a normalized error (status 0).
42
+ *
43
+ * `TimeoutError` and `AbortError` become `TIMEOUT`; anything else becomes `NETWORK`.
44
+ * The cause's message is never copied, since it can embed the request URL with credentials.
45
+ */
46
+ export declare const mapFetchFailure: (cause: unknown, endpoint: string) => SgpError;
47
+ /**
48
+ * Tags a failed write with whether SGP applied it: `"not_applied"` for a 4xx (SGP rejected the
49
+ * request) and for a `VALIDATION` with status 0 (rejected locally, nothing was sent), `"unknown"`
50
+ * for anything else (timeout/network, 5xx, 2xx that failed validation, 1xx/3xx).
51
+ *
52
+ * `isErrorListBody` (the {@link hasErrorList} result for the response body) marks a 4xx body that is
53
+ * SGP's generic exception wrapper: SGP may have failed after applying part of the write, so that 4xx
54
+ * is `"unknown"` too and carries {@link MESSAGE_WRITE_FAILED_GENERICALLY} as its `message`, except
55
+ * 401/403/404/405/422, which stay `"not_applied"`. Omit it when the body is not known.
56
+ *
57
+ * Returns a new object; the input is not mutated.
58
+ */
59
+ export declare const toWriteError: (error: SgpError, isErrorListBody?: boolean) => SgpWriteError;