siip-whatsapp-notifications.../INDEX_api_used.md

94 lines
4.7 KiB
Markdown
Executable File

# INDEX_api_used.md — Llamadas API que el plugin ya hace
> Referencia rápida de todas las llamadas API usadas en `public.php`, `Plugin.php` y sus dependencias.
> Para bugs o modificaciones en llamadas existentes, este archivo evita leer los archivos de referencia API completos.
---
## API UCRM (CRM v1.0)
**Base URL:** `https://{ipserver}/crm/api/v1.0/`
**Auth:** Header `X-Auth-App-Key: {apitoken}` (SDK) o `X-Auth-Token: {apitoken}` (Guzzle directo)
| Endpoint | Método | Usado en | Parámetros / Body |
|---|---|---|---|
| `clients` | GET | public.php, PaymentIntentService | `query, limit, offset` |
| `clients/{id}` | GET | Plugin.php, Facades, PaymentIntentService | — |
| `clients/{id}` | PATCH | AbstractMessageNotifierFacade | `{attributes: [{value, customAttributeId}]}` |
| `clients/services` | GET | AbstractMessageNotifierFacade | `?clientId={id}` |
| `users/admins` | GET | public.php | — |
| `users/admins/{id}` | GET | AbstractMessageNotifierFacade | — |
| `payments` | GET | public.php | `clientId, limit, order, direction` |
| `payments/{id}` | GET | public.php (resend_payment) | — |
| `payments` | POST | AbstractStripeOperationsFacade | `{clientId, amount, currencyCode, methodId, note}` |
| `payment-methods` | GET | public.php | — |
| `scheduling/jobs` | GET | public.php | `assignedUserId, statuses[], limit` |
| `scheduling/jobs/{id}` | GET | public.php (resend_job) | — |
| `scheduling/jobs/{id}` | PATCH | Plugin.php, AbstractMessageNotifierFacade | `{title}` |
| `client-attributes` | GET | AbstractStripeOperationsFacade | — (busca IDs de atributos custom) |
| `invoices/{id}` | GET | AbstractStripeOperationsFacade | — |
---
## API NMS/UNMS (v2.1)
**Base URL:** `https://{ipserver}/nms/api/v2.1/`
**Auth:** Header `X-Auth-Token: {unmsApiToken}`
| Endpoint | Método | Usado en | Parámetros / Body |
|---|---|---|---|
| `user/login` | POST | public.php (nms_login) | `{username, password}` |
| `user/login/totpauth` | POST | public.php (nms_login_totp) | `{twoFactorToken, totpCode}` |
| `user` | GET | public.php (nms_verify_session) | Header `x-auth-token` |
| `devices` | GET | AbstractMessageNotifierFacade | `?siteId={id}` |
| `vault/{deviceId}/credentials` | GET | AbstractMessageNotifierFacade | Header `X-Auth-Token` |
| `vault/{deviceId}/credentials/regenerate` | POST | AbstractMessageNotifierFacade | `[{username, password, readOnly}]` |
---
## API Stripe
**Lib:** `stripe/stripe-php` SDK
**Auth:** `stripeApiKey` (del config)
| Recurso Stripe | Operación | Usado en | Parámetros relevantes |
|---|---|---|---|
| `paymentIntents.create` | POST | PaymentIntentService, AbstractStripeOperationsFacade | `amount, currency, customer, payment_method_types, metadata` |
| `paymentIntents.all` | GET | PaymentIntentService | `customer, limit, expand:[data.charges]` |
| `paymentIntents.retrieve` | GET | AbstractStripeOperationsFacade | `id` |
| `customers.create` | POST | AbstractStripeOperationsFacade | `name, email, metadata:{clientId}` |
| `customers.retrieve` | GET | AbstractStripeOperationsFacade | `id` |
| `customers.update` | POST | AbstractStripeOperationsFacade | `name, email` |
| `customers.retrieveCashBalance` | GET | PaymentIntentService | `stripeCustomerId` |
| `customers.createFundingInstructions` | POST | AbstractStripeOperationsFacade | `currency, funding_type, bank_transfer:{type:mx_bank_transfer}` |
---
## API Callbell
**Base URL:** `https://api.callbell.eu/v1/`
**Auth:** Header `Authorization: Bearer {tokencallbell}`
**Usado en:** `ClientCallBellAPI.php`
| Endpoint | Método | Descripción |
|---|---|---|
| `contacts` | GET | Busca contacto por teléfono |
| `contacts/{uuid}` | PATCH | Actualiza datos del contacto (nombre, custom fields) |
| `messages/send` | POST | Envía mensaje / plantilla WhatsApp |
---
## Llamadas HTTP directas (cURL/Guzzle sin SDK)
| Destino | Método | Usado en | Descripción |
|---|---|---|---|
| `self URL` (loopback) | POST | public.php `resend_payment`, `resend_job_notification` | Simula webhook reenviando JSON al mismo `public.php` |
| `http://{ipPuppeteer}:{portPuppeteer}/generate` | POST | AbstractOxxoOperationsFacade | Genera imagen de voucher OXXO via Puppeteer |
| MinIO presigned URL | PUT | MinioStorageService | Sube imagen del voucher generado |
---
## Atributos Custom de Cliente en UCRM que el plugin usa
| Clave (`key`) | Nombre en UI | Usado para |
|---|---|---|
| `stripeCustomerId` | Stripe Customer ID | ID del customer en Stripe |
| `clabeInterbancaria` | Clabe Interbancaria | CLABE para transferencias MX |
| `passwordAntenaCliente` | Password Antena Cliente | Contraseña de la antena del cliente (desde UNMS vault) |
| `antenaSectorial` | Antena Sectorial | Tipo de antena (usado en audit de passwords) |
| `site` | Site | ID del sitio UNMS asociado al servicio |