Coder Social home page Coder Social logo

pet-boarding-api's Introduction

Portfolio Assignment

John Hash

Pet Boarding API

CS 493: Cloud Application Development

Spring 2020

Oregon State University

Last Update: June 7, 2020. 12:00 pm Pacific

Base URL for all API endpoints https://hashj-project.wl.r.appspot.com

URL for account creation/login https://hashj-project.wl.r.appspot.com/account

Change log

Data Model

API Specification

View All Users

Create a Room

View a Single Room

View All Rooms

Update a Room Via PATCH

Update a Room Via PUT

Delete a Room

Create a Pet

View a Pet

View All Pets

Update a Pet Via PATCH

Update a Pet Via PUT

Delete a Pet

Assign a Pet to a Room

Remove a Pet From a Room

405 and 406 Status Codes: Methods and Media Types Not Allowed

Change log

Page Change Date

| | Initial version. | May 27, 2020 | | | Version submitted | June 7, 2020 |

Data Model

Entity: User

These properties cannot be set by the user. They are either automatically generated by the Google Datastore or derived from the user's Google Account.

Property Type Valid Values Description Required?
id String Arabic numerals 0-9, 16 in length Generated by Google Datastore upon creation of user. Yes
user_id String Arabic numerals 0-9, less than 23 in length Generated from the JSON Web Token 'sub' field upon creation of a new account when user is authenticated through Google OAuth 2.0 API. Yes
First String English letters, a-z or A-Z, less than 20 in length First name of user. Name is fetched from Google People API upon creation of new account when user is authenticated through Google OAuth 2.0 API. Yes
Last Number English letters, a-z or A-Z, less than 20 in length Last name of user. Name is fetched from Google People API upon creation of new account when user is authenticated through Google OAuth 2.0 API. Yes

Entity: Pet

The first three properties listed are the inherent properties to a Pet Entity. These are the properties under control when creating or updating a Pet Entity. Pet Entities can be created or updated without specifying values for these properties, but they really should be given values otherwise their value will be null.

Property Type Valid Values Description Required?
species String English letters and spaces, a-z or A-Z, less than 20 in length The kind of animal that the pet is. Not enforced, but strongly recommended
color String English letters and spaces, a-z or A-Z, less than 20 in length The color of the animal that is used for identification purposes. Not enforced, but strongly recommended
name String English letters and spaces, a-z or A-Z, less than 20 in length What the pet is called by the owner. Not enforced, but strongly recommended

The next three properties listed are automatically created when the Pet Entity is created.

Property Type Valid Values Description Required?
owner (relationship) String Arabic numerals 0-9, less than 23 in length The user_id of the pet's owner Yes
room (relationship) Object JSON object attributes-begins empty on creation-once pet is assigned to room, "id" of room and "name" of room are stored in the object Description of the room that the pet is currently in. Yes
id String Arabic numerals 0-9, 16 in length Generated by Google Datastore upon creation of user. Yes

Entity: Room

The first four properties listed are the inherent properties to a Room Entity. These are the properties under control when creating or updating a Room Entity. Room Entities can be created or updated without specifying values for these properties, but they really should be given values otherwise their value will be null.

Name Type Valid Values Description Required?
type String English letters and spaces, a-z or A-Z, less than 20 in length The kind of room. Not enforced, but strongly recommended
name String English letters and spaces, a-z or A-Z, less than 20 in length What the room is called. Not enforced, but strongly recommended
size Number Arabic numerals 0-9, up to 999 The area of the room in square feet. Not enforced, but strongly recommended
rate Number (decimal) Arabic numerals 0-9 and radix, up to 99.99 The price of the room per night Not enforced, but strongly recommended

The next two properties listed are automatically created when a Room Entity is created.

Property Type Valid Values Description Required?
id String Arabic numerals 0-9, 16 in length Generated by Google Datastore upon creation of user. Yes
occupants (relationship) Array Array populated with JSON objects-begins empty on creation-once pet is assigned to room, "id" of pet and "name" of of are stored an object in the array Description of the room that the pet is currently in. Yes

Relationship Summary

Figure 1 shows a simple ERD that summaries the relationships among the three entities.

Users can own 0 to many pets. Pets can have only one owner.

Pets can reside in 0 or only one room. A room can hold 0 to many pets.

Figure 1. ERD showing entities, their properties, and relationships.

Relationship Rules

  1. Pets are protected and can only be created, read, updated, or deleted by their authenticated owner.

  2. Rooms are unprotected. They can be created, read, updated, or deleted by non-authenticated users.

  3. Rooms can only be deleted if no pets are in them.

  4. Pets can only reside in rooms with pets of the same owner, and the number of pets placed in the same room is not limited.

  5. Relationship properties cannot be changed through PATCH and PUT update operations on room in order to protect the pet relationships.

API Specification

Details for all the valid endpoints for the Pet Boarding API are listed below.

View All Users

List all the current user accounts.

GET /users

Request

Request Parameters

None

Request Body

None

Request Header : Accept

"Accept" header value must be 'application/json'

Response

Response Body Format

JSON

Response Statuses

Outcome Status Code Notes
Success 200 OK

|

Response Examples

  • An attribute for self is automatically created in the response for each registered user.

Success

| Status: 200 OK

[{"user_id": "114614630321977629406","First": "Christa","Last": "Hash","id": "5117579211309056","self": "https://localhost:8080/5117579211309056"},{"user_id": "114791681322698322383","First": "John M","Last": "Hash","id": "5631671361601536","self": "https://localhost:8080/5631671361601536"}]

Create a Room

Allows for creation of a new room entity.

POST /rooms

Request

Request Parameters

None

Request Body

Required

Authorization

None

Request Header : Accept

"Accept" header value must be 'application/json'

Request Body Format

JSON

Request JSON Attributes

Name Type Description Required?
type String The kind of room. Yes
name String What the room is called. Yes
size Number The area of the room in square feet. Yes
rate Number The price of the room per night. Yes

Request Body Example

{"type": "Standard Suite","name": "Bay View","size": 48, "rate": 39.99}

Response

Response Body Format

Success: 'application/json'

Response Statuses

Outcome Status Code Notes
Success 201 Created

|

Response Examples

  • Datastore will automatically generate an ID and store it with the room being created.
  • The self attribute will contain the live link to the REST resource corresponding to this room. The self attribute is not stored in Datastore but is generated for the response only.
  • A newly created room entity will contain a occupants attribute with a single empty array.

Success

| Status: 201 Created

{"id": "abc123","name": "Bay View","type": "Standard Suite", "rate": 39.99,"size": 48,"occupants":[],"self": "https://base-url/rooms/abc123"}

View a Single Room

Allows for retrieving a record for a single existing room.

GET /rooms/:room_id

Request

Request Parameters

Name Type Description Required?
room_id String ID of the room Yes

Request Body

None

Request Header : Accept

"Accept" header value must be 'application/json'

Response

Response Body Format

Success: JSON

Failure: JSON

Response Statuses

Outcome Status Code Notes
Success 200 OK

| | Failure | 404 Not Found | No room with this room_id exists |

Response Examples

  • An attribute for self is automatically created in the response for both the boat and each of the loads currently assigned to the room.

Success

| Status: 200 OKExample of a room returned with no occupants yet assigned{"id": "abc123","name": "Bay View","type": "Standard Suite", "rate": 39.99,"size": 48,"occupants":[],"self": "https://base-url/rooms/abc123"}Example of a room returned with two occupants currently assigned{"id": "abc123","name": "Bay View","type": "Standard Suite", "rate": 39.99,"size": 48,"occupants":[{"id": "5701666712059904","self": "http://localhost:8080/loads/5701666712059904"},{"id": "6278060542263296","self": "http://localhost:8080/loads/6278060542263296"}], "self": "https://base-url/rooms/abc123"} | | --- |

Failure

| Status: 404 Not Found

{ "Error": "No room with this room_id exists" }

View All Rooms

List all the rooms currently in the datastore and their attributes.

GET /rooms

Request

Request Parameters

None

Request Body

None

Request Header : Accept

"Accept" header value must be 'application/json'

Response

Response Body Format

JSON

Response Statuses

Outcome Status Code Notes
Success 200 OK

|

Response Examples

  • An attribute for self is automatically created in the response for both the room and each of the occupants currently assigned to the room.
  • The results for rooms are paginated with a limit of 5 records per page. A next attribute is generated with a link to the next set of rooms results in sequential order.
  • Attribute total rooms lists the total number of rooms in the collection
  • A GET request with the next link provided returns the next set of room results.

Success

| Status: 200 OK

{"rooms": [{"name": "Harbor View","rate": 25.5,"size": 49,"type": "Standard Suite","occupants": [],"id": "5079418695319552","self": "https://localhost:8080/rooms/5079418695319552"},{"name": "Peaceful Meadows","rate": 49.99,"size": 75,"type": "Luxury Suite","occupants": [],"id": "5636645067948032","self": "https://localhost:8080/rooms/5636645067948032"},{"size": 88,"type": "Presidential Suite","occupants": [],"name": "Grand View","rate": 79.99,"id": "5646488461901824","self": "https://localhost:8080/rooms/5646488461901824"},{"size": 48,"type": "Standard Suite","occupants": [],"name": "Bay View","rate": 29.99,"id": "5706627130851328","self": "https://localhost:8080/rooms/5706627130851328"},{"occupants": [],"name": "Hallway View","rate": 19.99,"size": 20,"type": "Simple Suite","id": "5714489739575296","self": "https://localhost:8080/rooms/5714489739575296"}],"next": https://localhost:8080/rooms?cursor=CioSJGoPbX5oYXNoai1wcm9qZWN0chELEgRSb29tGICAgJjFqZMKDBgAIAA=, "total_rooms": 7}

Update a Room Via PATCH

Allows for updating a room's attributes with the HTTP Verb 'PATCH'

All JSON attributes of the room entity remain the same unless specifically specified in request body.

Caution: This route is not intended for managing pet-room assignments. Pet-room relationships can only be managed through: DELETE /room/:room_id/pets/:pet_id or PUT /room/:room_id/pets/:pet_id Only attributes inherit to the room entity will be affected.

PATCH /rooms/:room_id

Request

Request Parameters

Name Type Description Required?
room_id String ID of the room Yes

Request Body

Required

Request JSON Attributes

Name Type Description Required?
type String The kind of room. Optional
name String What the room is called. Optional
size Number The area of the room in square feet. Optional
rate Number The price of the room per night Optional

Response

Response Body Format

Success: none

Failure: JSON

Response Header

Location header has live URL to the updated resource.

Response Statuses

Outcome Status Code Notes
Success 204 No Content Returns a 204 status code and URL to resource in the Location header.
Failure 404 Not Found No room with this room_id exists. If room_id isn't found, 404 is returned.

Response Examples

Failure

| Status: 404 Not Found

{ "Error": "No room with this room_id exists" }

Update a Room Via PUT

Allows for updating a room's attributes with the HTTP Verb 'PUT'

All JSON attributes of the room will reflect those provided in JSON request body. Failing to provide values for attributes will be overwritten with 'null'. It is recommended that all attributes are provided.

Caution: This route not intended for managing pet-room assignments. Pet-room assignments can only be managed through: DELETE /room/:room_id/pets/:pet_id or PUT /room/:room_id/pets/:pet_id Only attributes inherit to the room entity will be affected.

PUT /rooms/:room_id

Request

Request Parameters

Name Type Description Required?
room_id String ID of the room Yes

Request Body

Required

Request JSON Attributes

Name Type Description Required?
type String The kind of room. Optional
name String What the room is called. Optional
size Number The area of the room in square feet. Optional
rate Number The price of the room per night Optional

Response

No body

Response Body Format

Success: No body

Failure: JSON

Response Statuses

Outcome Status Code Notes
Success 204 No Content Returns a 204 status code and URL to resource in the Location header.
Failure 404 Not Found No room with this room_id exists. If room_id isn't found, 404 is returned.

Response Examples

Success

Status: 204 No Content

Failure

| Status: 404 Not Found

{ "Error": "No room with this room_id exists" }

Delete a Room

Allows for removing a room. Note that if the room currently has any occupants, the room cannot be deleted until all occupants are removed.

Note: To remove an an occupant, use: DELETE /room/:room_id/pets/:pet_id

DELETE /rooms/:room_id

Request

Request Parameters

Name Type Description Required?
room_id String ID of the room Yes

Request Body

None

Response

No body

Response Body Format

Success: No body

Failure: JSON

Response Statuses

Outcome Status Code Notes
Success 204 No Content

| | Failure | 404 Not Found | No room with this room_id was found in the datastore | | Failure | 403 Forbidden | 403 is returned if the room has occupants, and therefore, cannot be deleted at this time. |

Response Examples

  • Removal of the room from the datastore is allowed only if the room is empty

Success

Status: 204 No Content

Failure

| Status: 404 Not Found

{ "Error": "No room with this room_id exists" }

Failure

| Status: 403 Forbidden

{ "Error": "Occupants of room must be removed before room can be deleted." }

Create a Pet

Allows for creation of a new pet that is initially unassigned to a room.

POST /pets

Request

Request Parameters

None

Request Body

Required

Request Header: Authorization

"Authorization" header required. Type "Bearer". Token format: JSON Web Token (JWT).

Request Header : Accept

"Accept" header value must be 'application/json'

Request Body Format

JSON

Request JSON Attributes

Name Type Description Required?
species String The kind of animal. Yes
color String The color of the animal (e.g. "black and white" or "brown") Yes
name String What the pet is called by the owner. Yes

Request Body Example

{"species": "Canine","color": "Red","name": "Cooper"}

Response

Response Body Format

Success: 'application/json'

Failure: 'application/json'

Response Statuses

Outcome Status Code Notes
Success 201 Created

| | Failure | 401 Unauthorized | If the JSON Web Token (JWT) is not valid, the user cannot create a pet record.The user must return to:https://hashj-project.wl.r.appspot.com/accountto get a valid JWT by either creating an account or re-signing in. |

Response Examples

  • Datastore will automatically generate an ID and store it with the entity being created. This value is sent in the response body as shown in the example. The room attribute is generated automatically and added the entity.
  • The value of the attribute room begins as an empty object because the pet is not in a room initially. Later, room will be updated to hold identifying information about the room that the pet currently resides in.
  • The value of the attribute self is a live link to the REST resource corresponding to this pet. In other words, this is the URL to get this newly created pet. This link is generated for the response and not stored in the datastore.

Success

| Status: 201 Created

{ "species": "Canine", "color": "Red", "name": "Cooper", "room": {}, "owner": "114791681322698322383", "id": "5755374237908992", "self": "https://localhost:8080/pets/5755374237908992"}

Failure

| Status: 401 Unauthorized

{ "Error": "Invalid token signature"}

View a Pet

Allows for viewing information on an existing pet that is owned by the user.

GET /pets/:pet_id

Request

Request Parameters

Name Type Description Required?
pet_id String ID of the pet Yes

Request Body

None

Request Header : Authorization

"Authorization" header required. Type "Bearer". Token format: JSON Web Token (JWT).

Request Header : Accept

"Accept" header value must be 'application/json'

Response

Response Body Format

Success: 'application/json'

Failure: 'application/json'

Response Statuses

Outcome Status Code Notes
Success 200 OK Returns request pet information
Failure 404 Not Found No pet with this pet_id exists
Failure 404 Not Found No pets exist in data store
Failure 403 Forbidden User has been authenticated, but the pet with the pet_id in the request doesn't belong to the user making the request.
Failure 401 Unauthorized The JSON Web Token provided in the Authorization header of the request is invalid. User wasn't recognized by server.

Response Examples

  • If the pet is currently in a room, the name, id, and self URL for the room will appear in the room attribute in the response.

Success

| Status: 200 OK

{ "id": "4693933435125760", "species": "Box turtle", "color": "Brown", "name": "Boxer", "room": { "name": "Bay View", "id": "6485250678980608", "self": "https://localhost:8080/rooms/6485250678980608" }, "owner": "114791681322698322383", "self": "https://localhost:8080/pets/4693933435125760"}

Failure

| Status: 404 Not Found

{ "Error": "No pet with this pet_id exists." }

Failure

| Status: 404 Not Found

{ "Error": "No pets in datastore." }

Failure

| Status: 403 Forbidden

{ "Error": "No authorization to access this pet!" }

Failure

| Status: 401 Unauthorized

{ "Error": "Invalid token signature." }

View All Pets

List all the current pets whether they are in a room or not.

GET /pets

Request

Request Parameters

None

Request Body

None

Authorization

"Authorization" header required. Type "Bearer". Token format: JSON Web Token (JWT).

Request Header : Accept

"Accept" header value must be 'application/json'

Response

Response Body Format

JSON

Response Statuses

Outcome Status Code Notes
Success 200 OK

|

Response Examples

  • An attribute for self is automatically created in the response for both the pets and room they are assigned to if applicable.
  • The results for pets are paginated with a limit of 5 records per page. A next attribute is generated with a link to the next set of pets results in sequential order.
  • Attribute total_pets lists the total number of pets in the collection
  • A GET request with the next link provided returns the next set of pets results.

Success

| Status: 200 OK

{"pets": [{"name": "Rex","species": "Canine","color": "Black and tan","owner": "114791681322698322383","room": {},"id": "4887575659544576","self": "https://localhost:8080/pets/4887575659544576"},{"owner": "114791681322698322383","room": {},"name": "Dani","species": "Canine","color": "Black and tan","id": "5104074961715200","self": "https://localhost:8080/pets/5104074961715200"},{"owner": "114791681322698322383","room": {},"name": "Polly","species": "Parrot","color": "Gray","id": "5685335367352320","self": "https://localhost:8080/pets/5685335367352320"},{"name": "Tigger","species": "Feline","color": "Striped","owner": "114791681322698322383","room": {},"id": "5704642587525120","self": "https://localhost:8080/pets/5704642587525120"},{"name": "Boxer","species": "Box turtle","color": "Brown","owner": "114791681322698322383","room": {},"id": "5740073718906880","self": "https://localhost:8080/pets/5740073718906880"}],"next": "https://localhost:8080/pets?cursor=CikSI2oPbX5oYXNoai1wcm9qZWN0chALEgNQZXQYgICA%2BJCSmQoMGAAgAA%3D%3D","total\_pets": 7}

Update a Pet Via PATCH

Allows for updating a pet's attributes with the HTTP Verb 'PATCH'

All JSON stored attributes of the pet entity remain the same unless specifically specified in request body.

Disclaimer: This route not intended for managing pet-room assignments. Pet-room assignments can only be managed through: DELETE /room/:room_id/pets/:pet_id or PUT /room/:room_id/pets/:pet_id Only attributes inherit to the pet entity will be affected.

PATCH /pets/:pet_id

Request

Request Parameters

Name Type Description Required?
pet_id String ID of the pet Yes

Authorization

"Authorization" header required. Type "Bearer". Token format: JSON Web Token (JWT).

Request Body Format

JSON

Request JSON Attributes

Name Type Description Required?
species String The kind of animal. Optional
color String The color of the animal (e.g. "black and white" or "brown") Optional
name String What the pet is called by the owner. Optional

Response

No body

Location response header has live URL to the the updated resource

Response Body Format

Success: No body

Failure: JSON

Response Statuses

Outcome Status Code Notes
Success 204 No Content Location header has URL to the resource
Failure 404 Not Found No pet with this pet_id exists for the user. Rather than having a 403 for the user if they are forbidden from accessing the pet, the 404 leaves it ambiguous as to whether they have stumbled upon another user's pet's id. This is used in other API's such as GitHub to further protect privacy.
Failure 401 Unauthorized The JSON Web Token provided in the Authorization header of the request is invalid. User wasn't recognized by server.

Response Examples

Success

Status: 204 No Content

Failure

| Status: 404 Not Found

{ "Error": "User owns no pet with this pet_id" }
Status: 401 Unauthorized
{ "Error": "Invalid token signature" }

Update a Pet Via PUT

Allows for updating a pet's attributes with the HTTP Verb 'PUT'

All JSON attributes of the pet will reflect those provided in JSON request body. Failing to provide values for attributes will be overwritten with 'null'.

Disclaimer: This route not intended for managing pet-room assignments. Pet-room assignments can only be managed through: DELETE /room/:room_id/pets/:pet_id or PUT /room/:room_id/pets/:pet_id Only attributes inherit to the pet entity will be affected.

PUT /pets/:pet_id

Request

Request Parameters

Name Type Description Required?
pet_id String ID of the pet Yes

Authorization

"Authorization" header required. Type "Bearer". Token format: JSON Web Token (JWT).

Request Body Format

JSON

Request JSON Attributes

Name Type Description Required?
species String The kind of animal. Optional
color String The color of the animal (eg "black and white" or "brown") Optional
name String What the pet is called by the owner. Optional

Response

No body

Location response header has live URL to the the updated resource

Response Body Format

Success: No body

Failure: JSON

Response Statuses

Outcome Status Code Notes
Success 204 No Content Location header has URL to the resource
Failure 404 Not Found No pet with this pet_id exists for the user. Rather than having a 403 for the user if they are forbidden from accessing the pet, the 404 leaves it ambiguous as to whether they have stumbled upon another user's pet's id. This is used in other API's such as GitHub to further protect privacy.
Failure 401 Unauthorized The JSON Web Token provided in the Authorization header of the request is invalid. User wasn't recognized by server.

Response Examples

Success

Status: 204 No Content

Failure

| Status: 404 Not Found

{ "Error": "User owns no pet with this pet_id" }
Status: 401 Unauthorized
{ "Error": "Invalid token signature" }

Delete a Pet

Allows for deleting a pet from the system. If the pet is currently in a room, the pet will be removed from that room.

DELETE /pets/:pet_id

Request

Request Parameters

Name Type Description Required?
pet_id String ID of the pet Yes

Request Body

None

Authorization

"Authorization" header required. Type "Bearer". Token format: JSON Web Token (JWT).

Response

No body

Response Body Format

Success: No body

Failure: JSON

Response Statuses

Outcome Status Code Notes
Success 204 No Content

| | Failure | 404 Not Found | If the pet is not found in the set of pets that the user owns or if the user tries delete a pet that they do not own, then the 404 error is produced. It is possible that a 403 could have been used for the later case, but the 404 seems appropriate because it is also a way to protect the privacy of the other user in not allowing the other users to know the id of pets that they do not own. It is also borderline an appropriate case because the combination of the user's id and pet id do not exist. |

Response Examples

  • Removal of the pet from the datastore also updates the occupants attribute for the room that the pet was assigned to by removing pet's id from the array of occupants.

Success

Status: 204 No Content

Failure

| Status: 404 Not Found

{ "Error": "No pet with this pet id exists for current user." }

Assign a Pet to a Room

An empty room or a room that has a pet in it that is owned by the user can have a new pet assigned to it.

PUT /rooms/:room_id/pets/:pet_id

Request

Request Parameters

Name Type Description Required?
room_id String ID of the room Yes
pet_id String ID of the pet Yes

Request Body

None

Note: Set Content-Length to 0 in your request when calling out to this endpoint.

Response

No body

Authorization

Authorization" header required. Type "Bearer". Token format: JSON Web Token (JWT).

Response Body Format

Success: No body

Failure: JSON

Response Statuses

Outcome Status Code Notes
Success 204 No Content Succeeds only if a room exists with this room_id, a pet with the specified pet_id exists, and the pet with that pet_id is not already assigned to another room.
Failure 403 Forbidden This pet is already assigned to another room.
Failure 403 Forbidden User does not have authorization to assign pet to room.
Failure 403 Forbidden Another owner already has pets in that room. Pets from two different owners cannot be in the same room.
Failure 404 Not Found No room with this room_id exists, and/or no pet with this pet_id exits.
Failure 401 Unauthorized The user was not authenticated and not recognized by the server.

Response Examples

Success

Status: 204 No Content

Failure

| Status: 403 Forbidden

{ "Error": "The pet with this pet_id is already assigned to another room." }
Status: 403 Forbidden
{ "Error": "You lack authorization for this request." }

| | Status: 403 Forbidden { "Error": "This room is in use by another pet owner. Pick another room number." } |

Failure

| Status: 404 Not Found

{ "Error": "The specified room and/or pet don't exist" }

Failure

| Status: 401 Unauthorized

{ "Error": "Invalid token signature." }

Notes: A pet can only be assigned to one room, but a room can hold an unlimited number of pets. Pets can only be in rooms with other pets that have the same owner.

Remove a Pet From a Room

A room that has a pet in it can be removed from the room by the pet's owner.

DELETE /rooms/:room_id/pets/:pet_id

Request

Request Parameters

Name Type Description Required?
room_id String ID of the room Yes
pet_id String ID of the pet Yes

Request Body

None

Note: Set Content-Length to 0 in your request when calling out to this endpoint.

Response

No body

Authorization

Authorization" header required. Type "Bearer". Token format: JSON Web Token (JWT).

Response Body Format

Success: No body

Failure: JSON

Response Statuses

Outcome Status Code Notes
Success 204 No Content Succeeds only if a room exists with this room_id and the specified pet owned by the user is in that room.
Failure 404 Not Found No room with that room id exists.
Failure 404 Not Found No pet with that pet_id exists under the current user's ownership. Again, a 404 here protects the pet_id leaving it ambiguous as to whether a pet with that id exists. The actual owner would know it does. A 403 would let a non-owner know a pet's id number and what room it is in.
Failure 401 Unauthorized The user was not authenticated and not recognized by the server.

Response Examples

Success

Status: 204 No Content

Failure

| Status: 404 Not Found

{ "Error": "The specified room does not exist." }
Status: 404 Not Found
{ "Error": "The specified pet is not in that room." }

Failure

| Status: 401 Unauthorized

{ "Error": "Invalid token signature." }

405 and 406 Status Codes: Methods and Media Types Not Allowed

405 (Method Not Allowed)

The following endpoints are not allowed and will return a 405 status code:

DELETE /rooms

PUT /rooms

PATCH /rooms

DELETE /pets

PUT/pets

PATCH /pets

Response Example

| Status: 405 Method Not Allowed

{ "Error": "Method not allowed." }

406 (Not Acceptable)

Endpoints that return full response bodies and either a 200 status code or a 201 status code require that the content is returned in 'application/json' format. The 'accept' header in the request must specify that 'application/json' is accepted.

The following endpoints will return a 406 status code if 'accept' header is properly set:

POST /rooms

GET /rooms

GET /rooms/:room_id

POST /pets

GET /pets

GET /pets/:pet_id

GET /users

Response Example

| Status: 406 Not Acceptable

{ "Error": "Only application/json is acceptable." }

pet-boarding-api's People

Contributors

phoridfly avatar

Stargazers

 avatar

Watchers

 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.