API Parkings - morenagit/wikiTest GitHub Wiki

Parkings

A parking represents a single parking spot owned by a parking company.

GET /companies/:name/parkings

Description

Retrieves all the parking spots of a specific company.

  • Resource URI: /companies/:name/parkings
  • HTTP Req type: GET
  • Res Content Type: application/json

Path parameters

Parameter Type Description
name String Name of the company that manages the parking spots

Response Body

HTTP Res Code Structure Description
200 OK
  • Content
  • Message
  • Code
Returns the list of parkings of the company
404 Not found
  • Message
  • Code
The resource cannot be found
401 Unauthorized
  • Message
  • Code
Invalid or missing authorization token

Example

GET /api/companies/Company1/parkings

{
    "code": "200",
    "status": "success",
    "message": "Resource successfully retrieved",
    "content": [
        {
            "location": {
                "type": "Point",
                "coordinates": [
                    13.069174,
                    43.139802
                ]
            },
            "plate": null,
            "handicap": false,
            "indoor": false,
            "price": 2,
            "company": "Company1",
            "isApproved": true,
            "isUsable": true,
            "_id": "5e2494b12681366ecc4d2c06",
            "id": 1,
            "address": "Madonna delle Carceri",
            "city": "Camerino",
            "isFree": true
        },
        {
            "location": {
                "type": "Point",
                "coordinates": [
                    13.068363,
                    43.13937
                ]
            },
            "plate": null,
            "handicap": false,
            "indoor": false,
            "price": 2,
            "company": "Company1",
            "isApproved": true,
            "isUsable": true,
            "_id": "5e2494b12681366ecc4d2c16",
            "id": 2,
            "address": "Madonna delle Carceri",
            "city": "Camerino",
            "isFree": true
        }
    ]
}

GET /companies/:name/parkings/:id

Description

Retrieves a parking spot of a specific company.

  • Resource URI: /companies/:name/parkings/:id
  • HTTP Req type: GET
  • Res Content Type: application/json

Path parameters

Parameter Type Description
name String Name of the company that manages the parking spot
id Int Id of the parking spot

Response Body

HTTP Res Code Structure Description
200 OK
  • Content
  • Message
  • Code
Returns the requested parking spot
404 Not found
  • Message
  • Code
The resource cannot be found
401 Unauthorized
  • Message
  • Code
Invalid or missing authorization token

Example

GET /api/companies/Company1/parkings/1

{
    "code": "200",
    "status": "success",
    "message": "Resource successfully retrieved",
    "content": {
        "location": {
            "type": "Point",
            "coordinates": [
                13.069174,
                43.139802
            ]
        },
        "plate": null,
        "handicap": false,
        "indoor": false,
        "price": 2,
        "company": "Company1",
        "isApproved": true,
        "isUsable": true,
        "_id": "5e2494b12681366ecc4d2c06",
        "id": 1,
        "address": "Madonna delle Carceri",
        "city": "Camerino",
        "isFree": true
    }
}

POST /companies/:name/parkings

Description

Creates a new parking for the company.

  • Resource URI: /companies/:name/parkings
  • HTTP Req type: POST
  • Req Content Type: application/x-www-form-urlencoded
  • Res Content Type: application/json

Path parameters

Parameter Type Description
name String Name of the company that manages the parking spots

Request Body

Parameter Type Description
id Int Parking ID
city String Parking city
address String Parking address
latitude String Parking latitude
longitude String Parking longitude
indoor Boolean Location of the parking (indoor or outdoor)
handicap Boolean Indicates if the parking is accessible
price Double Hourly rate of the parking

Response Body

HTTP Res Code Structure Description
201 Created
  • Content
  • Message
  • Code
Resource has been successfully created
422 Unprocessable Entity
  • Message
  • Code
The parking spot already exists
401 Unauthorized
  • Message
  • Code
Invalid or missing authorization token

Example

POST /api/companies/Company1/parkings

{
    "code": "201",
    "status": "success",
    "message": "Resource successfully created",
    "content": {
        "location": {
            "type": "Point",
            "coordinates": [
                13.067321,
                43.142813
            ]
        },
        "plate": null,
        "handicap": false,
        "indoor": false,
        "price": 1,
        "company": "Company1",
        "isApproved": false,
        "isUsable": true,
        "_id": "5e56851a1ddc39111899206c",
        "id": 45,
        "city": "Camerino",
        "address": "Via Madonna delle carceri, 41"
    }
}

PATCH /companies/:name/parkings/:id

Description

Updates the properties of a parking spot.

  • Resource URI: /companies/:name/parkings/:id
  • HTTP Req type: PATCH
  • Req Content Type: application/x-www-form-urlencoded
  • Res Content Type: application/json

Path parameters

Parameter Type Description
name String Name of the company that manages the parking spot
id Int Id of the parking spot

Request Body

Parameter Type Description
price Double Hourly rate of the parking
isUsable Boolean Indicates if the parking is currently usable
isApproved Boolean Indicates whether the parking has been approved by the Municipality or not

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
401 Unauthorized
  • Message
  • Code
Invalid or missing authorization token

Example

PATCH /api/companies/Company1/parkings/45
price=3.0

{
    "code": "200",
    "status": "success",
    "message": "Resource successfully updated",
    "content": {
        "location": {
            "type": "Point",
            "coordinates": [
                13.067321,
                43.142813
            ]
        },
        "plate": null,
        "handicap": false,
        "indoor": false,
        "price": 3,
        "company": "Company1",
        "isApproved": null,
        "isUsable": null,
        "_id": "5e56851a1ddc39111899206c",
        "id": 45,
        "city": "Camerino",
        "address": "Via Madonna delle carceri, 41"
    }
}

DELETE /companies/:name/parkings/:id

Description

Deletes a parking spot.

  • Resource URI: /companies/:name/parkings/:id
  • HTTP Req type: DELETE
  • Res Content Type: application/json

Path parameters

Parameter Type Description
name String Name of the company that manages the parking spot
id Int Id of the parking spot

Response Body

HTTP Res Code Structure Description
204 No Content Resource has been successfully deleted
404 Not found
  • Message
  • Code
The resource cannot be found
401 Unauthorized
  • Message
  • Code
Invalid or missing authorization token
⚠️ **GitHub.com Fallback** ⚠️