1import { NextRequest, NextResponse } from 'next/server';
2import { fieldpineServerApi } from '@/lib/server/fieldpineApi';
3import { getStoredAuth } from '@/lib/server/auth';
6 * OpenAPI StockTransfers Endpoint
7 * GET /api/v1/openapi/stock-transfers/[id] - Get stock transfer details
9export async function GET(
11 { params }: { params: Promise<{ id: string }> }
14 const authData = await getStoredAuth();
15 if (!authData || !authData.authenticated) {
16 return NextResponse.json(
17 { error: 'Authentication required' },
22 const { searchParams } = new URL(request.url);
23 const queryParams: Record<string, string | number> = {};
25 const srcuid = searchParams.get('srcuid');
26 if (srcuid) queryParams.srcuid = parseInt(srcuid);
28 const transfer = await fieldpineServerApi.apiCall(
29 `/StockTransfers/${await params.then(p => p.id)}`,
32 cookie: authData.apiKey,
37 return NextResponse.json({
44 console.error('StockTransfers API error:', error);
45 return NextResponse.json(
46 { error: 'Failed to fetch stock transfer' },