# Smart Locker Explanation # Main Flow ### 1. Add new Box from the admin dashboard The Box will have a unique serial number, and it will be stored in the box. ### 2. First time Box connect to the internet The box will inform the server by sent request ### 3. Response from the server There is no response for the for fist time if there is no update for this box after 30 sec the server will send that there is no data then the box should send a new request ...etc ### 4. Open Box anytime the server can send to the box to open the box ### 5. Send updated from the Box send the server that Box in opend or closed The server will response, if not the box should try again to send ### 6. In case the server is down the box have to keep try to connect the server ---------------------------- ---------------------------- ---------------------------- ---------------------------- # API's All functionalities are accessible from this API host: : https://smart-locker-v1.herokuapp.com #### Conenct Box With The Server ```jsx= API => /api/v1/locker/connect/:serialNumber GET >> This API will response with no data in general unless the server have somthing to reply { statusCode: 200, message: "No Updates", } In this case you have to reconnect the server with same API ---------------------------------------------------------------------------- >> If the serialNumber is not found { statusCode: 404, message: "Box Not Found", } ---------------------------------------------------------------------------- >> If the server has updates ( Ex. open box ) { statusCode: 200, message: "Open Box" } ``` ---- #### Update Box Status ( Opened ) ```jsx= API => /api/v1/locker/box-opened/:serialNumber PUT >> If the serialNumber is not found { statusCode: 404, message: "Box Not Found", } ---------------------------------------------------------------------------- >> If the Box status is already opened { statusCode: 400, message: "Box Is Already Open", } ---------------------------------------------------------------------------- >> Success case { statusCode: 200, message: "Box Opened Successfully" } ``` #### Update Box Status ( Closed ) ```jsx= API => /api/v1/locker/box-closed/:serialNumber PUT >> If the serialNumber is not found { statusCode: 404, message: "Box Not Found", } ---------------------------------------------------------------------------- >> If the Box status is already colesd { statusCode: 400, message: "Box Is Already Close", } ---------------------------------------------------------------------------- >> Success case { statusCode: 200, message: "Box Closed Successfully" } ```