Implement missing resources methods

+ Fix Swagger doc
This commit is contained in:
Louis-Rémi Babé 2017-03-08 17:03:35 +01:00
parent 8732319ba1
commit e16e730138
27 changed files with 901 additions and 147 deletions

View File

@ -27,7 +27,7 @@ class $STUDLY_NAME$ApiController extends BaseAPIController
* tags={"$LOWER_NAME$"},
* @SWG\Response(
* response=200,
* description="A list with $LOWER_NAME$",
* description="A list of $LOWER_NAME$",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/$STUDLY_NAME$"))
* ),
* @SWG\Response(
@ -48,6 +48,12 @@ class $STUDLY_NAME$ApiController extends BaseAPIController
* path="/$LOWER_NAME$/{$LOWER_NAME$_id}",
* summary="Individual $STUDLY_NAME$",
* tags={"$LOWER_NAME$"},
* @SWG\Parameter(
* in="path",
* name="$LOWER_NAME$_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single $LOWER_NAME$",
@ -59,7 +65,6 @@ class $STUDLY_NAME$ApiController extends BaseAPIController
* )
* )
*/
public function show($STUDLY_NAME$Request $request)
{
return $this->itemResponse($request->entity());
@ -75,7 +80,7 @@ class $STUDLY_NAME$ApiController extends BaseAPIController
* summary="Create a $LOWER_NAME$",
* @SWG\Parameter(
* in="body",
* name="body",
* name="$LOWER_NAME$",
* @SWG\Schema(ref="#/definitions/$STUDLY_NAME$")
* ),
* @SWG\Response(
@ -102,13 +107,19 @@ class $STUDLY_NAME$ApiController extends BaseAPIController
* tags={"$LOWER_NAME$"},
* summary="Update a $LOWER_NAME$",
* @SWG\Parameter(
* in="path",
* name="$LOWER_NAME$_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="body",
* name="$LOWER_NAME$",
* @SWG\Schema(ref="#/definitions/$STUDLY_NAME$")
* ),
* @SWG\Response(
* response=200,
* description="Update $LOWER_NAME$",
* description="Updated $LOWER_NAME$",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/$STUDLY_NAME$"))
* ),
* @SWG\Response(
@ -117,7 +128,6 @@ class $STUDLY_NAME$ApiController extends BaseAPIController
* )
* )
*/
public function update(Update$STUDLY_NAME$Request $request, $publicId)
{
if ($request->action) {
@ -136,13 +146,14 @@ class $STUDLY_NAME$ApiController extends BaseAPIController
* tags={"$LOWER_NAME$"},
* summary="Delete a $LOWER_NAME$",
* @SWG\Parameter(
* in="body",
* name="body",
* @SWG\Schema(ref="#/definitions/$STUDLY_NAME$")
* in="path",
* name="$LOWER_NAME$_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Delete $LOWER_NAME$",
* description="Deleted $LOWER_NAME$",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/$STUDLY_NAME$"))
* ),
* @SWG\Response(
@ -151,8 +162,7 @@ class $STUDLY_NAME$ApiController extends BaseAPIController
* )
* )
*/
public function destroy(Update$STUDLY_NAME$Request $request)
public function destroy($STUDLY_NAME$Request $request)
{
$$LOWER_NAME$ = $request->entity();

View File

@ -15,8 +15,8 @@ class $STUDLY_NAME$Transformer extends EntityTransformer
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="user_id", type="integer", example=1)
* @SWG\Property(property="account_key", type="string", example="123456")
* @SWG\Property(property="updated_at", type="timestamp", example="")
* @SWG\Property(property="archived_at", type="timestamp", example="1451160233")
* @SWG\Property(property="updated_at", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="archived_at", type="string", format="date-time", example="2016-01-01 12:10:00")
*/
/**

View File

@ -30,7 +30,7 @@ class ClientApiController extends BaseAPIController
* tags={"client"},
* @SWG\Response(
* response=200,
* description="A list with clients",
* description="A list of clients",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Client"))
* ),
* @SWG\Response(
@ -60,6 +60,12 @@ class ClientApiController extends BaseAPIController
* path="/clients/{client_id}",
* summary="Individual Client",
* tags={"client"},
* @SWG\Parameter(
* in="path",
* name="client_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single client",
@ -83,7 +89,7 @@ class ClientApiController extends BaseAPIController
* summary="Create a client",
* @SWG\Parameter(
* in="body",
* name="body",
* name="client",
* @SWG\Schema(ref="#/definitions/Client")
* ),
* @SWG\Response(
@ -110,13 +116,19 @@ class ClientApiController extends BaseAPIController
* tags={"client"},
* summary="Update a client",
* @SWG\Parameter(
* in="path",
* name="client_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="body",
* name="client",
* @SWG\Schema(ref="#/definitions/Client")
* ),
* @SWG\Response(
* response=200,
* description="Update client",
* description="Updated client",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Client"))
* ),
* @SWG\Response(
@ -148,13 +160,14 @@ class ClientApiController extends BaseAPIController
* tags={"client"},
* summary="Delete a client",
* @SWG\Parameter(
* in="body",
* name="body",
* @SWG\Schema(ref="#/definitions/Client")
* in="path",
* name="client_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Delete client",
* description="Deleted client",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Client"))
* ),
* @SWG\Response(
@ -163,7 +176,7 @@ class ClientApiController extends BaseAPIController
* )
* )
*/
public function destroy(UpdateClientRequest $request)
public function destroy(ClientRequest $request)
{
$client = $request->entity();

View File

@ -2,8 +2,8 @@
namespace App\Http\Controllers;
use App\Http\Requests\CreateDocumentRequest;
use App\Http\Requests\DocumentRequest;
use App\Http\Requests\CreateDocumentRequest;
use App\Models\Document;
use App\Ninja\Repositories\DocumentRepository;
@ -41,7 +41,7 @@ class DocumentAPIController extends BaseAPIController
* tags={"document"},
* @SWG\Response(
* response=200,
* description="A list with documents",
* description="A list of documents",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Document"))
* ),
* @SWG\Response(
@ -61,6 +61,28 @@ class DocumentAPIController extends BaseAPIController
* @param DocumentRequest $request
*
* @return \Illuminate\Http\Response|\Redirect|\Symfony\Component\HttpFoundation\StreamedResponse
*
* @SWG\Get(
* path="/documents/{document_id}",
* tags={"document"},
* summary="Download a document",
* produces={"application/octet-stream"},
* @SWG\Parameter(
* in="path",
* name="document_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A file",
* @SWG\Schema(type="file")
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function show(DocumentRequest $request)
{
@ -80,7 +102,7 @@ class DocumentAPIController extends BaseAPIController
* summary="Create a document",
* @SWG\Parameter(
* in="body",
* name="body",
* name="document",
* @SWG\Schema(ref="#/definitions/Document")
* ),
* @SWG\Response(
@ -100,4 +122,35 @@ class DocumentAPIController extends BaseAPIController
return $this->itemResponse($document);
}
/**
* @SWG\Delete(
* path="/documents/{document_id}",
* tags={"document"},
* summary="Delete a client",
* @SWG\Parameter(
* in="path",
* name="document_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Deleted document",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Document"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function destroy(DocumentRequest $request)
{
$entity = $request->entity();
$this->documentRepo->delete($entity);
return $this->itemResponse($entity);
}
}

View File

@ -32,7 +32,7 @@ class ExpenseApiController extends BaseAPIController
* tags={"expense"},
* @SWG\Response(
* response=200,
* description="A list with expenses",
* description="A list of expenses",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Expense"))
* ),
* @SWG\Response(
@ -51,14 +51,41 @@ class ExpenseApiController extends BaseAPIController
return $this->listResponse($expenses);
}
/**
* @SWG\Get(
* path="/expenses/{expense_id}",
* tags={"expense"},
* summary="Retrieve an expense",
* @SWG\Parameter(
* in="path",
* name="expense_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single expense",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Expense"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function show(ExpenseRequest $request)
{
return $this->itemResponse($request->entity());
}
/**
* @SWG\Post(
* path="/expenses",
* tags={"expense"},
* summary="Create a expense",
* summary="Create an expense",
* @SWG\Parameter(
* in="body",
* name="body",
* name="expense",
* @SWG\Schema(ref="#/definitions/Expense")
* ),
* @SWG\Response(
@ -87,15 +114,21 @@ class ExpenseApiController extends BaseAPIController
* @SWG\Put(
* path="/expenses/{expense_id}",
* tags={"expense"},
* summary="Update a expense",
* summary="Update an expense",
* @SWG\Parameter(
* in="path",
* name="expense_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="body",
* name="expense",
* @SWG\Schema(ref="#/definitions/Expense")
* ),
* @SWG\Response(
* response=200,
* description="Update expense",
* description="Updated expense",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Expense"))
* ),
* @SWG\Response(
@ -123,15 +156,16 @@ class ExpenseApiController extends BaseAPIController
* @SWG\Delete(
* path="/expenses/{expense_id}",
* tags={"expense"},
* summary="Delete a expense",
* summary="Delete an expense",
* @SWG\Parameter(
* in="body",
* name="body",
* @SWG\Schema(ref="#/definitions/Expense")
* in="path",
* name="expense_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Delete expense",
* description="Deleted expense",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Expense"))
* ),
* @SWG\Response(

View File

@ -2,8 +2,10 @@
namespace App\Http\Controllers;
use App\Http\Requests\ExpenseCategoryRequest;
use App\Http\Requests\CreateExpenseCategoryRequest;
use App\Http\Requests\UpdateExpenseCategoryRequest;
use App\Models\ExpenseCategory;
use App\Ninja\Repositories\ExpenseCategoryRepository;
use App\Services\ExpenseCategoryService;
use Input;
@ -22,6 +24,58 @@ class ExpenseCategoryApiController extends BaseAPIController
$this->categoryService = $categoryService;
}
/**
* @SWG\Get(
* path="/expense_categories",
* summary="List of expense categories",
* tags={"expense_category"},
* @SWG\Response(
* response=200,
* description="A list of expense categories",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/ExpenseCategory"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function index()
{
$clients = ExpenseCategory::scope()
->orderBy('created_at', 'desc')
->withTrashed();
return $this->listResponse($clients);
}
/**
* @SWG\Get(
* path="/expense_categories/{expense_category_id}",
* summary="Individual Expense Category",
* tags={"expense_category"},
* @SWG\Parameter(
* in="path",
* name="expense_category_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single expense categroy",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/ExpenseCategory"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function show(ExpenseCategory $request)
{
return $this->itemResponse($request->entity());
}
/**
* @SWG\Post(
* path="/expense_categories",
@ -29,7 +83,7 @@ class ExpenseCategoryApiController extends BaseAPIController
* summary="Create an expense category",
* @SWG\Parameter(
* in="body",
* name="body",
* name="expense_category",
* @SWG\Schema(ref="#/definitions/ExpenseCategory")
* ),
* @SWG\Response(
@ -56,13 +110,19 @@ class ExpenseCategoryApiController extends BaseAPIController
* tags={"expense_category"},
* summary="Update an expense category",
* @SWG\Parameter(
* in="path",
* name="expense_category_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="body",
* name="expense_category",
* @SWG\Schema(ref="#/definitions/ExpenseCategory")
* ),
* @SWG\Response(
* response=200,
* description="Update expense category",
* description="Updated expense category",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/ExpenseCategory"))
* ),
* @SWG\Response(
@ -77,4 +137,35 @@ class ExpenseCategoryApiController extends BaseAPIController
return $this->itemResponse($category);
}
/**
* @SWG\Delete(
* path="/expense_categories/{expense_category_id}",
* tags={"expense_category"},
* summary="Delete an expense category",
* @SWG\Parameter(
* in="path",
* name="expense_category_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Deleted expense category",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/ExpenseCategory"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function destroy(ExpenseCategoryRequest $request)
{
$entity = $request->entity();
$this->expenseCategoryRepo->delete($entity);
return $this->itemResponse($entity);
}
}

View File

@ -46,7 +46,7 @@ class InvoiceApiController extends BaseAPIController
* tags={"invoice"},
* @SWG\Response(
* response=200,
* description="A list with invoices",
* description="A list of invoices",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Invoice"))
* ),
* @SWG\Response(
@ -70,6 +70,12 @@ class InvoiceApiController extends BaseAPIController
* path="/invoices/{invoice_id}",
* summary="Individual Invoice",
* tags={"invoice"},
* @SWG\Parameter(
* in="path",
* name="invoice_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single invoice",
@ -93,7 +99,7 @@ class InvoiceApiController extends BaseAPIController
* summary="Create an invoice",
* @SWG\Parameter(
* in="body",
* name="body",
* name="invoice",
* @SWG\Schema(ref="#/definitions/Invoice")
* ),
* @SWG\Response(
@ -307,17 +313,23 @@ class InvoiceApiController extends BaseAPIController
/**
* @SWG\Put(
* path="/invoices",
* path="/invoices/{invoice_id}",
* tags={"invoice"},
* summary="Update an invoice",
* @SWG\Parameter(
* in="path",
* name="invoice_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="body",
* name="invoice",
* @SWG\Schema(ref="#/definitions/Invoice")
* ),
* @SWG\Response(
* response=200,
* description="Update invoice",
* description="Updated invoice",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice"))
* ),
* @SWG\Response(
@ -352,17 +364,18 @@ class InvoiceApiController extends BaseAPIController
/**
* @SWG\Delete(
* path="/invoices",
* path="/invoices/{invoice_id}",
* tags={"invoice"},
* summary="Delete an invoice",
* @SWG\Parameter(
* in="body",
* name="body",
* @SWG\Schema(ref="#/definitions/Invoice")
* in="path",
* name="invoice_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Delete invoice",
* description="Deleted invoice",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice"))
* ),
* @SWG\Response(
@ -371,7 +384,7 @@ class InvoiceApiController extends BaseAPIController
* )
* )
*/
public function destroy(UpdateInvoiceAPIRequest $request)
public function destroy(InvoiceRequest $request)
{
$invoice = $request->entity();

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Requests\PaymentRequest;
use App\Http\Requests\CreatePaymentAPIRequest;
use App\Http\Requests\UpdatePaymentRequest;
use App\Models\Invoice;
@ -32,7 +33,7 @@ class PaymentApiController extends BaseAPIController
* summary="List of payments",
* @SWG\Response(
* response=200,
* description="A list with payments",
* description="A list of payments",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Payment"))
* ),
* @SWG\Response(
@ -52,18 +53,19 @@ class PaymentApiController extends BaseAPIController
}
/**
* @SWG\Put(
* path="/payments/{payment_id",
* summary="Update a payment",
* @SWG\Get(
* path="/payments/{payment_id}",
* tags={"payment"},
* summary="Retrieve a payment",
* @SWG\Parameter(
* in="body",
* name="body",
* @SWG\Schema(ref="#/definitions/Payment")
* in="path",
* name="payment_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Update payment",
* description="A single payment",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Payment"))
* ),
* @SWG\Response(
@ -71,20 +73,10 @@ class PaymentApiController extends BaseAPIController
* description="an ""unexpected"" error"
* )
* )
*
* @param mixed $publicId
*/
public function update(UpdatePaymentRequest $request, $publicId)
public function show(PaymentRequest $request)
{
if ($request->action) {
return $this->handleAction($request);
}
$data = $request->input();
$data['public_id'] = $publicId;
$payment = $this->paymentRepo->save($data, $request->entity());
return $this->itemResponse($payment);
return $this->itemResponse($request->entity());
}
/**
@ -94,7 +86,7 @@ class PaymentApiController extends BaseAPIController
* tags={"payment"},
* @SWG\Parameter(
* in="body",
* name="body",
* name="payment",
* @SWG\Schema(ref="#/definitions/Payment")
* ),
* @SWG\Response(
@ -122,19 +114,62 @@ class PaymentApiController extends BaseAPIController
return $this->itemResponse($payment);
}
/**
* @SWG\Put(
* path="/payments/{payment_id}",
* summary="Update a payment",
* tags={"payment"},
* @SWG\Parameter(
* in="path",
* name="payment_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="payment",
* @SWG\Schema(ref="#/definitions/Payment")
* ),
* @SWG\Response(
* response=200,
* description="Updated payment",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Payment"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*
* @param mixed $publicId
*/
public function update(UpdatePaymentRequest $request, $publicId)
{
if ($request->action) {
return $this->handleAction($request);
}
$data = $request->input();
$data['public_id'] = $publicId;
$payment = $this->paymentRepo->save($data, $request->entity());
return $this->itemResponse($payment);
}
/**
* @SWG\Delete(
* path="/payments/{payment_id}",
* summary="Delete a payment",
* tags={"payment"},
* @SWG\Parameter(
* in="body",
* name="body",
* @SWG\Schema(ref="#/definitions/Payment")
* in="path",
* name="payment_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Delete payment",
* description="Deleted payment",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Payment"))
* ),
* @SWG\Response(
@ -143,11 +178,11 @@ class PaymentApiController extends BaseAPIController
* )
* )
*/
public function destroy(UpdatePaymentRequest $request)
public function destroy(PaymentRequest $request)
{
$payment = $request->entity();
$this->clientRepo->delete($payment);
$this->paymentRepo->delete($payment);
return $this->itemResponse($payment);
}

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Requests\ProductRequest;
use App\Http\Requests\CreateProductRequest;
use App\Http\Requests\UpdateProductRequest;
use App\Models\Product;
@ -41,7 +42,7 @@ class ProductApiController extends BaseAPIController
* tags={"product"},
* @SWG\Response(
* response=200,
* description="A list with products",
* description="A list of products",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Product"))
* ),
* @SWG\Response(
@ -59,6 +60,33 @@ class ProductApiController extends BaseAPIController
return $this->listResponse($products);
}
/**
* @SWG\Get(
* path="/products/{product_id}",
* tags={"product"},
* summary="Retrieve a product",
* @SWG\Parameter(
* in="path",
* name="product_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single product",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Product"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function show(ProductRequest $request)
{
return $this->itemResponse($request->entity());
}
/**
* @SWG\Post(
* path="/products",
@ -93,13 +121,19 @@ class ProductApiController extends BaseAPIController
* tags={"product"},
* summary="Update a product",
* @SWG\Parameter(
* in="path",
* name="product_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="body",
* name="product",
* @SWG\Schema(ref="#/definitions/Product")
* ),
* @SWG\Response(
* response=200,
* description="Update product",
* description="Updated product",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Product"))
* ),
* @SWG\Response(
@ -122,4 +156,35 @@ class ProductApiController extends BaseAPIController
return $this->itemResponse($product);
}
/**
* @SWG\Get(
* path="/products/{product_id}",
* tags={"product"},
* summary="Delete a product",
* @SWG\Parameter(
* in="path",
* name="product_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Deleted product",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Product"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function destroy(ProductRequest $request)
{
$product = $request->entity();
$this->productRepo->delete($product);
return $this->itemResponse($product);
}
}

View File

@ -6,7 +6,7 @@ use App\Models\Invoice;
use App\Ninja\Repositories\InvoiceRepository;
use Response;
class QuoteApiController extends BaseAPIController
class QuoteApiController extends InvoiceAPIController
{
protected $invoiceRepo;
@ -19,22 +19,22 @@ class QuoteApiController extends BaseAPIController
$this->invoiceRepo = $invoiceRepo;
}
/**
* @SWG\Get(
* path="/quotes",
* tags={"quote"},
* summary="List of quotes",
* @SWG\Response(
* response=200,
* description="A list with quotes",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Invoice"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
/**
* @SWG\Get(
* path="/quotes",
* tags={"quote"},
* summary="List of quotes",
* @SWG\Response(
* response=200,
* description="A list of quotes",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Invoice"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function index()
{
$invoices = Invoice::scope()
@ -45,4 +45,100 @@ class QuoteApiController extends BaseAPIController
return $this->listResponse($invoices);
}
/**
* @SWG\Get(
* path="/quotes/{quote_id}",
* summary="Individual Quote",
* tags={"quote"},
* @SWG\Parameter(
* in="path",
* name="quote_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single quote",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
/**
* @SWG\Post(
* path="/quotes",
* tags={"quote"},
* summary="Create a quote",
* @SWG\Parameter(
* in="body",
* name="quote",
* @SWG\Schema(ref="#/definitions/Invoice")
* ),
* @SWG\Response(
* response=200,
* description="New quote",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
/**
* @SWG\Put(
* path="/quotes/{quote_id}",
* tags={"quote"},
* summary="Update a quote",
* @SWG\Parameter(
* in="path",
* name="quote_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="quote",
* @SWG\Schema(ref="#/definitions/Invoice")
* ),
* @SWG\Response(
* response=200,
* description="Updated quote",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
/**
* @SWG\Delete(
* path="/quotes/{quote_id}",
* tags={"quote"},
* summary="Delete a quote",
* @SWG\Parameter(
* in="path",
* name="quote_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Deleted quote",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
}

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Requests\TaskRequest;
use App\Http\Requests\UpdateTaskRequest;
use App\Models\Task;
use App\Ninja\Repositories\TaskRepository;
@ -30,7 +31,7 @@ class TaskApiController extends BaseAPIController
* summary="List of tasks",
* @SWG\Response(
* response=200,
* description="A list with tasks",
* description="A list of tasks",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Task"))
* ),
* @SWG\Response(
@ -49,6 +50,33 @@ class TaskApiController extends BaseAPIController
return $this->listResponse($tasks);
}
/**
* @SWG\Get(
* path="/tasks/{task_id}",
* summary="Individual task",
* tags={"task"},
* @SWG\Parameter(
* in="path",
* name="task_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single task",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Task"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function show(TaskRequest $request)
{
return $this->itemResponse($request->entity());
}
/**
* @SWG\Post(
* path="/tasks",
@ -56,7 +84,7 @@ class TaskApiController extends BaseAPIController
* summary="Create a task",
* @SWG\Parameter(
* in="body",
* name="body",
* name="task",
* @SWG\Schema(ref="#/definitions/Task")
* ),
* @SWG\Response(
@ -90,10 +118,16 @@ class TaskApiController extends BaseAPIController
/**
* @SWG\Put(
* path="/task/{task_id}",
* path="/tasks/{task_id}",
* tags={"task"},
* summary="Update a task",
* @SWG\Parameter(
* in="path",
* name="task_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="body",
* @SWG\Schema(ref="#/definitions/Task")
@ -117,4 +151,35 @@ class TaskApiController extends BaseAPIController
return $this->itemResponse($task);
}
/**
* @SWG\Delete(
* path="/tasks/{task_id}",
* tags={"task"},
* summary="Delete a task",
* @SWG\Parameter(
* in="path",
* name="task_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Deleted task",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Task"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function destroy(TaskRequest $request)
{
$task = $request->entity();
$this->taskRepo->delete($task);
return $this->itemResponse($task);
}
}

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Requests\TaxRateRequest;
use App\Http\Requests\CreateTaxRateRequest;
use App\Http\Requests\UpdateTaxRateRequest;
use App\Models\TaxRate;
@ -38,7 +39,7 @@ class TaxRateApiController extends BaseAPIController
* tags={"tax_rate"},
* @SWG\Response(
* response=200,
* description="A list with tax rates",
* description="A list of tax rates",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/TaxRate"))
* ),
* @SWG\Response(
@ -56,6 +57,33 @@ class TaxRateApiController extends BaseAPIController
return $this->listResponse($taxRates);
}
/**
* @SWG\Get(
* path="/tax_rates/{tax_rate_id}",
* tags={"tax_rate"},
* summary="Retrieve a tax rate",
* @SWG\Parameter(
* in="path",
* name="tax_rate_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single tax rate",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/TaxRate"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function show(TaxRateRequest $request)
{
return $this->itemResponse($request->entity());
}
/**
* @SWG\Post(
* path="/tax_rates",
@ -63,7 +91,7 @@ class TaxRateApiController extends BaseAPIController
* summary="Create a tax rate",
* @SWG\Parameter(
* in="body",
* name="body",
* name="tax_rate",
* @SWG\Schema(ref="#/definitions/TaxRate")
* ),
* @SWG\Response(
@ -90,13 +118,19 @@ class TaxRateApiController extends BaseAPIController
* tags={"tax_rate"},
* summary="Update a tax rate",
* @SWG\Parameter(
* in="path",
* name="tax_rate_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="body",
* name="tax_rate",
* @SWG\Schema(ref="#/definitions/TaxRate")
* ),
* @SWG\Response(
* response=200,
* description="Update tax rate",
* description="Updated tax rate",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/TaxRate"))
* ),
* @SWG\Response(
@ -119,4 +153,35 @@ class TaxRateApiController extends BaseAPIController
return $this->itemResponse($taxRate);
}
/**
* @SWG\Delete(
* path="/tax_rates/{tax_rate_id}",
* tags={"tax_rate"},
* summary="Delete a tax rate",
* @SWG\Parameter(
* in="path",
* name="tax_rate_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Deleted tax rate",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/TaxRate"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function destroy(TaxRateRequest $request)
{
$entity = $request->entity();
$this->taxRateRepo->delete($entity);
return $this->itemResponse($entity);
}
}

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Requests\UserRequest;
use App\Http\Requests\CreateUserRequest;
use App\Http\Requests\UpdateUserRequest;
use App\Models\User;
@ -25,22 +26,113 @@ class UserApiController extends BaseAPIController
$this->userRepo = $userRepo;
}
/**
* @SWG\Get(
* path="/users",
* summary="List of users",
* tags={"user"},
* @SWG\Response(
* response=200,
* description="A list of users",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/User"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function index()
{
$users = User::whereAccountId(Auth::user()->account_id)
->withTrashed()
->orderBy('created_at', 'desc');
return $this->listResponse($users);
}
/*
/**
* @SWG\Get(
* path="/users/{user_id}",
* summary="Individual user",
* tags={"client"},
* @SWG\Parameter(
* in="path",
* name="user_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single user",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/User"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function show(UserRequest $request)
{
return $this->itemResponse($request->entity());
}
/**
* @SWG\Post(
* path="/users",
* tags={"user"},
* summary="Create a user",
* @SWG\Parameter(
* in="body",
* name="user",
* @SWG\Schema(ref="#/definitions/User")
* ),
* @SWG\Response(
* response=200,
* description="New user",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/User"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function store(CreateUserRequest $request)
{
return $this->save($request);
}
*/
/**
* @SWG\Put(
* path="/users/{user_id}",
* tags={"user"},
* summary="Update a user",
* @SWG\Parameter(
* in="path",
* name="user_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="user",
* @SWG\Schema(ref="#/definitions/User")
* ),
* @SWG\Response(
* response=200,
* description="Updated user",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/User"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*
* @param mixed $userPublicId
*/
public function update(UpdateUserRequest $request, $userPublicId)
{
$user = Auth::user();
@ -66,4 +158,35 @@ class UserApiController extends BaseAPIController
return $this->response($data);
}
/**
* @SWG\Delete(
* path="/users/{user_id}",
* tags={"user"},
* summary="Delete a user",
* @SWG\Parameter(
* in="path",
* name="user_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Deleted user",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/User"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function destroy(UserRequest $request)
{
$entity = $request->entity();
$this->userRepo->delete($entity);
return $this->itemResponse($entity);
}
}

View File

@ -39,7 +39,7 @@ class VendorApiController extends BaseAPIController
* tags={"vendor"},
* @SWG\Response(
* response=200,
* description="A list with vendors",
* description="A list of vendors",
* @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Vendor"))
* ),
* @SWG\Response(
@ -57,6 +57,33 @@ class VendorApiController extends BaseAPIController
return $this->listResponse($vendors);
}
/**
* @SWG\Get(
* path="/vendors/{vendor_id}",
* summary="Individual vendor",
* tags={"client"},
* @SWG\Parameter(
* in="path",
* name="vendor_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="A single vendor",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Vendor"))
* ),
* @SWG\Response(
* response="default",
* description="an ""unexpected"" error"
* )
* )
*/
public function show(VendorRequest $request)
{
return $this->itemResponse($request->entity());
}
/**
* @SWG\Post(
* path="/vendors",
@ -64,7 +91,7 @@ class VendorApiController extends BaseAPIController
* summary="Create a vendor",
* @SWG\Parameter(
* in="body",
* name="body",
* name="vendor",
* @SWG\Schema(ref="#/definitions/Vendor")
* ),
* @SWG\Response(
@ -95,13 +122,19 @@ class VendorApiController extends BaseAPIController
* tags={"vendor"},
* summary="Update a vendor",
* @SWG\Parameter(
* in="path",
* name="vendor_id",
* type="integer",
* required="true"
* ),
* @SWG\Parameter(
* in="body",
* name="body",
* name="vendor",
* @SWG\Schema(ref="#/definitions/Vendor")
* ),
* @SWG\Response(
* response=200,
* description="Update vendor",
* description="Updated vendor",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Vendor"))
* ),
* @SWG\Response(
@ -133,13 +166,14 @@ class VendorApiController extends BaseAPIController
* tags={"vendor"},
* summary="Delete a vendor",
* @SWG\Parameter(
* in="body",
* name="body",
* @SWG\Schema(ref="#/definitions/Vendor")
* in="path",
* name="vendor_id",
* type="integer",
* required="true"
* ),
* @SWG\Response(
* response=200,
* description="Delete vendor",
* description="Deleted vendor",
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Vendor"))
* ),
* @SWG\Response(

View File

@ -0,0 +1,8 @@
<?php
namespace App\Http\Requests;
class UserRequest extends EntityRequest
{
protected $entityType = ENTITY_USER;
}

View File

@ -303,12 +303,10 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function () {
Route::get('accounts', 'AccountApiController@show');
Route::put('accounts', 'AccountApiController@update');
Route::resource('clients', 'ClientApiController');
Route::get('quotes', 'QuoteApiController@index');
Route::get('invoices', 'InvoiceApiController@index');
Route::ressource('quotes', 'QuoteApiController');
Route::get('download/{invoice_id}', 'InvoiceApiController@download');
Route::resource('invoices', 'InvoiceApiController');
Route::resource('payments', 'PaymentApiController');
Route::get('tasks', 'TaskApiController@index');
Route::resource('tasks', 'TaskApiController');
Route::post('hooks', 'IntegrationController@subscribe');
Route::post('email_invoice', 'InvoiceApiController@emailInvoice');

View File

@ -11,12 +11,12 @@ class ClientTransformer extends EntityTransformer
{
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="balance", type="float", example=10, readOnly=true)
* @SWG\Property(property="paid_to_date", type="float", example=10, readOnly=true)
* @SWG\Property(property="balance", type="number", format="float", example=10, readOnly=true)
* @SWG\Property(property="paid_to_date", type="number", format="float", example=10, readOnly=true)
* @SWG\Property(property="user_id", type="integer", example=1)
* @SWG\Property(property="account_key", type="string", example="123456")
* @SWG\Property(property="updated_at", type="timestamp", example="")
* @SWG\Property(property="archived_at", type="timestamp", example="1451160233")
* @SWG\Property(property="updated_at", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="archived_at", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="address1", type="string", example="10 Main St.")
* @SWG\Property(property="address2", type="string", example="1st Floor")
* @SWG\Property(property="city", type="string", example="New York")
@ -25,12 +25,12 @@ class ClientTransformer extends EntityTransformer
* @SWG\Property(property="country_id", type="integer", example=840)
* @SWG\Property(property="work_phone", type="string", example="(212) 555-1212")
* @SWG\Property(property="private_notes", type="string", example="Notes...")
* @SWG\Property(property="last_login", type="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="last_login", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="website", type="string", example="http://www.example.com")
* @SWG\Property(property="industry_id", type="integer", example=1)
* @SWG\Property(property="size_id", type="integer", example=1)
* @SWG\Property(property="is_deleted", type="boolean", example=false)
* @SWG\Property(property="payment_terms", type="", example=30)
* @SWG\Property(property="payment_terms", type="integer", example=30)
* @SWG\Property(property="custom_value1", type="string", example="Value")
* @SWG\Property(property="custom_value2", type="string", example="Value")
* @SWG\Property(property="vat_number", type="string", example="123456")

View File

@ -14,8 +14,8 @@ class DocumentTransformer extends EntityTransformer
* @SWG\Property(property="name", type="string", example="Test")
* @SWG\Property(property="type", type="string", example="CSV")
* @SWG\Property(property="invoice_id", type="integer", example=1)
* @SWG\Property(property="updated_at", type="timestamp", example=1451160233, readOnly=true)
* @SWG\Property(property="archived_at", type="timestamp", example=1451160233, readOnly=true)
* @SWG\Property(property="updated_at", type="string", format="date-time", example="2016-01-01 12:10:00", readOnly=true)
* @SWG\Property(property="archived_at", type="string", format="date-time", example="2016-01-01 12:10:00", readOnly=true)
*/
public function transform(Document $document)
{

View File

@ -12,8 +12,8 @@ class ExpenseCategoryTransformer extends EntityTransformer
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="name", type="string", example="Sample")
* @SWG\Property(property="updated_at", type="timestamp", example=1451160233, readOnly=true)
* @SWG\Property(property="archived_at", type="timestamp", example=1451160233, readOnly=true)
* @SWG\Property(property="updated_at", type="string", format="date-time", example="2016-01-01 12:10:00", readOnly=true)
* @SWG\Property(property="archived_at", type="string", format="date-time", example="2016-01-01 12:10:00", readOnly=true)
*/
public function transform(ExpenseCategory $expenseCategory)
{

View File

@ -4,8 +4,36 @@ namespace App\Ninja\Transformers;
use App\Models\Expense;
/**
* @SWG\Definition(definition="Expense", @SWG\Xml(name="Expense"))
*/
class ExpenseTransformer extends EntityTransformer
{
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="private_notes", type="string", example="Notes...")
* @SWG\Property(property="public_notes", type="string", example="Notes...")
* @SWG\Property(property="should_be_invoiced", type="boolean", example=false)
* @SWG\Property(property="updated_at", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="archived_at", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="transaction_id", type="integer", example=1)
* @SWG\Property(property="bank_id", type="integer", example=1)
* @SWG\Property(property="expense_currency_id", type="integer", example=1)
* @SWG\Property(property="expense_category_id", type="integer", example=1)
* @SWG\Property(property="amount", type="number", format="float,", example="17.5")
* @SWG\Property(property="expense_date", type="string", format="date", example="2016-01-01")
* @SWG\Property(property="exchange_rate", type="number", format="float", example="")
* @SWG\Property(property="invoice_currency_id", type="integer", example=1)
* @SWG\Property(property="is_deleted", type="boolean", example=false)
* @SWG\Property(property="tax_name1", type="string", example="VAT")
* @SWG\Property(property="tax_name2", type="string", example="Upkeep")
* @SWG\Property(property="tax_rate1", type="number", format="float", example="17.5")
* @SWG\Property(property="tax_rate2", type="number", format="float", example="30.0")
* @SWG\Property(property="client_id", type="integer", example=1)
* @SWG\Property(property="invoice_id", type="integer", example=1)
* @SWG\Property(property="vendor_id", type="integer", example=1)
*/
public function __construct($account = null, $serializer = null, $client = null)
{
parent::__construct($account, $serializer);

View File

@ -13,8 +13,8 @@ class InvoiceTransformer extends EntityTransformer
{
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="amount", type="float", example=10, readOnly=true)
* @SWG\Property(property="balance", type="float", example=10, readOnly=true)
* @SWG\Property(property="amount", type="number", format="float", example=10, readOnly=true)
* @SWG\Property(property="balance", type="number", format="float", example=10, readOnly=true)
* @SWG\Property(property="client_id", type="integer", example=1)
* @SWG\Property(property="invoice_number", type="string", example="0001")
* @SWG\Property(property="invoice_status_id", type="integer", example=1)

View File

@ -14,7 +14,7 @@ class PaymentTransformer extends EntityTransformer
{
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="amount", type="float", example=10, readOnly=true)
* @SWG\Property(property="amount", type="number", format="float", example=10, readOnly=true)
* @SWG\Property(property="invoice_id", type="integer", example=1)
*/
protected $defaultIncludes = [];

View File

@ -13,11 +13,11 @@ class ProductTransformer extends EntityTransformer
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="product_key", type="string", example="Item")
* @SWG\Property(property="notes", type="string", example="Notes...")
* @SWG\Property(property="cost", type="float", example=10.00)
* @SWG\Property(property="qty", type="float", example=1)
* @SWG\Property(property="cost", type="number", format="float", example=10.00)
* @SWG\Property(property="qty", type="number", format="float", example=1)
* @SWG\Property(property="default_tax_rate_id", type="integer", example=1)
* @SWG\Property(property="updated_at", type="timestamp", example=1451160233, readOnly=true)
* @SWG\Property(property="archived_at", type="timestamp", example=1451160233, readOnly=true)
* @SWG\Property(property="updated_at", type="string", format="date-time", example="2016-01-01 12:10:00", readOnly=true)
* @SWG\Property(property="archived_at", type="string", format="date-time", example="2016-01-01 12:10:00", readOnly=true)
*/
public function transform(Product $product)
{

View File

@ -13,7 +13,7 @@ class TaskTransformer extends EntityTransformer
{
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="amount", type="float", example=10, readOnly=true)
* @SWG\Property(property="amount", type="number", format="float", example=10, readOnly=true)
* @SWG\Property(property="invoice_id", type="integer", example=1)
*/
protected $availableIncludes = [

View File

@ -13,10 +13,10 @@ class TaxRateTransformer extends EntityTransformer
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="name", type="string", example="GST")
* @SWG\Property(property="account_key", type="string", example="asimplestring", readOnly=true)
* @SWG\Property(property="rate", type="float", example=17.5)
* @SWG\Property(property="rate", type="number", format="float", example=17.5)
* @SWG\Property(property="is_inclusive", type="boolean", example=false)
* @SWG\Property(property="updated_at", type="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="archived_at", type="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="updated_at", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="archived_at", type="string", format="date-time", example="2016-01-01 12:10:00")
*/
public function transform(TaxRate $taxRate)
{

View File

@ -5,8 +5,31 @@ namespace App\Ninja\Transformers;
use App\Models\Account;
use App\Models\User;
/**
* @SWG\Definition(definition="User", @SWG\Xml(name="User"))
*/
class UserTransformer extends EntityTransformer
{
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="first_name", type="string", example="John")
* @SWG\Property(property="last_name", type="string", example="Doe")
* @SWG\Property(property="email", type="string", example="johndoe@isp.com")
* @SWG\Property(property="account_key", type="string", example="123456")
* @SWG\Property(property="updated_at", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="deleted_at", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="phone", type="string", example="(212) 555-1212")
* @SWG\Property(property="registered", type="boolean", example=false)
* @SWG\Property(property="confirmed", type="boolean", example=false)
* @SWG\Property(property="oauth_user_id", type="integer", example=1)
* @SWG\Property(property="oauth_provider_id", type="integer", example=1)
* @SWG\Property(property="notify_sent", type="boolean", example=false)
* @SWG\Property(property="notify_viewed", type="boolean", example=false)
* @SWG\Property(property="notify_paid", type="boolean", example=false)
* @SWG\Property(property="notify_approved", type="boolean", example=false)
* @SWG\Property(property="is_admin", type="boolean", example=false)
* @SWG\Property(property="permissions", type="integer", example=1)
*/
public function transform(User $user)
{
return [

View File

@ -13,12 +13,12 @@ class VendorTransformer extends EntityTransformer
{
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="balance", type="float", example=10, readOnly=true)
* @SWG\Property(property="paid_to_date", type="float", example=10, readOnly=true)
* @SWG\Property(property="balance", type="number", format="float", example=10, readOnly=true)
* @SWG\Property(property="paid_to_date", type="number", format="float", example=10, readOnly=true)
* @SWG\Property(property="user_id", type="integer", example=1)
* @SWG\Property(property="account_key", type="string", example="123456")
* @SWG\Property(property="updated_at", type="timestamp", example="")
* @SWG\Property(property="archived_at", type="timestamp", example="1451160233")
* @SWG\Property(property="updated_at", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="archived_at", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="address1", type="string", example="10 Main St.")
* @SWG\Property(property="address2", type="string", example="1st Floor")
* @SWG\Property(property="city", type="string", example="New York")
@ -27,7 +27,7 @@ class VendorTransformer extends EntityTransformer
* @SWG\Property(property="country_id", type="integer", example=840)
* @SWG\Property(property="work_phone", type="string", example="(212) 555-1212")
* @SWG\Property(property="private_notes", type="string", example="Notes...")
* @SWG\Property(property="last_login", type="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="last_login", type="string", format="date-time", example="2016-01-01 12:10:00")
* @SWG\Property(property="website", type="string", example="http://www.example.com")
* @SWG\Property(property="is_deleted", type="boolean", example=false)
* @SWG\Property(property="vat_number", type="string", example="123456")
@ -36,12 +36,12 @@ class VendorTransformer extends EntityTransformer
protected $defaultIncludes = [
'vendor_contacts',
];
protected $availableIncludes = [
'invoices',
//'expenses',
];
public function includeVendorContacts(Vendor $vendor)
{
$transformer = new VendorContactTransformer($this->account, $this->serializer);