Table of Contents
June 27, 2023 update
- Gameplay Controller
- Endgame Controller
- ErrorHandling Serializer
- Deployment to www.correctorcrass.com
- Integration of CI/CD pipeline
Our mission is to create a complete and tested back end application that can be consumed by front end developers to create an functional Trivia Game.
Trivia API exposes endpoints that provide information for a front-end application to build a sassy trivia game! The end user will have to match a word (from a list) to a photo for five rounds.
So easy, right!?!
"BUT"... the user better score well because at the end of the fifth round we evaluate the user's performance and provide a triumphant message celebrating a winning record or a disparaging phrase that playfully "kicks 'em while they're down", along with a gif to emphatically drive home our thoughts!
We provide all this lighthearted content! All the front-end has to do is plug and let their users play.
- Ruby 3.2.2
- Rails 7.0.4
Deploy locally:
-
Clone the repo
git clone git@github.com:Correct-or-Crass/Trivia_API.git
-
Install gems
bundle install
-
Setup db
rails db:{drop,create,migrate}
-
Run RSpec tests
bundle exec rspec spec
This application relies on the following APIs:
This application creates the following API endpoints:
🗂️ Root Directory: www.correctorcrass.com
🔠 Words
- Returns a correct answer, 4 words (1 of which is the correct answer) and a photo related to the correct answer
- Photo contains the image's url, the image owner's name and account link to enable front end to credit image owner if desired
Successful response:
{
"data": {
"type": "game_play",
"attributes": {
"photo": {
"image_url": "https://images.unsplash.com/photo-1593132517397-ceb31d77194a?ixid=M3w0MTg4MjB8MHwxfHNlYXJjaHw2fHxDYXRjaHxlbnwwfHx8fDE2ODc0NzI2NzN8MA&ixlib=rb-4.0.3&utm_source=Trivia_API&utm_medium=referral&utm_campaign=api-credit",
"creator_name": "mmcgregor",
"creator_link": "https://api.unsplash.com/photos/Ns8trMR4Om8?utm_source=Trivia_API&utm_medium=referral&utm_campaign=api-credit"
},
"answer": "Catch",
"choices": [
"Staircase",
"Wood",
"Fist",
"Catch"
]
}
}
}
- An integer param can be provided to return more or less than the default 4 word choices
Successful response:
{
"data": {
"type": "game_play",
"attributes": {
"photo": {
"image_url": "https://images.unsplash.com/photo-1593132517397-ceb31d77194a?ixid=M3w0MTg4MjB8MHwxfHNlYXJjaHw2fHxDYXRjaHxlbnwwfHx8fDE2ODc0NzI2NzN8MA&ixlib=rb-4.0.3&utm_source=Trivia_API&utm_medium=referral&utm_campaign=api-credit",
"creator_name": "mmcgregor",
"creator_link": "https://api.unsplash.com/photos/Ns8trMR4Om8?utm_source=Trivia_API&utm_medium=referral&utm_campaign=api-credit"
},
"answer": "Catch",
"choices": [
"Staircase",
"Wood",
"Fist",
"Catch",
"Motorbike"
]
}
}
}
🏁 Endgame
- A request should include the number of wins and rounds, otherwise a default of wins = 0, rounds = 5 is provided
- It is recommended that wins are passed with the request and number of rounds adjusted if necessary
- A winning endgame requires a 60% or higher correct score ratio
Endpoints Examples
:
Successful response:
{
"data": {
type: "endgame",
attributes: {
phrase: "I bet you make babies smile.",
gif: {
url: "https://giphy.com/gifs/sensual-UElLGSOqm8XYI",
title:"making love GIF",
rating: "r"
}
}
}