Giter Club home page Giter Club logo

practice_reservation_booking's Introduction

README

This app is currently deployed in Heroku. These are the relevant urls:

  • base url - https://enatividad-reservation-booking.herokuapp.com/
  • create reservation - https://enatividad-reservation-booking.herokuapp.com/reservations.json
  • show reservation - https://enatividad-reservation-booking.herokuapp.com/reservations/1.json

I have added 2 records after deploying this app:

Implementation Notes

  • This app was developed using rbenv-managed ruby 2.6.7
  • This app assumes that if Guest record of Payload 1 has an id of 1 and if Guest record of Payload 2 has an id of 2, THEN Payload 1 Guest and Payload 2 Guest are the same records
    • This assumption can imply that Payload 1 and Payload 2 retrieve their data from the same data source
    • This assumption has led me to implement Guest so that if record with id 1 is present, the create reservation endpoint updates the existing Guest record instead of creating a new one. For clarification, Reservation records are always created.
  • This app makes as little assumptions as possible, leading to an implementation with minimal model validations
    • Guest#email can either be nil or an arbitrary string, as this implementation intends
  • Please refer to the code samples below for Payload 1 and Payload 2

Payload 1

{
  "start_date": "2021-03-12",
  "end_date": "2021-03-16",
  "nights": 4,
  "guests": 4,
  "adults": 2,
  "children": 2,
  "infants": 0,
  "status": "accepted",
  "guest": {
    "id": 1,
    "first_name": "Wayne",
    "last_name": "Woodbridge",
    "phone": "639123456789",
    "email": "[email protected]"
  },
  "currency": "AUD",
  "payout_price": "3800.00",
  "security_price": "500",
  "total_price": "4500.00"
}

Payload 2

{
  "reservation": {
    "start_date": "2021-03-12",
    "end_date": "2021-03-16",
    "expected_payout_amount": "3800.00",
    "guest_details": {
      "localized_description": "4 guests",
      "number_of_adults": 2,
      "number_of_children": 2,
      "number_of_infants": 0
    },
    "guest_email": "[email protected]",
    "guest_first_name": "Wayne",
    "guest_id": 1,
    "guest_last_name": "Woodbridge",
    "guest_phone_numbers": [
      "639123456789",
      "639123456789"
    ],
    "listing_security_price_accurate": "500.00",
    "host_currency": "AUD",
    "nights": 4,
    "number_of_guests": 4,
    "status_type": "accepted",
    "total_paid_amount_accurate": "4500.00"
  }
}

Dependencies

  • Ruby version: 2.6.7
  • System dependencies:
    • ruby
    • postgresql

Development Environment Setup

  • run bin/setup from inside the project directory
    • if the database cannot be created, either configure config/database.yml to use your postgresql credentials OR configure your postgresql installation to work with the current config/database.yml
  • run bin/rails test to execute the test suite

Production Environment Setup

  • install heroku-cli
  • run heroku login from the terminal
    • make a Heroku account if you do not have one
  • configure your ssh keys from inside your Heroku account
  • run heroku create from inside the project directory
  • run git push heroku master
  • run heroku run rails db:migrate
  • run heroku ps:scale web=1
  • run heroku open. if the browser doesn't open, manually click the generated app url.
  • use the app's base url by making api requests in:
    • GET /reservations/:id.json
    • POST /reservations.json

License

This app was developed by Emmanuel Natividad. Copyright © 2021, Emmanuel Natividad

practice_reservation_booking's People

Watchers

Emmanuel Natividad avatar  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.