{"openapi":"3.0.1","info":{"title":"9Darts API","description":"API for 9Darts Application","version":"1.0.0"},"servers":[{"url":"https://6nc0krnqw0.execute-api.eu-central-1.amazonaws.com/Dev","description":"Development Server"}],"paths":{"/game":{"post":{"summary":"Create a new game","description":"This endpoint saves game data for a user in the database, including the created_at timestamp.","operationId":"createGame","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["user_id","mode","average","rounds"],"properties":{"user_id":{"type":"integer","example":123,"description":"The ID of the user who played the game."},"mode":{"type":"string","enum":[301,501,701,901,"cricket"],"example":301,"description":"The mode of the game."},"average":{"type":"number","format":"float","example":50.5,"description":"The average score per round."},"rounds":{"type":"integer","example":10,"description":"The number of rounds played."},"points":{"type":"integer","example":301,"description":"The total points scored in the game (optional)."},"double_out_percentage":{"type":"integer","example":80,"description":"The percentage of successful double/master outs (optional)."},"game_time":{"type":"string","format":"time","example":"00:20:00","description":"The total time taken for the game (optional)."}}}}}},"responses":{"201":{"description":"Game data saved successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"Game data saved successfully"},"game_id":{"type":"integer","example":1},"created_at":{"type":"string","format":"date-time","example":"2025-01-25T12:34:56Z"}}}}}},"400":{"description":"Bad request due to missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Missing required fields"}}}}}},"500":{"description":"Internal server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Database error"},"details":{"type":"string","example":"Detailed error message"}}}}}}}},"get":{"summary":"Retrieve games for a user","description":"This endpoint retrieves games for a specific user, optionally filtered by date range and limited to a specific number of results.","operationId":"getGames","parameters":[{"name":"user_id","in":"query","required":true,"schema":{"type":"integer","example":123},"description":"The ID of the user whose games should be retrieved."},{"name":"from","in":"query","required":false,"schema":{"type":"string","format":"date-time","example":"2025-01-01T00:00:00Z"},"description":"The start date and time for filtering games."},{"name":"to","in":"query","required":false,"schema":{"type":"string","format":"date-time","example":"2025-01-15T23:59:59Z"},"description":"The end date and time for filtering games."},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","example":10},"description":"The maximum number of games to return."}],"responses":{"200":{"description":"Games retrieved successfully.","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"game_id":{"type":"integer","example":1},"mode":{"type":"string","example":301},"average":{"type":"number","format":"float","example":50.5},"rounds":{"type":"integer","example":10},"points":{"type":"integer","example":301},"double_out_percentage":{"type":"integer","example":80},"game_time":{"type":"string","format":"time","example":"00:20:00"},"created_at":{"type":"string","format":"date-time","example":"2025-01-25T12:34:56Z"}}}}}}},"400":{"description":"Bad request due to missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Missing user_id"}}}}}},"500":{"description":"Internal server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Database error"},"details":{"type":"string","example":"Detailed error message"}}}}}}}}},"/user":{"post":{"summary":"Create a new user","description":"This endpoint creates a new user and stores their details in the database.","operationId":"createUser","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["username","email","PIN"],"properties":{"username":{"type":"string","example":"johndoe","description":"The username of the user."},"email":{"type":"string","format":"email","example":"johndoe@example.com","description":"The email address of the user."},"PIN":{"type":"string","example":1234,"description":"PIN to login for the user."}}}}}},"responses":{"201":{"description":"User created successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"User created successfully"},"user_id":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"}}}}}},"400":{"description":"Bad request due to missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"500":{"description":"Internal server error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Internal server error"},"details":{"type":"string","example":"Database error"}}}}}}}},"delete":{"summary":"Delete a user account","description":"Deletes a user account from the database based on the user ID and PIN passed in headers.","operationId":"deleteUser","parameters":[{"name":"user_id","in":"header","required":true,"schema":{"type":"integer","example":123},"description":"The unique ID of the user to be deleted."},{"name":"pin","in":"header","required":true,"schema":{"type":"string","example":"mySecurePIN123"},"description":"The PIN for verifying the user's identity."}],"responses":{"200":{"description":"User account successfully deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"Account deleted successfully"}}}}}},"400":{"description":"Bad request. Missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"User ID and PIN are required"}}}}}},"404":{"description":"User not found.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Account not found"}}}}}},"500":{"description":"Internal server or database error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Database error"},"details":{"type":"string","example":"Error message with details"}}}}}}}},"get":{"summary":"Retrieve user details","description":"Authenticates a user by email and PIN passed in headers, and retrieves their details.","operationId":"getUser","parameters":[{"name":"email","in":"header","required":true,"schema":{"type":"string","format":"email","example":"johndoe@example.com"},"description":"The email address of the user."},{"name":"pin","in":"header","required":true,"schema":{"type":"string","example":"mySecurePIN123"},"description":"The PIN to authenticate the user."}],"responses":{"200":{"description":"User details retrieved successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"Success"},"user_id":{"type":"integer","example":123},"email":{"type":"string","format":"email","example":"johndoe@example.com"}}}}}},"400":{"description":"Bad request due to missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Email and pin are required"}}}}}},"404":{"description":"User not found.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Account not found"}}}}}},"500":{"description":"Internal server or database error.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","example":"Database error"},"details":{"type":"string","example":"Error message with details"}}}}}}}},"put":{"summary":"Update a user's details","description":"Updates a user's details in the database, including their username, email, and PIN.","operationId":"updateUser","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["user_id","username","email","pin"],"properties":{"user_id":{"type":"integer","example":123,"description":"The unique ID of the user to be updated."},"username":{"type":"string","example":"johndoe","description":"The new username for the user."},"email":{"type":"string","format":"email","example":"johndoe@example.com","description":"The new email address for the user."},"pin":{"type":"string","example":"myNewSecurePIN123","description":"The new PIN for the user."}}}}}},"responses":{"200":{"description":"User updated successfully.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"User updated successfully"},"user_id":{"type":"integer","example":123},"username":{"type":"string","example":"johndoe"},"email":{"type":"string","format":"email","example":"johndoe@example.com"},"updated_at":{"type":"string","format":"date-time","example":"2024-12-02T12:34:56Z"}}}}}},"400":{"description":"Bad request due to missing or invalid input.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"TEST"}}}}}},"404":{"description":"User not found.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"User not found"}}}}}},"500":{"description":"Internal server or database error.","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"Internal server error"},"details":{"type":"string","example":"Database error"}}}}}}}}}}}