EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
route.ts
Go to the documentation of this file.
1import { NextRequest, NextResponse } from "next/server";
2import { fieldpineServerApi } from "@/lib/server/fieldpineApi";
3import { getStoredAuth } from "@/lib/server/auth";
4
5/**
6 * Printing Pending List API
7 *
8 * Get list of pending print jobs/labels
9 * Uses: retailmax.elink.printingpending.list
10 */
11export async function GET(request: NextRequest) {
12 try {
13 const authData = await getStoredAuth();
14 if (!authData) {
15 return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
16 }
17
18 const { searchParams } = new URL(request.url);
19 const limit = searchParams.get("limit");
20
21 const params: Record<string, string> = {
22 "3": "retailmax.elink.printingpending.list"
23 };
24
25 if (limit) {
26 params["8"] = limit;
27 }
28
29 console.log('[Printing Pending API] Fetching pending print jobs');
30
31 const result = await fieldpineServerApi.buckApiCall(params, authData.apiKey!);
32
33 return NextResponse.json({
34 success: true,
35 data: result,
36 source: "elink",
37 });
38 } catch (error: any) {
39 console.error("[Printing Pending API] Error:", error);
40 return NextResponse.json(
41 { success: false, error: error.message || "Failed to fetch printing pending list" },
42 { status: error.status || 500 }
43 );
44 }
45}