Git Product home page Git Product logo

hotelapi's Introduction

alt text

Hotel API Programming

In this exam, you are provided with hotels database in CSV (Comma Separated Values) format.

We need you implement HTTP service, according to the API requirements described below. You may use any language or platform that you like: C#/Java/Scala/etc.

Good luck!

Application is built using Spring boot and Java 8.

API

  1. Search hotels by CityId
API Rest URL: http://<hostname>:<portname>/city/{cityId}
Ex: http://localhost:8080/city/Bangkok
  1. Provide optional sorting of the result by Price (both ASC and DESC order). Will pass as request parameter "order". Permissible values are "ASC" and "DESC".

    For example http://localhost:8080/city/Bangkok?order=ASC

    By default there would not be any ordering

API Rate Limit: Every API is bounded by rate limit defined in application.properties file. This properties file will contain rate per duration (in seconds) for each API. Every API is uniquely identified by a key called API Key. Valid API keys are defined in com.agoda.hotel.model.GET_HOTEL_BY_CITY.

Each request to API must be provided with following Header param (apart from application/json as Content-Type):

API_KEY: API KEY NAME

Also every API must have their unqiue key defined in application.properties file

For example, for search hotel by city ID. Caller must provide following as

Header param: API_KEY: GET_HOTEL_BY_CITY

So if user exceeds rate limit, then operation would be halted for 5 minutes. Service would come back again after 5 minutes.

I have used Token bucket algorithm to implement Rate limit feature.

Build and Run instructions

Make sure system has maven 3 and JDK 8 deployed To build this code, run following command inside the project (where pom.xml is located)

mvn clean install

Once build is successful, run following command to up app server

java -jar target/hotel-rest-service-0.1.0.jar

App server would start running at localhost:8080

API Testing

Use any REST Client and make an HTTP request at following details:

URL: http://localhost:8080/city/Bangkok (Bangkok is example city. It could be any valid city ID)

Method: GET

Header: Content-Type: application/json API_KEY: GET_HOTEL_BY_CITY

Response:

200 OK: Result in JSON format for all hotel details in given city ID. Result could be put in ASC or DESC by passing "order" as request parameter.

403: Forbidden, If you caller exceed API call rate limit

500: Internal Server Error

All material herein © 2005 – 2014 Agoda Company Pte. Ltd., All Rights Reserved.
AGODA ® is a registered trademark of AGIP LLC, used under license by Agoda Company Pte. Ltd.
Agoda is part ofPriceline (NASDAQ:PCLN)

hotelapi's People

Contributors

hagaypeleg avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar Shekhar Gupta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.