<?php


header('Content-Type: application/json');

require_once '../db/functions.php';
require_once '../db/ratings/Rating.php';



$rating = new Rating($conn);
$method = $_SERVER['REQUEST_METHOD'];



// دریافت داده‌های JSON برای POST و PUT
$input = json_decode(file_get_contents('php://input'), true);



switch ($method) {
    case 'GET':

            echo json_encode("");

        break;

    case 'POST':
       $result= $rating->Add($input);
        echo json_encode( $result);
        break;

    case 'PUT':


            echo json_encode(['status' => 'updated']);

        break;

    case 'DELETE':


            echo json_encode(['status' => 'deleted']);

        break;

    default:
        http_response_code(405);
        echo json_encode(['error' => 'Method not allowed']);
        break;
}