Recupera una lista paginada de pagos (facturas) de su organización. Admite filtrado por estado, método de pago, paciente y rango de fechas de creación. Solo lectura.
Ejemplos de código
Node.js
const fetch = require('node-fetch');
async function llamarApi() {
const claveApi = 'YOUR_API_KEY';
const from = 'su-from';
const to = 'su-to';
const status = 'su-status';
const paymentMethod = 'su-paymentMethod';
const patientId = 'su-patientId';
const rowsPerPage = 'su-rowsPerPage';
const page = 'su-page';
const sortDir = 'su-sortDir';
const queryString = new URLSearchParams({
from: from,
to: to,
status: status,
paymentMethod: paymentMethod,
patientId: patientId,
rowsPerPage: rowsPerPage,
page: page,
sortDir: sortDir
}).toString();
const url = `https://account.lunahealth.app/api/payments` + (queryString ? `?${queryString}` : '');
try {
const response = await fetch(url, {
method: 'GET',
headers: {
'Authorization': `Bearer ${claveApi}`,
'Content-Type': 'application/json'
}
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
const data = await response.json();
console.log(data);
return data;
} catch (error) {
console.error('Error al llamar a la API:', error);
throw error;
}
}
llamarApi();