<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");

include_once '../database.php';
include_once '../customers.php';

$database = new Database();
$db = $database->getConnection();
$item = new Customers($db);

$item->id = isset($_GET['id']) ? $_GET['id'] : die();
if(!isset($_GET['reward_type']))
{
    echo json_encode(['status'=>'error','message'=>'reward_type is invalid','suggested'=>'referal,testimonial_video,Leave_a_review,3_months_completion']);
    die;
}
$item->reward_type = $_GET['reward_type'];

if($item->updateCustomerPoints()){
    echo json_encode(['status'=>'success','message'=>"Customer balance updated"]);
} else{
    echo json_encode(['status'=>'error','message'=>"Customer balance not updated"]);
}
?>