Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

jezumbro/open-exchange-rate-challenge

Repository files navigation

Table of contents

  1. Intro
  2. Your tasks
  3. Project Layout
  4. Running the project
  5. Specifications
  6. Submitting
  7. Evaluation

Intro

Your mission is to build a simplified API to power a listing website.

The Listing entity carries a certain number of information about the property (title, market, etc) and has a Calendar to carry prices and availability.

A Calendar is just a list of dates with added information about each date - for example each date can have a different price:

date=2020-01-01, price=500
date=2020-01-02, price=450

Additionally, the concept of a "Base Price". When we predict a price for a day, we think of it as a multiple of the base price. E.g. a price of $150 for a specific day is a 1.5x multiple on the base price of $100.

The challenge will work with a simplified version of the listing and the calendar.

Your tasks

Endpoints to implement:

(See Specifications for more details)

  1. Create a listing
    See POST /listings endpoint

  2. Retrieve a listing
    See GET /listings/:id endpoint

  3. Update a listing
    See PUT /listings/:id endpoint

  4. Delete a listing
    See DELETE /listings/:id endpoint

  5. Retrieve several listings
    See GET /listings endpoint

  6. Retrieve a listing's calendar
    See GET /listings/:id/calendar endpoint

Project Layout

  • We've set up Flask in app.py. Implement the endpoints in this file. We also added an example to show how to use Flask to process the information of a request.

Specifications

Your solution must use python 3.7 or greater.

Your solution must persist data into a file without using an ORM library or a DB system.

Your solution must use [open exchange rates][open-exchange-rates] to get the exchange rates. The free plan is enough to complete this task.

The response format of your API must be JSON and a proper use of HTTP status codes and error handling is expected.

  1. POST /listings endpoint

    • Send JSON data in the body, for example:

      {
         "title": "Comfortable Room In Cozy Neighborhood",
         "base_price": 867,
         "currency": "USD",
         "market": "san-francisco",
         "host_name": "John Smith"
      },
      

      All fields are required except for host_name.

    • Return: the listing information (including its ID) in a JSON format.

  2. GET /listings/:id endpoint

    • Return: the listing information (including its ID) in a JSON format.
  3. PUT /listings/:id endpoint

    • Send JSON data in the body
    • Update only the fields present in the request
    • Return: the listing information (including its ID) in a JSON format.
  4. DELETE /listings/:id endpoint

    • A successful response must mean a listing was deleted.
  5. GET /listings endpoint

    • Return: a list of listings in a JSON format.

    • This endpoint should allow to filter by market and base price/currency.

      Those filters must be implemented as query parameters:

      • market - optional

        • A single market or a list of markets separated by commas. It uses the market codes.
        • E.g.: ?market=paris or ?market=paris,san-francisco
      • base_price.[e|gt|gte|lt|lte] - optional

        • The comparison type is part of the query parameter.
        • E.g.: ?base_price.gt=500 or ?base_price.lte=300
      • currency - optional but required when base price is specified

        • It uses the currency codes.
        • E.g.: ?currency=usd
  6. GET /listings/:id/calendar endpoint

    • This endpoint returns the listing's calendar (365 days starting from today).

    • It must allow to return the calendar in any currency. The default being the listing's currency.

      This parameter must be implemented as a query parameter:

      • currency - optional
        • It uses the currency codes.
        • E.g.: ?currency=usd
    • Format for dates: YYYY-MM-DD

    • Calendar rules:

      • For the Paris and Lisbon markets: Saturday and Sunday => 1.5x of base price
      • For the San Francisco market: Wednesday => 0.70x of base price
      • For the rest of the markets: Friday => 1.25x of base price
    • Example of response:

    [
       {
          "date": "2019-01-01",
          "price": 500,
          "currency": "USD",
       },
       {
          "date": "2019-01-02",
          "price": 550,
          "currency": "USD",
       },
       ...
    ]
    

About

Open Exchange Rate Challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages