-
Notifications
You must be signed in to change notification settings - Fork 0
3. APIs and Controller
Saves a puzzle the user has scanned.
Endpoint: POST /postpuzzle/
Request Parameters:
Key | Location | Type | Description |
---|---|---|---|
user_id |
Form | String | Unique identifier associating a user with their saved puzzles |
puzzle_img |
Form | text/jpeg | Image file of the puzzle the user is saving |
Response Codes:
Code | Description |
---|---|
201 Created |
Success |
202 Accepted |
Puzzle image too blurry |
400 Bad Request |
Invalid parameters |
Returns: No return values
Example:
Success
Puzzle image too blurry
Returns the saved puzzle images.
Endpoint: GET /getpuzzles/<str:user_id>/
Request Parameters:
Key | Location | Type | Description |
---|---|---|---|
user_id |
Device ID | String | Unique identifier associating a user with their saved puzzles |
Response Codes:
Code | Description |
---|---|
200 OK |
Success |
404 Not Found |
Invalid method or parameters |
Returns:
Key | Location | Type | Description |
---|---|---|---|
puzzles |
JSON | JSON object | JSON object containing the images, names, and unique identifying IDs for all puzzles saved by a particular user |
Structure of the Puzzles JSON object:
Key | Location | Type | Description |
---|---|---|---|
puzzle_id |
puzzles | Integer | Globally unique identifier for a given puzzle |
puzzle_img |
puzzles | text/jpeg | Link to the image of the puzzle in the database |
Example:
Success
The user clicks on an image of the puzzle that they'd like to delete on the front end and sends the request through a form
Endpoint: DELETE /deletepuzzle/<int:puzzle_id>/
Request Parameters:
Key | Location | Type | Description |
---|---|---|---|
puzzle_id |
url parameter | Integer | Unique id associated with the puzzle the user would like to delete |
Response Codes:
Code | Description |
---|---|
204 No Content |
Successfully deleted the puzzle image from the database |
404 Not Found |
The puzzle_id selected for deletion does not exist within the database, or the user tried an invalid method |
400 Bad Request |
Invalid parameters |
Returns: No return values
Example:
Success
Saves a puzzle piece the user has scanned and computes/stores the solution.
Endpoint: POST /postpiece/
Request Parameters:
Key | Location | Type | Description |
---|---|---|---|
puzzle_id |
Form | Integer | Globally unique identifier for a given puzzle |
piece_img |
Form | text/jpeg | Link to the image of the puzzle piece in the database |
difficulty |
Form | Integer | An integer representing the selected difficulty of the solution (0 for default, 1 for hard) |
Response Codes:
Code | Description |
---|---|
201 Created |
Success |
202 Accepted |
Piece image too blurry |
204 No Content |
Piece image too homogenous with background |
400 Bad Request |
Invalid parameters |
Returns: No return values
Example:
Success
Piece image too homogenous with background
Returns the saved piece images and their associated solutions for a given puzzle.
Endpoint: GET /getpieces/<int:puzzle_id>/
Request Parameters:
Key | Location | Type | Description |
---|---|---|---|
puzzle_id |
Form | Integer | Globally unique identifier for a given puzzle |
Response Codes:
Code | Description |
---|---|
200 OK |
Success |
404 Not Found |
Invalid parameters or method |
Returns:
Key | Location | Type | Description |
---|---|---|---|
pieces |
JSON | JSON object | JSON object containing the images, solutions, and unique identifying IDs for all puzzle pieces of a particular puzzle |
Structure of the Pieces JSON object:
Key | Location | Type | Description |
---|---|---|---|
piece_id |
pieces | Integer | Globally unique identifier for a given puzzle piece |
piece_img |
pieces | text/jpeg | Link to the image of the puzzle piece in the database |
solution_img |
pieces | text/jpeg | Link to the image of the solution associated with the puzzle piece in the database |
difficulty |
pieces | Integer | An integer representing the selected difficulty of the solution (0 for easy, 1 for hard) |
Example:
Success
The user clicks on an image of the puzzle piece that they'd like to delete on the front end, and the piece is removed from the database
Endpoint: DELETE /deletepiece/<int:piece_id>/
Request Parameters:
Key | Location | Type | Description |
---|---|---|---|
piece_id |
url parameter | Integer | Globally unique identifier for a given puzzle piece |
Response Codes:
Code | Description |
---|---|
204 No Content |
Successfully deleted the puzzle image from the database |
404 Not Found |
The puzzle_id selected for deletion does not exist within the database |
Returns: No return values
Example:
Success