Skip to content

Latest commit

 

History

History
366 lines (285 loc) · 5.07 KB

File metadata and controls

366 lines (285 loc) · 5.07 KB

Movie API Documentation

Endpoints :

List of available endpoints:

  • POST /register
  • POST /login
  • GET /trips
  • POST /trips
  • PUT /trips/:id
  • POST /payment/:id

 

1. POST /register

Request:

  • body:
{
  "email": "string",
  "password": "string",
  "firstName": "string",
  "lastName": "string",
  "isDriver": "boolean",
}

Response (201 - Created)

{
    "message": "Register successful",
    "email": "email@mail.com",
}

Response (400 - Bad Request)

[
    "Email are required",
    "Please enter a valid email address",
    "Password are required",
    "first name are required",
    "last name are required",
]
OR
[
    "email must be unique"
]

 

2. POST /login

Request:

  • body:
{
  "email": "string",
  "password": "string"
}

Response (200 - OK)

{
  "message": "Login successful",
  "access_token": "string",
  "user_id": 1,
  "is_driver": "boolean"
}

Response (400 - Bad Request)

{
  "message": "Email is required"
}
OR
{
  "message": "Password is required"
}

Response (401 - Unauthorized)

{
  "message": "Invalid email/password"
}

 

3. GET /trip

Description:

  • Get all trips from database

Request:

  • headers:
{
  "access_token": "string"
}

Response (200 - OK)

[
    {
        "id": 32,
        "UserId": 7,
        "DriverId": 7,
        "pickupLat": "-6.921152067931175",
        "pickupLong": "107.66306753896748",
        "pickupLocation": "Mesjid Al-Hikmah, Jln. Sampang No. 1",
        "destinationLat": "-6.931961488821898",
        "destinationLong": "107.67167736128528",
        "destinationLocation": "Kelurahan Cisaranten Endah, Jl. Parakansaat No.150",
        "tripStart": null,
        "tripEnd": null,
        "status": "string",
        "redirectUrl": null,
        "updatedAt": "2021-11-18T06:29:53.006Z",
        "User": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "Driver": {
            "firstName": "John",
            "lastName": "Doe"
        }
    },
  ...
]

 

4. POST /trip

Description:

  • Create trip by id

Request:

  • headers:
{
  "access_token": "string"
}
  • params:
{
    "pickup": ["-6.921152067931175", "107.66306753896748"],
    "pickupLocation": ["-6.931961488821898", "107.67167736128528"],
    "destination": "Mesjid Al-Hikmah, Jln. Sampang No. 1",
    "destinationLocation": "Kelurahan Cisaranten Endah, Jl. Parakansaat No.150",
}

Response (201 - Created)

{
    "id": 32,
    "UserId": 7,
    "DriverId": 7,
    "pickupLat": "-6.921152067931175",
    "pickupLong": "107.66306753896748",
    "pickupLocation": "Mesjid Al-Hikmah, Jln. Sampang No. 1",
    "destinationLat": "-6.931961488821898",
    "destinationLong": "107.67167736128528",
    "destinationLocation": "Kelurahan Cisaranten Endah, Jl. Parakansaat No.150",
    "tripStart": null,
    "tripEnd": null,
    "status": "string",
    "redirectUrl": null,
    "updatedAt": "2021-11-18T06:29:53.006Z",
    "User": {
        "firstName": "John",
        "lastName": "Doe"
    },
    "Driver": {
        "firstName": "John",
        "lastName": "Doe"
    }
},

 

5. PATCH /trip/:id

Description:

  • Update status by id

Request:

  • headers:
{
  "access_token": "string"
}
  • params:
{
  "id": "integer (required)",
  "status": "string (required)"
}

Response (200 - OK)

{
    "id": 32,
    "UserId": 7,
    "DriverId": 7,
    "pickupLat": "-6.921152067931175",
    "pickupLong": "107.66306753896748",
    "pickupLocation": "Mesjid Al-Hikmah, Jln. Sampang No. 1",
    "destinationLat": "-6.931961488821898",
    "destinationLong": "107.67167736128528",
    "destinationLocation": "Kelurahan Cisaranten Endah, Jl. Parakansaat No.150",
    "tripStart": null,
    "tripEnd": null,
    "status": "string",
    "redirectUrl": null,
    "updatedAt": "2021-11-18T06:29:53.006Z",
    "User": {
        "firstName": "John",
        "lastName": "Doe"
    },
    "Driver": {
        "firstName": "John",
        "lastName": "Doe"
    }
},

Response (403 - Forbidden)

{
  "message": "Forbidden: Not Authorized"
}

Response (404 - Not Found)

{
  "message": "Trip with id {id} not found"
}

 

6. POST /google-signin

Request:

  • body:
{
  "id_token": "string",
}

Response (200 - OK)

{
  "message": "Login successful",
  "access_token": "string"
}

Response (201 - Created)

{
  "message": "Login successful",
  "access_token": "string",
  "user_id": 1,
  "user_role": "Staff"
}

 

7. POST /payment

Request:

  • body:
{
  "card_number": "string",
  "card_exp_month": "string",
  "card_exp_year": "string",
  "card_cvv": "string",
  "price": "string"
}

Response (200 - OK)

{
  "message": "Charge successful",
}

 

Global Error

Response (401 - Unauthorized)

{
  "message": "Not Authorized"
}
OR
{
  "message": "Invalid Email or Password"
}

Response (500 - Internal Server Error)

{
  "message": "Internal server error"
}