Commit 3dd66042 authored by philippepary's avatar philippepary
Browse files

Added version and image routes and Image model

parent 6425bc02
......@@ -5,13 +5,17 @@ $files = [
"../src/http/public/index.php",
"../src/lib/Model/Category.php",
"../src/lib/Model/Currency.php",
"../src/lib/Model/Image.php",
"../src/lib/Model/Product.php",
"../src/lib/Model/Tax.php",
"../src/lib/Model/User.php",
"../src/http/routes/category.php",
"../src/http/routes/currency.php",
"../src/http/routes/image.php",
"../src/http/routes/product.php",
"../src/http/routes/tax.php",
"../src/http/routes/user.php",
"../src/http/routes/version.php",
];
$dirs = [
"../src/http/routes/",
......
......@@ -3,6 +3,14 @@
use \Pasteque\Server\System\API\APICaller;
use \Pasteque\Server\System\API\APIResult;
/**
* @rest\endpoint /image/{model}/default
* @rest\method GET Get default image for a given model
* @rest\path String model Model name (user, category, user, customer, paymentmode …)
* @rest\response 200 String Base64 of the image
* @rest\tags images
*/
//
$app->GET('/api/image/{model}/default', function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
$imgCall = APICaller::run($ptApp, 'image', 'getDefault', $args['model']);
......@@ -21,14 +29,12 @@ $app->GET('/api/image/{model}/default', function($request, $response, $args) {
});
/**
* GET imageIdGet
* Summary:
* Notes: get image
* Output-Formats: MIME type of the image
* @SWG\Get(
* path="/api/image/{model}/{id}",
* @SWG\Response(response="200", description="get image")
* )
* @rest\endpoint /image/{model}/{id}
* @rest\method GET get a given model
* @rest\path String model Model type
* @rest\path String id Model's ID
* @rest\response 200 String Base64 of the image
* @rest\tags images
*/
$app->GET('/api/image/{model}/{id}', function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
......
......@@ -4,10 +4,10 @@ use \Pasteque\Server\System\API\APICaller;
use \Pasteque\Server\System\API\APIResult;
/**
* GET server version
* Summary:
* Notes:
* Output-Formats: [application/json]
* @rest\endpoint /version
* @rest\method GET Get the current version of the API
* @rest\response 200 Int Pastèque's API current version
* @rest\tags generic
*/
$app->GET('/api/version', function ($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
......
......@@ -32,9 +32,14 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* identified by the model name and it's id. This flag is managed by
* ImageAPI and should not be edited in an other way.
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @Table(name="images")
* @rest\model Image
* @rest\description An image for a product, category, user…
* @rest\property String image base64 encoded image
* @rest\property String model Type of model for this image (category, product, user, customer, paymentmode…). See MODEL_* constants
* @rest\property String modelId ID of the model the image is for.\nIt is a string to allow multi-fied ids as a JSON string
* @rest\property String mimeType Mime type of the image
*/
class Image extends DoctrineModel
{
......@@ -59,7 +64,6 @@ class Image extends DoctrineModel
/**
* Type of model the image is for. See constants.
* @var string
* @SWG\Property()
* @Id @Column(type="string")
*/
protected $model;
......@@ -70,7 +74,6 @@ class Image extends DoctrineModel
* ID of the model the image is for.
* It is a string to allow multi-fied ids as a JSON string.
* @var string
* @SWG\Property()
* @Id @Column(type="string")
*/
protected $modelId;
......@@ -88,7 +91,6 @@ class Image extends DoctrineModel
/**
* Mime type
* @var string
* @SWG\Property()
* @Column(type="string")
*/
protected $mimeType;
......@@ -98,7 +100,6 @@ class Image extends DoctrineModel
/**
* The actual image
* @var binary
* @SWG\Property()
* @Column(type="blob")
*/
protected $image;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment