Go
| Requisitos | |
|---|---|
| Pacote | github.com/uhurucompliance/zuia-go |
| Ambiente | Go 1.22+ |
| Dependências | none (standard library) |
| Testes | 8 testes unitários + teste de contrato contra a API real |
Instalar
go get github.com/uhurucompliance/zuia-go
replace no seu go.mod: replace github.com/uhurucompliance/zuia-go => ../api.zuia.uhurucompliance.com/sdks/go.Configurar
Autentique-se com uma chave de API com âmbito ou com um fornecedor de tokens OAuth2 (client credentials). Ver Autenticação.
import zuia "github.com/uhurucompliance/zuia-go"
zc := zuia.New("https://api.zuia.uhurucompliance.com",
zuia.WithAPIKey(os.Getenv("ZUIA_API_KEY")), // or zuia.WithTokenSource(func(ctx context.Context) (string, error) { … })
zuia.WithLanguage("pt-AO"),
zuia.WithTimeout(30*time.Second),
zuia.WithMaxRetries(3),
)
Triagem de uma pessoa ou entidade
r, err := zc.ScreenParty(ctx, zuia.PartyQuery{
Name: "Joao Manuel Exemplo", Type: zuia.Individual, DateOfBirth: "1975-08-14",
Nationality: "Utopia", DocumentNumber: "UT1234567", ClientID: "C001",
}, &zuia.CallOptions{IdempotencyKey: "onboarding-C001", CorrelationID: "crm-7f3a9c21"})
if err != nil {
return holdAndRetryLater(err)
}
switch r.Outcome {
case zuia.NoMatch:
openAccount()
case zuia.PotentialMatch:
holdOnboarding(*r.CaseID)
case zuia.ConfirmedMatch:
rejectAndReport(*r.CaseID)
}
Triagem de uma transacção
HOLD significa: não executar.
tx, err := zc.ScreenTransaction(ctx, zuia.TransactionRequest{
TransactionID: "T002", Kind: "TRANSFER", Amount: "45000.00", Currency: "USD",
Client: zuia.PartyQuery{Name: "Kwanza Demo Investimentos, S.A.", Type: zuia.Entity, ClientID: "C014"},
Counterparty: &zuia.PartyQuery{Name: "Northwind Holdings", Nationality: "Utopia"},
}, &zuia.CallOptions{IdempotencyKey: "T002-attempt-1"})
if err == nil && tx.Decision == zuia.Hold {
holdTransfer(tx)
}
Erros
Cada erro da API passa a uma excepção tipada com o estado HTTP, o code estável, a mensagem traduzida, o correlationId e Retry-After. Ver Erros e novas tentativas.
_, err := zc.GetCase(ctx, "CASE-0001")
var apiErr *zuia.APIError
var connErr *zuia.ConnectionError
switch {
case errors.As(err, &apiErr): // RFC 9457 problem document
log.Printf("%d %s %s correlation=%s", apiErr.Status, apiErr.Code, apiErr.Message, apiErr.CorrelationID)
if zuia.IsCode(err, "license.trialEnded") {
alertAdministrators()
}
case errors.As(err, &connErr): // after retries
holdAndRetryLater(err)
}
Novas tentativas
Os pedidos que podem ser repetidos com segurança — GET e chamadas de triagem com chave de idempotência — são repetidos até 3 vezes em 429, 502, 503, 504 e erros de rede, esperando Retry-After ou com espera exponencial. As chamadas sem chave de idempotência nunca são repetidas automaticamente.
Paginação
Cada chamada de lista devolve uma página com o total de X-Total-Count; o iterador lê todas as páginas por si.
page, err := zc.ListCases(ctx, zuia.CaseFilter{Status: zuia.CaseOpen}, 0, 50) // page.Total, page.HasNext()
err = zc.AllCases(ctx, zuia.CaseFilter{Status: zuia.CaseOpen}, func(c zuia.Case) bool {
fmt.Println(c.ID, c.Status, c.PastSla)
return true // false stops the iteration
})
Relatórios e auditoria
pdf, err := zc.DownloadReport(ctx, zuia.ReportCases, "pdf", "2026-10-01", "2026-10-31")
_ = os.WriteFile("cases_2026-10.pdf", pdf, 0o600)
v, err := zc.VerifyAudit(ctx) // v.Valid
Webhooks
Verifique cada entrega com o corpo original; depois ignore X-Event-Id duplicados. Exemplos completos de receptores: Webhooks.
ev, err := zuia.VerifyWebhook(secret, r.Header.Get("X-Signature"), body) // errors.Is(err, zuia.ErrWebhookSignature)
Referência
| Método | Endpoint |
|---|---|
ScreenParty(ctx, party, opts) | POST /screen/party |
ScreenTransaction(ctx, tx, opts) | POST /screen/transaction |
GetScreening(ctx, id) | GET /screenings/{id} |
ListScreenings(ctx, offset, limit) | GET /screenings |
RescreenAll(ctx) | POST /screen/rescreen |
ImportClients(ctx, fileName, content) | POST /clients/import |
ListCases(ctx, filter, offset, limit) / AllCases(ctx, filter, fn) | GET /cases |
GetCase(ctx, id) | GET /cases/{id} |
ListUpdates(…) / AllListUpdates(…) | GET /lists/updates |
GetListUpdate(ctx, id) | GET /lists/updates/{id} |
DownloadReport(ctx, type, format, from, to) | GET /reports/{type} |
VerifyAudit(ctx) | GET /audit/verify |
Do(ctx, method, path, query, body, opts, out) | qualquer outro endpoint |
VerifyWebhook(secret, header, body) | assinatura de webhook |
Qualquer outro endpoint está disponível através do método genérico de pedido — ver a referência da API.