/**
 * Created by PhpStorm.
 * User: idz
 * Date: 4/6/15
 * Time: 12:19 AM
 */
require_once 'classes/playlist.php';
// session_start();
$playlist = new Playlist();
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
if (property_exists($request, "playlistName") && property_exists($request, "athTokenPl")) {
    $playlistName = $request->playlistName;
    $encrypted_user_id = $request->athTokenPl;
    $return_code = $playlist->AddPlaylist($playlistName, $encrypted_user_id);
    if ($return_code == 1) {
        echo "Playlist added successfully";
    } else {
        if ($return_code == 2) {
            echo "Something went wrong in database";
        } else {
            echo "Something's wrong";
        }
    }
}
if (property_exists($request, "athTokenPlModel")) {
    $encrypted_user_id = $request->athTokenPlModel;
    $playlist_object = $playlist->GetPlaylists($encrypted_user_id);
    echo json_encode($playlist_object);
}