Mock SAOP API – Electron Integration Guide
Base URL
- http://localhost:4001
API Faces
- SAOP-style XML: /api/...
- Internal JSON: /SI/API/...
For VRP and routing use JSON endpoints; XML is only for mimicking real SAOP.
Key Analytic
- Base analytic code: 0000001
- Base analytic numeric ID: 1
Data Shape (JSON)
- GET /SI/API/Analytics/1 returns:
{
id: 1,
code: "0000001",
name: "Uvoz iz Excela",
customers: [
{
id: number,
customerCode: string, // SAOP customer ("Naročnik")
name: string, // "Naziv naročnika"
address: string, // "Naslov dostave"
orderNumber: string, // "Številka" (order ID)
weight: number | null, // "Neto teža"
document: string | null // "Dokument"
},
...
]
}
Endpoints
1) Import base orders for a given analytic (GET)
Recommended (JSON):
- GET /SI/API/Analytics/{analyticId}
- Example: GET http://localhost:4001/SI/API/Analytics/1
- Use customers[] directly as VRP input.
SAOP-style XML (optional):
- GET /api/Customers/GetCustomers
- Example: GET http://localhost:4001/api/Customers/GetCustomers
- Returns ...
- Each Customer has:
-
-
-
- (e.g. 0000001)
- If needed, filter client-side by AnalyticId == "0000001".
2) List analytics (GET)
- GET /SI/API/Analytics
- Example: GET http://localhost:4001/SI/API/Analytics
- Returns array of:
{
id: number,
code: string, // e.g. "0000001"
name: string,
customerCount: number
}
3) Create a new analytic (route bucket) (POST)
Option A – SAOP-style:
- POST /api/Analytics1/AddAnalytic1
- URL: http://localhost:4001/api/Analytics1/AddAnalytic1
- Body (JSON):
{
"Analytic_1Id": "0000002", // 7-digit code
"Analytic_1Description": "Route 1"
}
- Response: XML with key.
Option B – Internal JSON:
- POST /SI/API/Analytics
- URL: http://localhost:4001/SI/API/Analytics
- Body (JSON):
{
"code": "0000002", // 7-digit code
"name": "Route 1"
}
- Response: created analytic with numeric id and empty customers array.
Note: analytic codes must be zero-padded to 7 digits (0000002, 0000003, ...).
4) Assign orders to a route analytic (POST customers)
- POST /SI/API/Analytics/{analyticId}/Customers
- Example: POST http://localhost:4001/SI/API/Analytics/2/Customers
- Body: JSON array of customers assigned to that route analytic:
[
{
"customerCode": "0000142",
"name": "ŽITO d.o.o.",
"address": "ŽITO PEKARNA MARIBOR, JOŽICE FLANDER 2, MARIBOR, 2000 Maribor",
"orderNumber": "59063",
"weight": 180,
"document": "4501874214"
},
...
]
Behavior:
- Clears existing customers for that analyticId.
- Inserts the given ones with customerCode, name, address, orderNumber, weight, document.
- Returns the inserted rows including DB-generated id.
5) Verify route assignments
- JSON check:
- GET /SI/API/Analytics/{analyticId}
- Example: GET http://localhost:4001/SI/API/Analytics/2
- Verify customers[] matches the route assignments.
- XML-style SAOP check (optional):
- GET /api/Customers/GetCustomers
- Check that for the moved orders is the new analytic code (e.g. 0000002).
Suggested Electron Flow
1) At end of order entry window:
- Call GET /SI/API/Analytics/1 to load base orders for analytic code 0000001.
2) Run VRP in the app using the returned customers array.
3) For each VRP route:
- Generate a new 7-digit analytic code (0000002, 0000003, ...).
- Create the analytic via POST /api/Analytics1/AddAnalytic1 or POST /SI/API/Analytics.
- Capture the returned numeric analytic id for the next step.
4) For each route analytic id:
- Build the list of customers/orders assigned to that route.
- POST that array to /SI/API/Analytics/{analyticId}/Customers.
5) Optionally re-read:
- GET /SI/API/Analytics/{analyticId} to confirm assignments.
- Or GET /api/Customers/GetCustomers to see SAOP-style view.