Skip to content

abdulredd/pets_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pets Api

This is an api that is used in Backend Mod 3 exercise for students to explore api tools including Postman and Faraday.

Versions

Rails 5.2.8.1

Ruby 2.7.4

Exercises

  1. Using Postman, try to get a successful response from each endpoint.

    • If you haven't installed Postman you can do so here
  2. Using Faraday, try to get a successful response from each endpoint.

    • Install the Faraday gem
    • Create a ruby file and require the Faraday library along with a debugger, such as pry
    • In this newly created Ruby file write requests for each endpoint, use your debugger to check the response body

Extra Challenge: Explore how to parse a JSON response here

Endpoints

Request GET https://turing-pets-api.herokuapp.com/api/v1/pets

Example Response

[
  {
    "id": 1,
    "name": "Wile E.",
    "animal_type": "coyote",
    "age": 4,
    "created_at": "2020-05-05T14:41:55.013Z",
    "updated_at": "2020-05-05T14:41:55.013Z"
  },
  {
    "id": 2,
    "name": "Road Runner",
    "animal_type": "bird",
    "age": 1,
    "created_at": "2020-05-05T14:41:55.021Z",
    "updated_at": "2020-05-05T14:41:55.021Z"
  },
  {
    "id": 3,
    "name": "Tweety",
    "animal_type": "bird",
    "age": 15,
    "created_at": "2020-05-05T14:41:55.028Z",
    "updated_at": "2020-05-05T14:41:55.028Z"
  },
  {
    "id": 4,
    "name": "Sylvester",
    "animal_type": "cat",
    "age": 2,
    "created_at": "2020-05-05T14:41:55.037Z",
    "updated_at": "2020-05-05T14:41:55.037Z"
  }
]

Request GET https://turing-pets-api.herokuapp.com/api/v1/pets/:id

Example Response

{
  "id": 1,
  "name": "Wile E.",
  "animal_type": "coyote",
  "age": 4,
  "created_at": "2020-05-05T14:41:55.013Z",
  "updated_at": "2020-05-05T14:41:55.013Z"
}

Request POST https://turing-pets-api.herokuapp.com/api/v1/pets

Request Example with required body

  POST https://turing-pets-api.herokuapp.com/pets
  body: {
          "name": "Bugs",
          "animal_type": "bunny",
          "age": 5
        }

Example Response

{
  "id": 5,
  "name": "Bugs",
  "animal_type": "bunny",
  "age": 5,
  "created_at": "2020-05-05T14:41:55.013Z",
  "updated_at": "2020-05-05T14:41:55.013Z"
}

Request DELETE https://turing-pets-api.herokuapp.com/api/v1/pets/:id

Example Response 204 No Content

Request PATCH https://turing-pets-api.herokuapp.com/api/v1/pets/:id

Example Request with body

PATCH https://turing-pets-api.herokuapp.com/pets/3
body: {
        "age": 10
      }

Example Response

  {
    "id": 3,
    "name": "Tweety",
    "animal_type": "bird",
    "age": 10,
    "created_at": "2020-05-05T14:41:55.028Z",
    "updated_at": "2020-05-05T17:43:10.736Z"
  }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published