Skip to content

Edyta-Budny/Notify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API request, response and urls description

View Create Message

HTTP method: POST

Url: https://daftcodenotify.herokuapp.com/message

Authorizations: required HTTPBasic

Parameters: none

Request body schema example: application/json:

{
    "content": "hello"
}

Responses samples:

Status symbol: 201

Status description: successful response

Content type: application/json

Response body:

{
    "msg": "You have created a message hello"
}

Status symbol: 422

Status description: validation error

Content type: application/json

The response body for a message with character length zero:

{
  "detail": [
    {
      "loc": [
        "body",
        "content"
      ],
      "msg": "ensure this value has at least 1 characters",
      "type": "value_error.any_str.min_length",
      "ctx": {
        "limit_value": 1
      }
    }
  ]
}

The response content for messages with a character length longer than 160:

{
  "detail": [
    {
      "loc": [
        "body",
        "content"
      ],
      "msg": "ensure this value has at most 160 characters",
      "type": "value_error.any_str.max_length",
      "ctx": {
        "limit_value": 160
      }
    }
  ]
}

View Show Message

HTTP method: GET

Url: https://daftcodenotify.herokuapp.com/message/{message_id}

Authorizations: not required

Path parameters: message_id, type: integer, required

Responses samples:

Status symbol: 200

Status description: successful response

Content type: application/json

Example Value:

{
  "content": "hello",
  "view_counter": 1
}

Status symbol: 404

Status description: error: not found

Content type: application/json

{
  "detail": "Message not found"
}

View Update Message

HTTP method: PATCH

Url: https://daftcodenotify.herokuapp.com/message/{message_id}

Authorizations: required HTTPBasic

Path parameters: message_id, type: integer, required

Request body schema example: application/json:

{
  "content": "hello again"
}

Responses samples:

Status symbol: 201

Status description: successful response

Content type: application/json

Example Value:

{
  "content": "hello again",
  "view_counter": 0
}

Status symbol: 404

Status description: error: not found

Content type: application/json

{
  "detail": "Message not found"
}

View Delete Message

HTTP method: DELETE

Url: https://daftcodenotify.herokuapp.com/message/{message_id}

Authorizations: required HTTPBasic

Path parameters: message_id, type: integer, required

Request body schema example: application/json:

Responses samples:

Status symbol: 201

Status description: successful response

Content type: application/json

Example Value:

{
  "msg": "Message id 1 has been deleted."
}

Status symbol: 404

Status description: error: not found

Content type: application/json

{
  "detail": "Message not found"
}

Check the urls in the terminal using the following commands

curl --request POST -u user:access --data '{"content": "hello"}' https://daftcodenotify.herokuapp.com/message
curl --request GET https://daftcodenotify.herokuapp.com/message/1
curl --request PATCH -u user:access --data '{"content": "hello again"}' https://daftcodenotify.herokuapp.com/message/1
curl --request DELETE -u user:access https://daftcodenotify.herokuapp.com/message/1

About

Recruitment task for Daftcode

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages