Api Stops - morenagit/wikiTest GitHub Wiki

Stops

GET /stops

Description

Retrieves all stops

  • Resource URI: /stops
  • HTTP Req type: GET
  • Res Content Type: application/json

Query parameters

Parameter Type Description
company String Name of the parking company that manages the parking spots
plate String License plate
email String Driver email

Response Body

HTTP Res Code Structure Description
200 OK
  • Content
  • Message
  • Code
Returns the list of stops
404 Not found
  • Message
  • Code
The resource cannot be found

Example

GET /stops?company=Company1

{
    "code": "200",
    "status": "success",
    "message": "Resource successfully retrieved",
    "content": [
        {
            "driverEmail": "[email protected]",
            "start": "2020-01-28T11:17:41.881Z",
            "end": "2020-01-28T19:30:39.817Z",
            "valid": true,
            "paid": null,
            "_id": "5e30185521d84707a4195b39",
            "parkingId": 1,
            "company": "Company1",
            "plate": "BB888FF",
            "cost": 4
        },
        {
            "driverEmail": null,
            "start": "2020-01-28T15:44:38.304Z",
            "end": null,
            "valid": false,
            "paid": null,
            "_id": "5e3056e6db3f7a3d748dd8d4",
            "parkingId": 1,
            "company": "Company1",
            "plate": "EF234GH",
            "cost": null
        }
    ]
}

PATCH /stops/:id

Description

Updates a stop to add a timestamp of the driver’s payment.

  • Resource URI: /stops/:id
  • HTTP Req type: PATCH
  • Res Content Type: application/json

Path parameters

Parameter Type Description
id String Id of the stop

Response Body

HTTP Res Code Structure Description
200 OK
  • Content
  • Message
  • Code
Resource has been successfully updated
404 Not found
  • Message
  • Code
The resource cannot be found

Example

PATCH /stop/5e30185521d84707a4195b39

{
    "code": "200",
    "status": "success",
    "message": "Resource successfully updated",
    "content": [
        {
            "driverEmail": "[email protected]",
            "start": "2020-01-28T11:17:41.881Z",
            "end": "2020-01-28T19:30:39.817Z",
            "valid": true,
            "paid": 2020-01-28T22:32:39.817Z,
            "_id": "5e30185521d84707a4195b39",
            "parkingId": 1,
            "company": "Company1",
            "plate": "BB888FF",
            "cost": 4
        }
    ]
}

Stops simulation

The stops simulation APIs allow to simulate the arrival and departure of a driver. When a vehicle parks, the sensor detects the plate number and checks for a booking. If there are no bookings, the stop is considered invalid.

Stop start

Description

Simulates a driver parking on a specific parking spot by creating a new stop document.

  • Resource URI: /stop/start
  • HTTP Req type: POST
  • Req Content Type: application/x-www-form-urlencoded
  • Res Content Type: application/json

Request Body

Parameter Type Description
parking Int Parking ID
company String Name of the company that manages the parking spot
plate String License plate read by the sensor

Response Body

HTTP Res Code Structure Description
201 Created
  • Content
  • Message
  • Code
Resource has been successfully created

Example

POST /stop/start

{
    "code": "201",
    "status": "success",
    "message": "Resource successfully created",
    "content": [
        {
            "driverEmail": "[email protected]",
            "start": "2020-01-28T11:17:41.881Z",
            "end": null,
            "valid": true,
            "paid": null,
            "_id": "5e30185521d84707a4195b39",
            "parkingId": 1,
            "company": "Company1",
            "plate": "BB888FF",
            "cost": null
        }
    ]
}
}

Stop end

Description

Simulates a driver leaving a parking spot. When the driver leaves, the corresponding stop document is updated with the departure timestamp, and the total cost is calculated.

  • Resource URI: /stops/end
  • HTTP Req type: PATCH
  • Res Content Type: application/json

Request Body

Parameter Type Description
parking Int Parking ID
company String Name of the company that manages the parking spot
plate String License plate read by the sensor

Response Body

HTTP Res Code Structure Description
200 OK
  • Content
  • Message
  • Code
Resource has been successfully updated
404 Not found
  • Message
  • Code
The resource cannot be found

Example

PATCH /stop/end

{
    "code": "200",
    "status": "success",
    "message": "Resource successfully updated",
    "content": [
        {
             "driverEmail": "[email protected]",
            "start": "2020-01-28T11:17:41.881Z",
            "end": "2020-01-28T19:30:39.817Z",
            "valid": true,
            "paid": null,
            "_id": "5e30185521d84707a4195b39",
            "parkingId": 1,
            "company": "Company1",
            "plate": "BB888FF",
            "cost": 4
        }
    ]
}
}
⚠️ **GitHub.com Fallback** ⚠️