-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create working CURL scripts for game storage API
- Move user auth curl scripts to `curl-scripts/user-auth` - Add directory `curl-scripts/game-storage` containing CURL scripts for all game storage API actions: `create.sh`, `index.sh`, `index-over.sh`, `index-not-over.sh`, `show.sh`, `sign-up.sh`
- Loading branch information
1 parent
355eeb6
commit dcd3ac2
Showing
10 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
curl --include --request POST "https://tic-tac-toe-wdi.herokuapp.com/games" \ | ||
--header "Content-Type: application/json" \ | ||
--header "Authorization: Token token=${TOKEN}" | ||
|
||
echo | ||
|
||
# WORKING!! | ||
|
||
# The create action expects a POST with an empty body (e.g '' or '{}' if JSON). If the request is successful, the response will have an HTTP Status of 201 Created, and the body will contain JSON of the created game with player_x set to the user calling create, e.g.: | ||
# | ||
# { | ||
# "game": { | ||
# "id": 3, | ||
# "cells": ["","","","","","","","",""], | ||
# "over": false, | ||
# "player_x": { | ||
# "id": 1, | ||
# "email": "[email protected]" | ||
# }, | ||
# "player_o": null | ||
# } | ||
# } | ||
# If the request is unsuccessful, the response will have an HTTP Status of 400 Bad Request, and the response body will be JSON describing the errors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
curl --include --request GET "https://tic-tac-toe-wdi.herokuapp.com/games?over=false" \ | ||
--header "Authorization: Token token=${TOKEN}" \ | ||
|
||
echo | ||
|
||
# WORKING!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
curl --include --request GET "https://tic-tac-toe-wdi.herokuapp.com/games?over=true" \ | ||
--header "Authorization: Token token=${TOKEN}" \ | ||
|
||
echo | ||
|
||
# WORKING!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
curl --include --request GET "https://tic-tac-toe-wdi.herokuapp.com/games" \ | ||
--header "Authorization: Token token=${TOKEN}" \ | ||
|
||
echo | ||
|
||
# WORKING! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
curl --include --request GET "https://tic-tac-toe-wdi.herokuapp.com/games/${ID}" \ | ||
--include \ | ||
--header "Content-Type: application/json" \ | ||
--header "Authorization: Token token=${TOKEN}" \ | ||
|
||
echo | ||
|
||
# WORKING !! | ||
# | ||
#The show action is a GET specifing the id of the game to retrieve. If the request is successful the status will be 200, OK, and the response body will contain JSON for the game requested, e.g.: | ||
# | ||
# { | ||
# "game": { | ||
# "id": 1, | ||
# "cells": ["o","x","o","x","o","x","o","x","o"], | ||
# "over": true, | ||
# "player_x": { | ||
# "id": 1, | ||
# "email": "[email protected]" | ||
# }, | ||
# "player_o": { | ||
# "id": 3, | ||
# "email": "[email protected]" | ||
# } | ||
# } | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
curl --include --request PATCH "https://tic-tac-toe-wdi.herokuapp.com/games/${ID}" \ | ||
--header "Authorization: Token token=${TOKEN}" \ | ||
--header "Content-Type: application/json" \ | ||
--data '{ | ||
"game": { | ||
"cell": { | ||
"index": "'${INDEX}'", | ||
"value": "'"${VALUE}"'" | ||
}, | ||
"over": "'${OVER}'" | ||
} | ||
}' | ||
|
||
echo | ||
|
||
# WORKING!! | ||
|
||
# This update action expects a PATCH with changes to to an existing game, e.g.: | ||
# | ||
# Using an HTML form element this may look like: | ||
# | ||
# <form> | ||
# <input name="game[cell][index]" type="text" value="0"> | ||
# <input name="game[cell][value]" type="text" value="x"> | ||
# <input name="game[over]" type="text" value="false"> | ||
# </form> | ||
# Alternatively, you may want to store the cell index in an HTML element that is not a form. To do this, you could utilize data attributes and add the value and over properties using javascript. | ||
# | ||
# <div data-cell-index='0'> | ||
# </div> | ||
# The update action expects data formatted as such: | ||
# | ||
# { | ||
# "game": { | ||
# "cell": { | ||
# "index": 0, | ||
# "value": "x" | ||
# }, | ||
# "over": false | ||
# } | ||
# } | ||
# If the request is successful, the response will have an HTTP Status of 200 OK, and the body will be JSON containing the modified game, e.g.: | ||
# | ||
# { | ||
# "game": { | ||
# "id": 1, | ||
# "cells": ["x","","","","","","","",""], | ||
# "over":false, | ||
# "player_x": { | ||
# "id": 1, | ||
# "email": "[email protected]" | ||
# }, | ||
# "player_o": { | ||
# "id": 3, | ||
# "email": | ||
# "[email protected]" | ||
# } | ||
# } | ||
# } | ||
# If the request is unsuccessful, the response will have an HTTP Status of 400 Bad Request, and the response body will be JSON describing the errors. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.