summaryrefslogtreecommitdiff
path: root/app/api/mdg/send-vendor/route.ts
blob: 2442b7332255d2c6c155709f7fafccc78c3bc46d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { NextRequest, NextResponse } from 'next/server';
import { sendSingleVendorToMDG } from '@/lib/soap/mdg/send/vendor-master/action';

export async function POST(request: NextRequest) {
  try {
    const { vendorCode } = await request.json();

    if (!vendorCode || typeof vendorCode !== 'string') {
      return NextResponse.json(
        { success: false, message: 'vendorCode is required' },
        { status: 400 }
      );
    }

    const result = await sendSingleVendorToMDG(vendorCode);

    return NextResponse.json(result);
  } catch (error) {
    console.error('[send-vendor] error:', error);
    return NextResponse.json(
      {
        success: false,
        message: error instanceof Error ? error.message : 'Unknown error',
      },
      { status: 500 }
    );
  }
}