654 lines
16 KiB
JavaScript
654 lines
16 KiB
JavaScript
const express = require("express");
|
|
const asyncHandler = require("../middleware/asyncHandler");
|
|
const controller = require("../modules/proxy/proxy.controller");
|
|
|
|
const router = express.Router();
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/request:
|
|
* post:
|
|
* summary: Generic Uber passthrough for any Uber endpoint
|
|
* tags:
|
|
* - Uber Generic
|
|
* responses:
|
|
* 200:
|
|
* description: Uber response
|
|
*/
|
|
router.post("/uber/request", asyncHandler(controller.genericProxy));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/menu/upsert:
|
|
* post:
|
|
* summary: Legacy upsert helper for store menu
|
|
* tags:
|
|
* - Uber Menu
|
|
* responses:
|
|
* 200:
|
|
* description: Menu upserted
|
|
*/
|
|
router.post("/uber/menu/upsert", asyncHandler(controller.upsertMenu));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/menu/replace:
|
|
* put:
|
|
* summary: Replace store menu (full upload)
|
|
* tags:
|
|
* - Uber Menu
|
|
* responses:
|
|
* 200:
|
|
* description: Menu replaced
|
|
*/
|
|
router.put("/uber/menu/replace", asyncHandler(controller.replaceMenu));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/menu/items:
|
|
* post:
|
|
* summary: Update individual menu items (stock/price updates)
|
|
* tags:
|
|
* - Uber Menu
|
|
* responses:
|
|
* 200:
|
|
* description: Menu items updated
|
|
*/
|
|
router.post("/uber/menu/items", asyncHandler(controller.updateMenuItems));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/menu:
|
|
* get:
|
|
* summary: Fetch store menu
|
|
* tags:
|
|
* - Uber Menu
|
|
* responses:
|
|
* 200:
|
|
* description: Menu fetched
|
|
*/
|
|
router.get("/uber/menu", asyncHandler(controller.getMenu));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/orders:
|
|
* get:
|
|
* summary: List store orders
|
|
* tags:
|
|
* - Uber Orders
|
|
* responses:
|
|
* 200:
|
|
* description: Orders fetched
|
|
*/
|
|
router.get("/uber/orders", asyncHandler(controller.listOrders));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/orders/{orderId}:
|
|
* get:
|
|
* summary: Retrieve full order details by order ID
|
|
* tags:
|
|
* - Uber Orders
|
|
* parameters:
|
|
* - in: path
|
|
* name: orderId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Order details retrieved
|
|
*/
|
|
router.get("/uber/orders/:orderId", asyncHandler(controller.getOrderById));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/orders/{orderId}/fulfillment-issues:
|
|
* post:
|
|
* summary: Resolve retail fulfillment issues (found/partial/out-of-stock substitutions)
|
|
* tags:
|
|
* - Uber Orders
|
|
* parameters:
|
|
* - in: path
|
|
* name: orderId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Fulfillment issue update submitted
|
|
*/
|
|
router.post(
|
|
"/uber/orders/:orderId/fulfillment-issues",
|
|
asyncHandler(controller.resolveFulfillmentIssues)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/orders/{orderId}/ready:
|
|
* post:
|
|
* summary: Mark order ready for handoff/pickup
|
|
* tags:
|
|
* - Uber Orders
|
|
* parameters:
|
|
* - in: path
|
|
* name: orderId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Order marked ready
|
|
*/
|
|
router.post("/uber/orders/:orderId/ready", asyncHandler(controller.markOrderReady));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/stores:
|
|
* get:
|
|
* summary: Retrieve all stores provisioned to developer account
|
|
* tags:
|
|
* - Uber Stores
|
|
* responses:
|
|
* 200:
|
|
* description: Stores retrieved
|
|
*/
|
|
router.get("/uber/stores", asyncHandler(controller.listStores));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/stores/provisionable:
|
|
* get:
|
|
* summary: Retrieve stores associated with merchant OAuth token
|
|
* tags:
|
|
* - Uber Provisioning
|
|
* parameters:
|
|
* - in: query
|
|
* name: merchantId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Stores retrieved
|
|
*/
|
|
router.get("/uber/stores/provisionable", asyncHandler(controller.listProvisionableStores));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/stores/{storeId}:
|
|
* get:
|
|
* summary: Retrieve store details by store ID
|
|
* tags:
|
|
* - Uber Stores
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store retrieved
|
|
*/
|
|
router.get("/uber/stores/:storeId", asyncHandler(controller.getStoreById));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/stores/{storeId}/status:
|
|
* get:
|
|
* summary: Retrieve store online/offline status
|
|
* tags:
|
|
* - Uber Stores
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store status retrieved
|
|
* post:
|
|
* summary: Set store online/offline status
|
|
* tags:
|
|
* - Uber Stores
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store status updated
|
|
*/
|
|
router.get("/uber/stores/:storeId/status", asyncHandler(controller.getStoreStatus));
|
|
router.post("/uber/stores/:storeId/status", asyncHandler(controller.setStoreStatus));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/stores/{storeId}/holiday-hours:
|
|
* get:
|
|
* summary: Retrieve store holiday hours
|
|
* tags:
|
|
* - Uber Stores
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Holiday hours retrieved
|
|
* post:
|
|
* summary: Set store holiday hours
|
|
* tags:
|
|
* - Uber Stores
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Holiday hours updated
|
|
*/
|
|
router.get("/uber/stores/:storeId/holiday-hours", asyncHandler(controller.getHolidayHours));
|
|
router.post("/uber/stores/:storeId/holiday-hours", asyncHandler(controller.setHolidayHours));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/orders/{orderId}/action:
|
|
* post:
|
|
* summary: Trigger order action (accept, deny, ready, cancel, resolve)
|
|
* tags:
|
|
* - Uber Orders
|
|
* parameters:
|
|
* - in: path
|
|
* name: orderId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Order action sent
|
|
*/
|
|
router.post("/uber/orders/:orderId/action", asyncHandler(controller.orderAction));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/stores/hours:
|
|
* put:
|
|
* summary: Update store hours
|
|
* tags:
|
|
* - Uber Stores
|
|
* responses:
|
|
* 200:
|
|
* description: Store hours updated
|
|
*/
|
|
router.put("/uber/stores/hours", asyncHandler(controller.updateHours));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/stores/{storeId}/pos-data:
|
|
* post:
|
|
* summary: Activate integration for selected store (POST /pos_data)
|
|
* tags:
|
|
* - Uber Provisioning
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store provisioned
|
|
* get:
|
|
* summary: Retrieve integration configuration for selected store (GET /pos_data)
|
|
* tags:
|
|
* - Uber Provisioning
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store integration configuration retrieved
|
|
* patch:
|
|
* summary: Update integration settings for selected store (PATCH /pos_data)
|
|
* tags:
|
|
* - Uber Provisioning
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store integration updated
|
|
* delete:
|
|
* summary: De-provision integration for selected store (DELETE /pos_data)
|
|
* tags:
|
|
* - Uber Provisioning
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store integration removed
|
|
*/
|
|
router.post("/uber/stores/:storeId/pos-data", asyncHandler(controller.createPosData));
|
|
router.get("/uber/stores/:storeId/pos-data", asyncHandler(controller.getPosData));
|
|
router.patch("/uber/stores/:storeId/pos-data", asyncHandler(controller.patchPosData));
|
|
router.delete("/uber/stores/:storeId/pos-data", asyncHandler(controller.deletePosData));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-store/stores:
|
|
* get:
|
|
* summary: Store API 1.0.0 - Get stores (/v1/delivery/stores)
|
|
* tags:
|
|
* - Uber Delivery Store v1
|
|
* responses:
|
|
* 200:
|
|
* description: Stores retrieved
|
|
*/
|
|
router.get("/uber/delivery-store/stores", asyncHandler(controller.deliveryListStores));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-store/stores/{storeId}:
|
|
* get:
|
|
* summary: Store API 1.0.0 - Get store details
|
|
* tags:
|
|
* - Uber Delivery Store v1
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store details retrieved
|
|
* post:
|
|
* summary: Store API 1.0.0 - Update store information
|
|
* tags:
|
|
* - Uber Delivery Store v1
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store information updated
|
|
*/
|
|
router.get("/uber/delivery-store/stores/:storeId", asyncHandler(controller.deliveryGetStoreDetails));
|
|
router.post("/uber/delivery-store/stores/:storeId", asyncHandler(controller.deliveryUpdateStore));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-store/stores/{storeId}/status:
|
|
* get:
|
|
* summary: Store API 1.0.0 - Retrieve store status
|
|
* tags:
|
|
* - Uber Delivery Store v1
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store status retrieved
|
|
* post:
|
|
* summary: Store API 1.0.0 - Set store status
|
|
* tags:
|
|
* - Uber Delivery Store v1
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Store status updated
|
|
*/
|
|
router.get(
|
|
"/uber/delivery-store/stores/:storeId/status",
|
|
asyncHandler(controller.deliveryGetStoreStatus)
|
|
);
|
|
router.post(
|
|
"/uber/delivery-store/stores/:storeId/status",
|
|
asyncHandler(controller.deliverySetStoreStatus)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-store/stores/{storeId}/prep-time:
|
|
* post:
|
|
* summary: Store API 1.0.0 - Update prep time
|
|
* tags:
|
|
* - Uber Delivery Store v1
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Prep time updated
|
|
*/
|
|
router.post(
|
|
"/uber/delivery-store/stores/:storeId/prep-time",
|
|
asyncHandler(controller.deliveryUpdatePrepTime)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-store/stores/{storeId}/fulfillment-configuration:
|
|
* post:
|
|
* summary: Store API 1.0.0 - Update BYOC fulfillment configuration
|
|
* tags:
|
|
* - Uber Delivery Store v1
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Fulfillment configuration updated
|
|
*/
|
|
router.post(
|
|
"/uber/delivery-store/stores/:storeId/fulfillment-configuration",
|
|
asyncHandler(controller.deliveryUpdateFulfillmentConfig)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-order/orders/{orderId}:
|
|
* get:
|
|
* summary: Order API 1.0.0 - Get order details
|
|
* tags:
|
|
* - Uber Delivery Order v1
|
|
* parameters:
|
|
* - in: path
|
|
* name: orderId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Order details retrieved
|
|
*/
|
|
router.get("/uber/delivery-order/orders/:orderId", asyncHandler(controller.deliveryGetOrderDetails));
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-order/stores/{storeId}/orders:
|
|
* get:
|
|
* summary: Order API 1.0.0 - List store orders with details
|
|
* tags:
|
|
* - Uber Delivery Order v1
|
|
* parameters:
|
|
* - in: path
|
|
* name: storeId
|
|
* required: true
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Orders listed
|
|
*/
|
|
router.get(
|
|
"/uber/delivery-order/stores/:storeId/orders",
|
|
asyncHandler(controller.deliveryListOrders)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-order/orders/{orderId}/accept:
|
|
* post:
|
|
* summary: Order API 1.0.0 - Accept order
|
|
* tags:
|
|
* - Uber Delivery Order v1
|
|
* responses:
|
|
* 200:
|
|
* description: Order accepted
|
|
*/
|
|
router.post(
|
|
"/uber/delivery-order/orders/:orderId/accept",
|
|
asyncHandler(controller.deliveryAcceptOrder)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-order/orders/{orderId}/deny:
|
|
* post:
|
|
* summary: Order API 1.0.0 - Deny order
|
|
* tags:
|
|
* - Uber Delivery Order v1
|
|
* responses:
|
|
* 200:
|
|
* description: Order denied
|
|
*/
|
|
router.post(
|
|
"/uber/delivery-order/orders/:orderId/deny",
|
|
asyncHandler(controller.deliveryDenyOrder)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-order/orders/{orderId}/cancel:
|
|
* post:
|
|
* summary: Order API 1.0.0 - Cancel order
|
|
* tags:
|
|
* - Uber Delivery Order v1
|
|
* responses:
|
|
* 200:
|
|
* description: Order canceled
|
|
*/
|
|
router.post(
|
|
"/uber/delivery-order/orders/:orderId/cancel",
|
|
asyncHandler(controller.deliveryCancelOrder)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-order/orders/{orderId}/ready:
|
|
* post:
|
|
* summary: Order API 1.0.0 - Mark order ready
|
|
* tags:
|
|
* - Uber Delivery Order v1
|
|
* responses:
|
|
* 200:
|
|
* description: Order ready
|
|
*/
|
|
router.post(
|
|
"/uber/delivery-order/orders/:orderId/ready",
|
|
asyncHandler(controller.deliveryMarkOrderReady)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-order/orders/{orderId}/adjust-price:
|
|
* post:
|
|
* summary: Order API 1.0.0 - Adjust order price
|
|
* tags:
|
|
* - Uber Delivery Order v1
|
|
* responses:
|
|
* 200:
|
|
* description: Order price adjusted
|
|
*/
|
|
router.post(
|
|
"/uber/delivery-order/orders/:orderId/adjust-price",
|
|
asyncHandler(controller.deliveryAdjustOrderPrice)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-order/orders/{orderId}/update-ready-time:
|
|
* post:
|
|
* summary: Order API 1.0.0 - Update order ready time
|
|
* tags:
|
|
* - Uber Delivery Order v1
|
|
* responses:
|
|
* 200:
|
|
* description: Order ready time updated
|
|
*/
|
|
router.post(
|
|
"/uber/delivery-order/orders/:orderId/update-ready-time",
|
|
asyncHandler(controller.deliveryUpdateReadyTime)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-order/orders/{orderId}/resolve-fulfillment-issues:
|
|
* post:
|
|
* summary: Order API 1.0.0 - Resolve fulfillment issues
|
|
* tags:
|
|
* - Uber Delivery Order v1
|
|
* responses:
|
|
* 200:
|
|
* description: Fulfillment issue resolution submitted
|
|
*/
|
|
router.post(
|
|
"/uber/delivery-order/orders/:orderId/resolve-fulfillment-issues",
|
|
asyncHandler(controller.deliveryResolveFulfillmentIssues)
|
|
);
|
|
|
|
/**
|
|
* @openapi
|
|
* /api/v1/uber/delivery-order/replacement-recommendations:
|
|
* post:
|
|
* summary: Order API 1.0.0 - Get replacement recommendations
|
|
* tags:
|
|
* - Uber Delivery Order v1
|
|
* responses:
|
|
* 200:
|
|
* description: Replacement recommendations returned
|
|
*/
|
|
router.post(
|
|
"/uber/delivery-order/replacement-recommendations",
|
|
asyncHandler(controller.deliveryGetReplacementRecommendations)
|
|
);
|
|
|
|
module.exports = router;
|