API
How Flexpress uses WowCalculator once Steve approves the calculations.
Two ways in
- Call the API. Flexpress posts a job and gets back the cost, the price and the profit. Nothing else changes in Flexpress.
- Use the engine directly.
WowCalculator.Engineis a plain class library with no database or web dependencies. Flexpress can reference it and callJobCalculator.Calculate(...)itself, loading the same settings.
Endpoints
| Call | What it does |
|---|---|
GET /api/v1/health | Is it up. |
GET /api/v1/products | Products and formats WowCalculator knows (Flexpress ids). |
GET /api/v1/products/{id} | One product: its choices, route and a default job to start from. |
POST /api/v1/calculate | Cost, price and profit for a job. 422 with errors when it can't be made. |
POST /api/v1/calculate/ladder | The same job at several quantities: { "job": {…}, "quantities": [100, 250, 500] }. |
POST /api/v1/sync | Sync from Flexpress now (for example right after a product is saved in Flexpress). |
When
Api:Key is set in appsettings, every call must send it as the X-Api-Key header.A job, in Flexpress's terms
Every id is Flexpress's own: product, format, paper category (material), lamination and foil colour. A basket item maps across field by field.
POST /api/v1/calculate
{
"productId": 7,
"formatId": 56,
"quantity": 500,
"inner": {
"paperCategoryId": 10,
"colours": 4,
"sides": 2,
"laminationId": 2,
"laminationSides": 2
},
"turnaround": "Standard"
}
200 OK
{
"productName": "Regular Business Cards",
"totalItems": 500,
"cost": { "materialCost": 22.91, "labourCost": 55.73, "fullCost": 78.64, "materials": [ … ], "times": [ … ], "parts": [ … ] },
"price": { "marginPercent": 64, "price": 65.00, "profitAfterMaterialPercent": 64.8, "light": "Green", "steps": [ … ] }
}From a Flexpress basket item
| Job field | Flexpress ShoppingCartItem / OrderItem |
|---|---|
| productId, formatId | ProductId, ProductFormatId |
| landscape | Orientation == "Landscape" |
| quantity, versions, pages, fileCopies | Quantity, Versions, Pages, FileCopies |
| inner.paperCategoryId / cover.paperCategoryId | the inner and cover paper category |
| inner.colours, inner.sides | printing option (4 or 1) and sides (1 or 2) |
| laminationId, laminationSides; spotUvCoverage, spotUvSides; foilCoverage, foilColourId, foilSides | the part's finishing choices |
| options | the chosen add-ons: option code to selection name |
| turnaround | "Saver", "Standard" or "Express" |
| pdfProof | Proofing == "PDF Proof Required" |