/TajawalAPI

Tajawal Code Challenge solution, by Ahmad Tawila

Primary LanguagePHP

Tajawal Code Challenge solution

By Ahmad Tawila

The challenge details is mentioned here

The Solution is implemented in PHP 7.2 with Symfony4 Framework, and PHPunit for testing.


Travis-CI Build Status

Scrutinizer-CI Build Status Code Coverage Scrutinizer Code Quality Code Intelligence Status

CodeClimate Test Coverage Maintainability


Assumptions

No assumptions for the moment

Installation

You need a machine that has PHP 7.2 and Composer installed.

  • clone this repository

    git clone https://github.com/a-tawila/TajawalAPI.git TajawalAPI
    cd TajawalAPI
    
  • install project dependencies using Composer

    composer install --dev
    
  • run the local webserver

    php bin/console server:run
    

    The default URL for this installation from you local machine should be http://localhost:8000

Usage

consuming the API

  • using any RestAPI client like Postman call the following URL

    GET http://localhost:8000/search
    
  • use the follwing parameters to narrow down your search results.

    f[hotel_name]=Gold  // a part of the hotel name, case insinsitive.
    f[city]=cairo       // city name must match the exact name, case insinsitive.
    f[price_max]=200    // int/float value (100, 90.5, 111.3, ... etc)
    f[price_min]=200
    f[start_date]=200   // start date, format dd-mm-yyyy (ex. 21-09-2020)
    f[end_date]=200     // end data same format
    
    s[hotel_name]=asc   // Sorting by hotel name (values 'asc' or 'desc', default 'asc')
    s[price]=asc        // Sorting by price      (values 'asc' or 'desc', default 'asc')
    

    example call URLs

    GET http://localhost:8000/search?f[city]=cairo&f[price_max]=200&s[price]=asc
    
    GET http://localhost:8000/search?f[hotel_name]=tuli
    
    GET http://localhost:8000/search
    

running the tests

Tests are written with PHPUnit 7

cd TajawalAPI
vendor/bin/simple-phpunit