AutenticaProcuradorService class

Serviço: AUTENTICA PROCURADOR

Permite que um Procurador autorize uma Empresa Contratante a fazer requisições em nome de um Contribuinte.

Fluxo de Autenticação

┌─────────────────┐    assina termo    ┌─────────────────┐
│   PROCURADOR    │ ─────────────────► │   CONTRATANTE   │
│ (certificado 2) │   autoriza usar    │ (certificado 1) │
└─────────────────┘                    └─────────────────┘
        │                                      │
        │ em nome de                           │ faz requisições
        ▼                                      ▼
┌─────────────────┐                    ┌─────────────────┐
│  CONTRIBUINTE   │ ◄───────────────── │   API SERPRO    │
│   (Empresa B)   │   dados obtidos    │                 │
└─────────────────┘                    └─────────────────┘

Plataformas Suportadas

Plataforma Certificado Path Certificado Base64
Windows
Android
iOS
Web

Exemplo Completo

// 1. Autenticar Empresa A (Contratante) com seu certificado
await apiClient.authenticate(
  consumerKey: 'xxx',
  consumerSecret: 'xxx',
  contratanteNumero: '11111111000111',  // CNPJ Empresa A
  autorPedidoDadosNumero: '12345678901', // CPF do Procurador
  certificadoDigitalPath: 'empresa_a.pfx',
  senhaCertificado: 'senha123',
  ambiente: 'producao',
);

// 2. Procurador assina termo para autorizar requisições em nome de Empresa B
final autenticaService = AutenticaProcuradorService(apiClient);
final resultado = await autenticaService.autenticarProcurador(
  contratanteNome: 'Empresa A Contabilidade Ltda',
  autorNome: 'João Silva',
  contribuinteNumero: '22222222000222', // CNPJ Empresa B
  certificadoPath: 'procurador.pfx',
  certificadoPassword: 'senha_procurador',
);

Constructors

AutenticaProcuradorService(ApiClient _apiClient)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

autenticarProcurador({required String contratanteNome, required String autorNome, String? contribuinteNumero, String? certificadoPath, String? certificadoBase64, String? certificadoPassword, String? contratanteNumero, String? autorNumero}) Future<TermoAutorizacaoResponse>
Autentica procurador enviando XML assinado com Termo de Autorização
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

tokenEmCache TermoAutorizacaoResponse?
Obtém o token em cache (se houver e estiver válido)
no setter

Static Methods

limparCache() → void
Limpa o cache local do token