Skip to content

Microservice that allows to create and search elements of type BIKE

Notifications You must be signed in to change notification settings

gsmoral/api_bike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Bike logo

API Bike

This project was created with Laravel.

Run this project

To run this project perform the following steps:

Clone project

Run: git clone https://github.com/gsmoral/api_bike.git and navigate to project folder.

IMPORTANT: in \laravel-app folder, rename .env.example to .env

Docker

Run: docker-compose build and docker-compose up -d

Connect to Docker container: docker exec -it l_app /bin/sh

Inside container run: composer install and php artisan migrate --seed


phpMyAdmin

You can administrate the database from http://localhost:8081/

Use: Server: l_mysql_db, User: root, Password: toor


API

With postman, set headers: Content-Type: application/json and Accept: application/json

For ***Protected Routes -> *** Use: Authorization - Bearer Token witn obtained token in Login

Response to Unauthenticated: { "message": "Unauthenticated." }

POST - Login

localhost:8080/api/auth/login

Body:

{
  "email": "test@example.com",
  "password": "password"
}

Response example:

{
    "status": true,
    "token": "NHFaGamgR2pPxPKgzNhrpVRsdoo0uicmtJwVkqNpHQqu"
}

GET - Get bikes

localhost:8080/api/bikes

Search params for example: localhost:8080/api/bikes?name="Mountain"&manufacturer=Technogym&item_type="item_type"&sort=asc

Response example:

{
    "status": true,
    "total": 2,
    "data": [...]
}

GET - Get bike

Response cached.

localhost:8080/api/bike/1

Response example:

{
    "status": true,
    "data": {
        "id": 1,
        "name": "aperiam",
        "description": "Consequatur sit velit inventore necessitatibus doloribus nulla. Reiciendis id et exercitationem voluptatem quas quae enim. Id alias pariatur ea delectus enim consequatur. Voluptatem nulla consequatur cumque et ducimus magni dicta.",
        "price": "828.95",
        "manufacturer": "Toorx",
        "created_at": "2023-07-02T11:20:59.000000Z",
        "updated_at": "2023-07-02T11:20:59.000000Z",
        "items": [
            {
                "id": 17,
                "model": "error",
                "type": "a",
                "description": "Vero consequatur accusantium labore voluptatem possimus.",
                "created_at": "2023-07-02T11:21:02.000000Z",
                "updated_at": "2023-07-02T11:21:02.000000Z"
            }
        ]
    }
}

POST - Save Bike

To create a new bike, the elements must exist in the database (30 elements have been created). Only created item IDs can be submitted.

localhost:8080/api/bikes

Body:

{
  "name": "Test 3",
  "manufacturer": "ABC Bikes",
  "description": "A high-quality mountain bike",
  "price": 100.99,
  "item_ids": [10,13,21]
}

Response example:

{
    "status": true,
    "data": {
        "name": "Test 3",
        "description": "A high-quality mountain bike",
        "price": 100.99,
        "manufacturer": "ABC Bikes",
        "updated_at": "2023-07-02T17:35:13.000000Z",
        "created_at": "2023-07-02T17:35:13.000000Z",
        "id": 25,
        "items": [
            {
                "id": 10,
                "model": "provident",
                "type": "et",
                "description": "Eligendi alias facilis molestias et qui sunt nihil.",
                "created_at": "2023-07-02T11:21:01.000000Z",
                "updated_at": "2023-07-02T11:21:01.000000Z"
            },
            {
                "id": 13,
                "model": "quis",
                "type": "eligendi",
                "description": "Saepe atque est dolores voluptas numquam sed.",
                "created_at": "2023-07-02T11:21:02.000000Z",
                "updated_at": "2023-07-02T11:21:02.000000Z"
            },
            {
                "id": 21,
                "model": "repellat",
                "type": "qui",
                "description": "Ut soluta sunt autem porro voluptates adipisci.",
                "created_at": "2023-07-02T11:21:03.000000Z",
                "updated_at": "2023-07-02T11:21:03.000000Z"
            }
        ]
    }
}

About

Microservice that allows to create and search elements of type BIKE

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages