diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index c87e8efad5..257d1c137e 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -96,9 +96,8 @@ class LoginController extends BaseController * @param \Illuminate\Http\Request $request The request * * @return Response|User Process user login. - */ - - /** + * + * * @OA\Post( * path="/api/v1/login", * operationId="postLogin", @@ -192,6 +191,46 @@ class LoginController extends BaseController } + /** + * Refreshes the data feed with the current Company User + * + * @return CompanyUser Refresh Feed. + * + * + * @OA\Post( + * path="/api/v1/refresh", + * operationId="refresh", + * tags={"refresh"}, + * summary="Refreshes the dataset", + * description="Refreshes the dataset", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Parameter(ref="#/components/parameters/include_static"), + * @OA\Parameter(ref="#/components/parameters/clear_cache"), + * @OA\Response( + * response=200, + * description="The Company User response", + * @OA\Header(header="X-API-TOKEN", ref="#/components/headers/X-API-TOKEN"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/CompanyUser"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * + */ public function refresh(Request $request) { $ct = CompanyUser::whereUserId(auth()->user()->id); diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 832e9a09d7..3aea470456 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -74,6 +74,40 @@ class InvoiceController extends BaseController * @param \App\Filters\InvoiceFilters $filters The filters * * @return \Illuminate\Http\Response + * + * @OA\Get( + * path="/api/v1/invoices", + * operationId="getInvoices", + * tags={"invoices"}, + * summary="Gets a list of invoices", + * description="Lists invoices, search and filters allow fine grained lists to be generated. + + Query parameters can be added to performed more fine grained filtering of the invoices, these are handled by the InvoiceFilters class which defines the methods available", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Response( + * response=200, + * description="A list of invoices", + * @OA\Header(header="X-API-TOKEN", ref="#/components/headers/X-API-TOKEN"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/Invoice"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * */ public function index(InvoiceFilters $filters) { @@ -90,6 +124,39 @@ class InvoiceController extends BaseController * @param \App\Http\Requests\Invoice\CreateInvoiceRequest $request The request * * @return \Illuminate\Http\Response + * + * + * @OA\Get( + * path="/api/v1/invoices/create", + * operationId="getInvoicesCreate", + * tags={"invoices"}, + * summary="Gets a new blank invoice object", + * description="Returns a blank object with default values", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Response( + * response=200, + * description="A blank invoice object", + * @OA\Header(header="X-API-TOKEN", ref="#/components/headers/X-API-TOKEN"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/Invoice"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * */ public function create(CreateInvoiceRequest $request) { @@ -107,7 +174,40 @@ class InvoiceController extends BaseController * @param \App\Http\Requests\Invoice\StoreInvoiceRequest $request The request * * @return \Illuminate\Http\Response - */ + * + * + * @OA\Post( + * path="/api/v1/invoices", + * operationId="storeInvoice", + * tags={"invoices"}, + * summary="Adds a invoice", + * description="Adds an invoice to the system", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Response( + * response=200, + * description="Returns the saved invoice object", + * @OA\Header(header="X-API-TOKEN", ref="#/components/headers/X-API-TOKEN"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/Invoice"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * + */ public function store(StoreInvoiceRequest $request) { @@ -128,7 +228,51 @@ class InvoiceController extends BaseController * @param \App\Models\Invoice $invoice The invoice * * @return \Illuminate\Http\Response - */ + * + * + * @OA\Get( + * path="/api/v1/invoices/{id}", + * operationId="showInvoice", + * tags={"invoices"}, + * summary="Shows an invoice", + * description="Displays an invoice by id", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Parameter( + * name="id", + * in="path", + * description="The Invoice Hashed ID", + * example="D2J234DFA", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Response( + * response=200, + * description="Returns the invoice object", + * @OA\Header(header="X-API-TOKEN", ref="#/components/headers/X-API-TOKEN"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/Invoice"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * + */ public function show(ShowInvoiceRequest $request, Invoice $invoice) { @@ -143,7 +287,50 @@ class InvoiceController extends BaseController * @param \App\Models\Invoice $invoice The invoice * * @return \Illuminate\Http\Response - */ + * + * @OA\Get( + * path="/api/v1/invoices/{id}/edit", + * operationId="editInvoice", + * tags={"invoices"}, + * summary="Shows an invoice for editting", + * description="Displays an invoice by id", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Parameter( + * name="id", + * in="path", + * description="The Invoice Hashed ID", + * example="D2J234DFA", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Response( + * response=200, + * description="Returns the invoice object", + * @OA\Header(header="X-API-TOKEN", ref="#/components/headers/X-API-TOKEN"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/Invoice"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * + */ public function edit(EditInvoiceRequest $request, Invoice $invoice) { @@ -158,7 +345,51 @@ class InvoiceController extends BaseController * @param \App\Models\Invoice $invoice The invoice * * @return \Illuminate\Http\Response - */ + * + * + * @OA\Put( + * path="/api/v1/invoices/{id}", + * operationId="updateInvoice", + * tags={"invoices"}, + * summary="Updates an invoice", + * description="Handles the updating of an invoice by id", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Parameter( + * name="id", + * in="path", + * description="The Invoice Hashed ID", + * example="D2J234DFA", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Response( + * response=200, + * description="Returns the invoice object", + * @OA\Header(header="X-API-TOKEN", ref="#/components/headers/X-API-TOKEN"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/Invoice"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * + */ public function update(UpdateInvoiceRequest $request, Invoice $invoice) { @@ -177,6 +408,48 @@ class InvoiceController extends BaseController * @param \App\Models\Invoice $invoice * * @return \Illuminate\Http\Response + * + * @OA\Delete( + * path="/api/v1/invoices/{id}", + * operationId="deleteInvoice", + * tags={"invoices"}, + * summary="Deletes a invoice", + * description="Handles the deletion of an invoice by id", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Parameter( + * name="id", + * in="path", + * description="The Invoice Hashed ID", + * example="D2J234DFA", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Response( + * response=200, + * description="Returns a HTTP status", + * @OA\Header(header="X-API-TOKEN", ref="#/components/headers/X-API-TOKEN"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * */ public function destroy(DestroyInvoiceRequest $request, Invoice $invoice) { @@ -191,6 +464,53 @@ class InvoiceController extends BaseController * Perform bulk actions on the list view * * @return Collection + * + * @OA\Post( + * path="/api/v1/invoices/bulk", + * operationId="bulkInvoices", + * tags={"invoices"}, + * summary="Performs bulk actions on an array of invoices", + * description="", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/index"), + * @OA\RequestBody( + * description="User credentials", + * required=true, + * @OA\MediaType( + * mediaType="application/json", + * @OA\Schema( + * type="array", + * @OA\Items( + * type="integer", + * description="Array of hashed IDs to be bulk 'actioned", + * example="[0,1,2,3]", + * ), + * ) + * ) + * ), + * @OA\Response( + * response=200, + * description="The Company User response", + * @OA\Header(header="X-API-TOKEN", ref="#/components/headers/X-API-TOKEN"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/CompanyUser"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * */ public function bulk() { @@ -213,6 +533,73 @@ class InvoiceController extends BaseController } + /** + * + * @OA\Get( + * path="/api/v1/invoices/{id}/{action}", + * operationId="actionInvoice", + * tags={"invoices"}, + * summary="Performs a custom action on an invoice", + * description="Performs a custom action on an invoice. + + The current range of actions are as follows + - clone_to_invoice + - clone_to_quote + - history + - delivery_note + - mark_paid + - download + - archive + - delete + - email", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/include"), + * @OA\Parameter( + * name="id", + * in="path", + * description="The Invoice Hashed ID", + * example="D2J234DFA", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Parameter( + * name="action", + * in="path", + * description="The action string to be performed", + * example="clone_to_quote", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Response( + * response=200, + * description="Returns the invoice object", + * @OA\Header(header="X-API-TOKEN", ref="#/components/headers/X-API-TOKEN"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/Invoice"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + * + */ public function action(ActionInvoiceRequest $request, Invoice $invoice, $action) { diff --git a/app/Http/Controllers/OpenAPI/InvoiceSchema.php b/app/Http/Controllers/OpenAPI/InvoiceSchema.php new file mode 100644 index 0000000000..698aa5ceb2 --- /dev/null +++ b/app/Http/Controllers/OpenAPI/InvoiceSchema.php @@ -0,0 +1,43 @@ +