Skip to content

sherrimitchell/ComicGameBackend

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zero Issue Game API

  • Ruby version ruby 2.1.5p273

User

Comics

Photos

Get All Users

GET '/users'

Params:

  • none
  • Returns and array of all users

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{
  "user": [
    {
      "id": 1,
      "username": "jsmith1234",
      "access_token": "083a050c4b1556c5b8ca68612f2b5c9f",
      "email": "jsmith@tiy.com"
    },
    {
      "id": 2,
      "username": "BJohnson1234",
      "access_token": "c9d85bbde2fde34c1cab0e1995216043",
      "email": "BJohnson@tiy.com"
    },
    {
      "id": 3,
      "username": "TMcGraw1234",
      "access_token": "908ab2d13e18b6d436c2908f83fe9adf",
      "email": "TMcGraw@tiy.com"
    }
  ]
}```
Example failure:
```json
  {"errors": ["errors":["Email has already been taken"]]}

Register User

POST '/users/register'

Params:

  • username: a string
  • email: a string
  • password: a string

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{
  "user": {
    "id": 1,
    "username": "jsmith1234",
    "access_token": "083a050c4b1556c5b8ca68612f2b5c9f",
    "email": "jsmith@tiy.com"
  }
}

Example failure:

  {"errors": ["errors":["Email has already been taken"]]}

Login User

POST '/users/login'

Params:

  • username: a string
  • password: a string

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{
  "user": {
    "id": 3,
    "username": "TMcGraw1234",
    "access_token": "908ab2d13e18b6d436c2908f83fe9adf",
    "email": "TMcGraw@tiy.com"
  }
}

Example failure:

{ "message":"Invalid Login" }

Get All Comics

GET 'comics'

Params:

  • none
  • Returns array of comics from all users.

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{ "user":{"id":2,
  "username":"JDrama2000",
  "points":20 }}

Example failure:

  {"errors": ["errors":["Error"]]}

Show Comic

GET 'comic/title'

Params:

  • none
  • Returns the selected comic.

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{
  "post": [
    {
    },
    {
      "image": "www.photos.com/photos4",
      "user_id": 4,
      "answer": "answer",

      "image": "www.photo.com/photo",
      "user_id": 1,
      "answer": 1,
      "complete": false
    },
    {
      "image": "www.photo.com/photo",
      "user_id": 2,
      "answer": 1,
      "complete": false
    },
    {
      "image": "www.photo.com/photo",
      "user_id": 3,
      "answer": 1,
      "complete": false
    },
    {
      "image": "www.photo.com/photo",
      "user_id": 4,
      "answer": 1,
      "complete": false
    }
  ]
}

Example failure:

  {"errors": ["errors":["Error when loading posts"]]}

Create Comic

POST '/comics/create'

Params:

  • none
  • Returns a single post

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{ "post":{"image":"image file",
  "user_id":3,
  "answer":"correct answer",
  "complete":false,
  "answer_1":"incorrect answer",
  "answer_2":"incorrect answer",
  "answer_3":"incorrect answer"}}

Example failure:

{ "message":"Access Token Not Found" }

Get All Of User's Comics

GET 'comics/user'

Params:

  • none
  • Retrieves all of a user's commics.

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{ "post":{"id":6,
  "image":"null",
  "user_id":3,
  "answer":"correct",
  "complete":false,
  "answer_1":"incorrect",
  "answer_2":"incorrect",
  "answer_3":"incorrect"}}

Example failure:

{ "message":"Access Token Not Found" }

Create Photo

POST 'photos/create'

Params:

  • none
  • Removes validated users' post

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{"message":"Post deleted"}

Example failure:

{ "message":"ERROR" }

Get User Photos

GET 'photos/user'

Params:

  • guess: "string"

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{ "user":{"id":2,
  "guess":"A",
  "point":1,
  "user_id":3,
  "post_id":6,
  "access_token":"25a0eea82cd2fd34c34ddadc2447fb92"}}

Example failure:

{ "message":"Access Token Not Found" }

Get A User Photo

GET 'photo/:id'

Params:

  • guess: "string"

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{ "user":{"id":2,
  "guess":"A",
  "point":1,
  "user_id":3,
  "post_id":6,
  "access_token":"25a0eea82cd2fd34c34ddadc2447fb92"}}

Example failure:

{ "message":"Access Token Not Found" }

Get All Users' Photos

GET 'photos/users'

Params:

  • guess: "strings"

Response: Status Code: 201 if successful, 422 if unsuccessful

Example success:

{ "user":{"id":2,
  "guess":"A",
  "point":1,
  "user_id":3,
  "post_id":6,
  "access_token":"25a0eea82cd2fd34c34ddadc2447fb92"}}

Example failure:

{ "message":"Access Token Not Found" }

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 84.0%
  • HTML 12.5%
  • CSS 1.8%
  • JavaScript 1.7%