Skip to content

joshuand1990/filterable-api

Repository files navigation

Filterable API

Requirements

  • CLI command to convert the input CSV file (see last section) to a JSON and XML file.
  • REST API to serve the contents of the JSON file filterable by name and discount_percentage. Serving a filtered response in XML format.
  • README file with anything you would like us to know about your solution and any future improvements you might make.

Installation

  • Docker need to be installed on your machine.
  • run docker compose build to build the necessary dependencies.
  • run docker compose up to start the machine.
  • To ssh into the docker container there is a script in ./docker/shell.sh, on MacOS you can sh ./docker/shell.sh.
  • Once in the default directory /var/www/html, run composer install, all the necessary packages will be installed.
  • After the installation scripts of composer please create config file, .env, in the root directory of the project
  • When the installation completes, all the available cli commands can be accessed using php artisan while in the root directory via the terminal.
  • Web server can be accessed using http://localhost.
  • Since we are using an .env file, the "database" (json file) can be configured using hte key CSV_FILE, in-case there needs to be any path changes - the full path needs to given
  • There is a sample .env file called .env.example that can be used as a template

API Reference

Get all items

  GET /api/listings
Parameter Type Description
name string optional. Filters by name
discount_percentage string optional. Filters by discount percentage

CSV Convertor

php artisan app:convert {file} {formats=xml,json} {outputFilename}

This command will create the necessary files for the web api to read and serve.

Notes:

  • Lumen Framework (lite framework with a quick router)
  • PHP 7.2
  • main csv file is under the storage folder

Testing:

  • run tests using the composer test command while the active directory is the project root.
  • all tests are available in the tests folder.

Improvements

  • Adding Auth System using JWT
  • Using a database (maybe sqlite) to complete the CURD operations.
  • Move the api to JSON.
  • Depending on the volume of data, we could implement a cache system.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors