Giter Site home page Giter Site logo

students_and_cohorts_api's Introduction

Students and Cohorts API - An Intro To Building APIs Challenge

This repository is to be used for practicing building an API.

Set Up

  1. git clone <paste SSH key> this repo (you do not need to fork becuase we will not be giving feedback on this challenge)
  2. cd students_and_cohorts_api
  3. bundle install
  4. rails db:{create,migrate,seed}

If you open up your rails console (rails c), you should see that you have 4 cohorts (Cohort.count) and 78 students (Student.count). When you run your test suite, you should have 12 passing tests.

Schema

The database has already been designed for you. You should not change it.

Schema Design

The Challenge

You are creating two endpoints that will expose data about students and cohorts. We recommend serializing your json data by hand (creating your own methods in the serializer to format your response), and then refactoring to use the jsonapi-serializer gem if you have more time.

ENDPOINT 1

GET all students

Your endpoint should follow this format:
GET /api/v1/students

Your API will return:

  • first name
  • last name
  • preferred name
  • pronouns
  • email
  • github username
  • slack username

Expand the endpoints below to see the expected response:

GET /api/v1/students
{
    "data": [
        {
            "id": "1",
            "type": "student",
            "attributes": {
                "first_name": "Jessie",
                "last_name": "Smith",
                "preferred_name": "Jess",
                "pronouns": "xe/xem",
                "email": "[email protected]",
                "github_username": "Jessie_github",
                "slack_username": "Jessie_slack"
            }
        },
        {
            "id": "2",
            "type": "student",
            "attributes": {
                "first_name": "Marion",
                "last_name": "Johnson",
                "preferred_name": "Marion",
                "pronouns": "she/they",
                "email": "[email protected]",
                "github_username": "Marion_github",
                "slack_username": "Marion_slack"
            }
        },
        {
            "id": "3",
            "type": "student",
            "attributes": {
                "first_name": "Alva",
                "last_name": "Brown",
                "preferred_name": "Alva",
                "pronouns": "ze/zir",
                "email": "[email protected]",
                "github_username": "Alva_github",
                "slack_username": "Alva_slack"
            }
        },
        {
            "id": "4",
            "type": "student",
            "attributes": {
                "first_name": "Ollie",
                "last_name": "Jones",
                "preferred_name": "Ollie",
                "pronouns": "he/they",
                "email": "[email protected]",
                "github_username": "Ollie_github",
                "slack_username": "Ollie_slack"
            }
        },
        ...
        ...
        ...
    ]
  }

ENDPOINT 2

GET one cohort

Your endpoint should follow this format:
GET /api/v1/cohorts/:id

Your API will return:

  • name
  • start date
  • graduation date
  • number_of_students
  • status (future, current, graduated) - this should be based off of the start/graduation dates compared to the current date that the request is being made

Expand the endpoints below to see the expected response:

GET /api/v1/cohorts/1
{
  "data": {
      "id": "1",
      "type": "cohort",
      "attributes": {
          "name": "2107 BE",
          "start_date": "2021-07-01",
          "graduation_date": "2022-02-01",
          "number_of_students": 17,
          "status": "current"
        }
   }
}
GET /api/v1/cohorts/2
 {
    "data": {
        "id": "2",
        "type": "cohort",
        "attributes": {
            "name": "2103 FE",
            "start_date": "2021-03-01",
            "graduation_date": "2021-10-01",
            "number_of_students": 26,
            "status": "graduated"
        }
      }
  }

Versions

  • Rails 5.2.6
  • Ruby 2.7.2

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.