PaperBag/www/api/v1/index.php

47 lines
1.0 KiB
PHP

<?php
require 'api-init.php';
$db = database();
$data = sanitize();
$group = "";
if(isset($data['fi'])){
$group = $data['fi'];
}
elseif(isset($data['recipes'])){
$group = "recipe";
}
switch ($group){
case "recipe":
include 'recipes.php';
if(!empty($_POST)){
// CREATE RECIPE
if(isset($data['name']) && $data['name'] != "string"){
if($newID = Recipes::createRecipe($data['name'], $data['portions'], $data['public'])){
returns("OK: ".$newID);
}
else {
returns($db->error, 1);
}
}
}
else {
returns(Recipes::getAll());
}
break;
case "plan":
returns("Coming soon...");
break;
default:
returns('Nothing to do');
}
returns('Failed.',2);
$docs['recipe'][] = array("method"=>'POST', "href"=>"/recipe", "name"=>"Create recipe", "body"=>"{\n \"name\": \"string\",\n \"public\": \"boolean\" \n}");