Fix NetUP API path: /mw/a → /mw/api (actual server URL from spec)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-18 18:27:55 +03:00
parent 61d25628ae
commit cc5f9c18d3

View File

@@ -23,7 +23,7 @@ const netup: FastifyPluginAsync = async (fastify) => {
body?: unknown, body?: unknown,
): Promise<{ ok: boolean; status: number; data: unknown }> { ): Promise<{ ok: boolean; status: number; data: unknown }> {
const base = serverUrl.replace(/\/$/, '') const base = serverUrl.replace(/\/$/, '')
const url = `${base}/mw/a${path}` const url = `${base}/mw/api${path}`
const cred = Buffer.from(`${username}:${password}`).toString('base64') const cred = Buffer.from(`${username}:${password}`).toString('base64')
const res = await fetch(url, { const res = await fetch(url, {
@@ -257,7 +257,7 @@ export async function notifyNetupCheckin(hotelId: string, roomId: string, guestN
try { try {
const base = cfg.server_url.replace(/\/$/, '') const base = cfg.server_url.replace(/\/$/, '')
const cred = Buffer.from(`${cfg.username}:${cfg.password}`).toString('base64') const cred = Buffer.from(`${cfg.username}:${cfg.password}`).toString('base64')
await fetch(`${base}/mw/a/hotel-room/${encodeURIComponent(mapping.netup_room_number)}/check-in`, { await fetch(`${base}/mw/api/hotel-room/${encodeURIComponent(mapping.netup_room_number)}/check-in`, {
method: 'POST', method: 'POST',
headers: { Authorization: `Basic ${cred}`, 'Content-Type': 'application/json' }, headers: { Authorization: `Basic ${cred}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ body: JSON.stringify({
@@ -288,7 +288,7 @@ export async function notifyNetupCheckout(hotelId: string, roomId: string) {
try { try {
const base = cfg.server_url.replace(/\/$/, '') const base = cfg.server_url.replace(/\/$/, '')
const cred = Buffer.from(`${cfg.username}:${cfg.password}`).toString('base64') const cred = Buffer.from(`${cfg.username}:${cfg.password}`).toString('base64')
await fetch(`${base}/mw/a/hotel-room/${encodeURIComponent(mapping.netup_room_number)}/check-out`, { await fetch(`${base}/mw/api/hotel-room/${encodeURIComponent(mapping.netup_room_number)}/check-out`, {
method: 'POST', method: 'POST',
headers: { Authorization: `Basic ${cred}` }, headers: { Authorization: `Basic ${cred}` },
signal: AbortSignal.timeout(6000), signal: AbortSignal.timeout(6000),