diff --git a/app/Http/Controllers/ClientApiController.php b/app/Http/Controllers/ClientApiController.php index b847a54d349b..c4cce4d570ad 100644 --- a/app/Http/Controllers/ClientApiController.php +++ b/app/Http/Controllers/ClientApiController.php @@ -23,6 +23,22 @@ class ClientApiController extends Controller return Response::make('', 200, $headers); } + /** + * @SWG\Get( + * path="/clients", + * summary="List of clients", + * tags={"client"}, + * @SWG\Response( + * response=200, + * description="A list with clients", + * @SWG\Schema(type="array", @SWG\Items(ref="#/definitions/Client")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ public function index() { $clients = Client::scope() @@ -37,6 +53,27 @@ class ClientApiController extends Controller return Response::make($response, 200, $headers); } + /** + * @SWG\Post( + * path="/clients", + * tags={"client"}, + * summary="Create a client", + * @SWG\Parameter( + * in="body", + * name="body", + * @SWG\Schema(ref="#/definitions/Client") + * ), + * @SWG\Response( + * response=200, + * description="New client", + * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Client")) + * ), + * @SWG\Response( + * response="default", + * description="an ""unexpected"" error" + * ) + * ) + */ public function store(CreateClientRequest $request) { $client = $this->clientRepo->save($request->input()); diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index 268a547e573b..2be9b2d70fc3 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -83,7 +83,7 @@ class InvoiceApiController extends Controller * ), * @SWG\Response( * response=200, - * description="Newly created invoice", + * description="New invoice", * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice")) * ), * @SWG\Response( diff --git a/app/Ninja/Transformers/ClientTransformer.php b/app/Ninja/Transformers/ClientTransformer.php index 8e9396981e84..4b2e950921d4 100644 --- a/app/Ninja/Transformers/ClientTransformer.php +++ b/app/Ninja/Transformers/ClientTransformer.php @@ -5,8 +5,18 @@ use App\Models\Client; use App\Models\Contact; use League\Fractal; +/** + * @SWG\Definition(definition="Client", @SWG\Xml(name="Client")) + */ + 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) + */ + protected $defaultIncludes = [ 'contacts', 'invoices', diff --git a/app/Ninja/Transformers/InvoiceTransformer.php b/app/Ninja/Transformers/InvoiceTransformer.php index 4cc751e62e6e..c5d47f14d3e3 100644 --- a/app/Ninja/Transformers/InvoiceTransformer.php +++ b/app/Ninja/Transformers/InvoiceTransformer.php @@ -6,7 +6,7 @@ use App\Models\Invoice; use League\Fractal; /** - * @SWG\Definition(definition="Invoice",required={"invoice_number"}, @SWG\Xml(name="Invoice")) + * @SWG\Definition(definition="Invoice", required={"invoice_number"}, @SWG\Xml(name="Invoice")) */ class InvoiceTransformer extends EntityTransformer