This is a Laravel-based API that fetches, parses, maps, and stores product data from an external API into a local database. The data can then be retrieved in either JSON or XML format.
Note: This project was done for a recruitment interview at Bugloos.
- Fetches data from an external API
- Parses the fetched data based on its content type (XML or JSON)
- Maps the parsed data to match the fields of the local database
- Stores the mapped data in the database
- Retrieves all stored products in either JSON or XML format
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- PHP >= 8.1
- Composer
- Laravel >= 10.x
- A SQL database
- Clone the repository:
git clone https://github.com/aliosmanyuksel/bugloosLaravel.git
- Navigate to the project directory:
cd bugloosLaravel
- Install Composer dependencies:
composer install
- Create a
.env
file by copying the example file:cp .env.example .env
- Add to .env file this lines.
API_URL=https://aliosmanyuksel.com.tr/wp-content/uploads/products.json CONFIG_PATH=/products.yml
- Generate an app key:
php artisan key:generate
- Set up your database and fill in the database information in the
.env
file - Migrate the database:
php artisan migrate
- Run the server:
php artisan serve
- The application should now be running at
http://localhost:8000
The application currently supports two endpoints:
GET /api/fetch
: Fetches, parses, maps, and stores product data from the external APIGET /api/products
: Retrieves all stored products in the format specified by theAccept
header of the request
You can run the application's tests by using the following command: php artisan test
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under the MIT License - see the LICENSE.md file for details