Commit 8e36d2be authored by philippepary's avatar philippepary
Browse files

Added product and category routes

parent 7155a112
......@@ -8,6 +8,8 @@ $files = [
"../src/lib/Model/Product.php",
"../src/lib/Model/Tax.php",
"../src/lib/Model/User.php",
"../src/http/routes/category.php",
"../src/http/routes/product.php",
];
$dirs = [
"../src/http/routes/",
......
<?php
use Pasteque\Server\System\API\APICaller;
use Pasteque\Server\System\API\APIResult;
/**
* GET categoryGetAllGet
* Summary:
* Notes: Get an array of all Categories
* Output-Formats: [application/json]
* @rest\endpoint /category/getAll
* @rest\method GET Get all available categories
* @rest\response 200 array(Category) An array of categories
* @rest\tags categories
*/
$app->GET('/api/category/getAll', function($request, $response, $args) {
......@@ -18,10 +19,10 @@ $app->GET('/api/category/getAll', function($request, $response, $args) {
/**
* GET categoryGetChildrensGet
* Summary:
* Notes: Get an array of Categories from a parent Category Id
* Output-Formats: [application/json]
* @rest\endpoint /category/getChildrens
* @rest\method GET Get all children categories
* @rest\response 200 array(Category) An array of categories
* @rest\tags categories
*/
$app->GET('/api/category/getChildrens', function($request, $response, $args) {
......@@ -32,10 +33,11 @@ $app->GET('/api/category/getChildrens', function($request, $response, $args) {
/**
* GET categoryIdGet
* Summary:
* Notes: Get a Category
* Output-Formats: [application/json]
* @rest\endpoint /caterogy/{id}
* @rest\method GET Get a category by its ID
* @rest\path Int id ID of the category
* @rest\response 200 Category The category
* @rest\tags categories
*/
$app->GET('/api/category/{id}', function($request, $response, $args) {
return $response->withJson(\Pasteque\CategoriesService::get($args['id']));
......
......@@ -3,11 +3,12 @@
use \Pasteque\Server\System\API\APICaller;
/**
* GET productGetAllGet
* Summary:
* Notes: Get a array of all Product
* Output-Formats: [application/json]
* @rest\endpoint /product/getAll
* @rest\method GET Get all available products
* @rest\response 200 array(Product) An array of products
* @rest\tags products
*/
//
$app->GET('/api/product/getAll', function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
return $response->withApiResult(APICaller::run($ptApp, 'product', 'getAll'));
......@@ -15,11 +16,13 @@ $app->GET('/api/product/getAll', function($request, $response, $args) {
/**
* GET productGetByCategoryCategoryGet
* Summary:
* Notes: getCategory description
* Output-Formats: [application/json]
* @rest\endpoint /product/getByCategory/{category}
* @rest\method GET Get products of a category
* @rest\path Int category ID of the category
* @rest\response 200 array(Product) An array of products
* @rest\tags products categories
*/
//
$app->GET('/api/product/getByCategory/{category}', function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
return $response->withApiResult(APICaller::run($ptApp, 'product', 'getFromCategory', $args['category']));
......@@ -27,11 +30,13 @@ $app->GET('/api/product/getByCategory/{category}', function($request, $response,
/**
* GET productGetbycodeCodeGet
* Summary:
* Notes: Get a Product by code
* Output-Formats: [application/json]
* @rest\endpoint /product/getByCode/{code}
* @rest\method GET Get a product by its barcode
* @rest\path String code Barcode of a product
* @rest\response 200 Product The product
* @rest\tags products
*/
//
$app->GET('/api/product/getByCode/{code}', function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
return $response->withApiResult(APICaller::run($ptApp, 'product', 'getByCode', $args['code']));
......@@ -39,11 +44,13 @@ $app->GET('/api/product/getByCode/{code}', function($request, $response, $args)
/**
* GET productGetbyreferenceReferenceGet
* Summary:
* Notes: Get a Product by reference
* Output-Formats: [application/json]
* @rest\endpoint /product/getByReference/{reference}
* @rest\method GET Get a product by its reference
* @rest\path String reference Product's reference
* @rest\response 200 Product The product
* @rest\tags products
*/
//
$app->GET('/api/product/getByReference/{reference}', function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
return $response->withApiResult(APICaller::run($ptApp, 'product', 'getByReference', $args['reference']));
......@@ -51,10 +58,11 @@ $app->GET('/api/product/getByReference/{reference}', function($request, $respons
/**
* GET productIdGet
* Summary:
* Notes: Get a Product
* Output-Formats: [application/json]
* @rest\endpoint /product/{id}
* @rest\method GET Get a product by its id
* @rest\path Int id Product's ID
* @rest\response 200 Product The product
* @rest\tags products
*/
$app->GET('/api/product/{id}', function($request, $response, $args) {
$ptApp = $this->get('settings')['ptApp'];
......
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