Giter Club home page Giter Club logo

appt-api-app's Introduction

##Appointment API

This appointment API was designed to use imported data from a CSV (comma-separated values) file to create a database-driven RESTful Web API using Ruby on Rails.

I used test-driven development (TDD) to create this API, testing all 4 methods that facilitate CRUD operations on the appointment resources. Please refer to the integration tests for more information:

  • GET request (Read): Returns a list of all of the appointments, in JSON.
  • POST request (Create): Able to create an appointment, but first and last name need to be present, and start/end times must be in the future.
  • Integration tests were written to ensure that the above is true, if valid, as well as appointments can not overlap.
  • In order to truly make sure that this works, I created a file called api_test.rb. The code in this file allows us to use HTTParty to test the POST HTTP method.
  • Here is the code in that file:
    require 'httparty'
    require 'json'
    require 'pp'

    data = {
      body: {
        appointment: {
        first_name: "Maddie",
        last_name: "Campos",
        start_time: "2015-12-2T19:00:00.000Z",
        end_time: "2015-12-2T120:05:00.000Z"
         }
        }
      }

     response = HTTParty.post('https://vast-woodland-4805.herokuapp.com/appointments', data)

     print response
  • Checking the heroku logs will help see what kind of request was made (POST, in this instance), along with the status code.
  • The newly created appointment may also be verified in the heroku console by typing: Appointment.last.
  • It is also confirmed that appointments can not be created with duplicate start times (no overlap)
  • PUT/PATCH request (Update): After updating an entry, the data is reloaded from the database (.reload method) and populated with the latest update.

    • In order to update an appointment,id:must be added to the above params, as well as to the end of the URL.
    • Changing post to patch is also necessary.
  • DELETE (Destroy): Tests the ability to delete an existing appointment.

The smarter_csv gem was implemented in order to help populate the database with the csv file.

appt-api-app's People

Contributors

madelene avatar

Watchers

 avatar  avatar

appt-api-app's Issues

cleanup

the following lines, if not needed, should be removed...
https://github.com/Madelene/appt-api-app/blob/master/app/models/appointment.rb#L7-L25

If you decided not to use the API namespace when developing your API, it's better if you remove it as it's not being used...
https://github.com/Madelene/appt-api-app/blob/master/app/controllers/api/appointments_controller.rb

Spacing is off (inconsistent) in the following controller: https://github.com/Madelene/appt-api-app/blob/master/app/controllers/appointments_controller.rb

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.