mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Merge pull request #633 from turbo124/master
Added delete invoice functionality to API
This commit is contained in:
commit
78ed0dca97
@ -1,6 +1,7 @@
|
|||||||
<?php namespace App\Http\Controllers;
|
<?php namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use Illuminate\Support\Facades\Request;
|
||||||
use Utils;
|
use Utils;
|
||||||
use Response;
|
use Response;
|
||||||
use Input;
|
use Input;
|
||||||
@ -270,7 +271,27 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
return Response::make($response, $error ? 400 : 200, $headers);
|
return Response::make($response, $error ? 400 : 200, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SWG\Put(
|
||||||
|
* path="/invoices",
|
||||||
|
* tags={"invoice"},
|
||||||
|
* summary="Update an invoice",
|
||||||
|
* @SWG\Parameter(
|
||||||
|
* in="body",
|
||||||
|
* name="body",
|
||||||
|
* @SWG\Schema(ref="#/definitions/Invoice")
|
||||||
|
* ),
|
||||||
|
* @SWG\Response(
|
||||||
|
* response=200,
|
||||||
|
* description="Update invoice",
|
||||||
|
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice"))
|
||||||
|
* ),
|
||||||
|
* @SWG\Response(
|
||||||
|
* response="default",
|
||||||
|
* description="an ""unexpected"" error"
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*/
|
||||||
public function update(UpdateInvoiceRequest $request, $publicId)
|
public function update(UpdateInvoiceRequest $request, $publicId)
|
||||||
{
|
{
|
||||||
if ($request->action == ACTION_ARCHIVE) {
|
if ($request->action == ACTION_ARCHIVE) {
|
||||||
@ -297,4 +318,41 @@ class InvoiceApiController extends BaseAPIController
|
|||||||
|
|
||||||
return $this->response($data);
|
return $this->response($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SWG\Delete(
|
||||||
|
* path="/invoices",
|
||||||
|
* tags={"invoice"},
|
||||||
|
* summary="Delete an invoice",
|
||||||
|
* @SWG\Parameter(
|
||||||
|
* in="body",
|
||||||
|
* name="body",
|
||||||
|
* @SWG\Schema(ref="#/definitions/Invoice")
|
||||||
|
* ),
|
||||||
|
* @SWG\Response(
|
||||||
|
* response=200,
|
||||||
|
* description="Delete invoice",
|
||||||
|
* @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Invoice"))
|
||||||
|
* ),
|
||||||
|
* @SWG\Response(
|
||||||
|
* response="default",
|
||||||
|
* description="an ""unexpected"" error"
|
||||||
|
* )
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function destroy($publicId)
|
||||||
|
{
|
||||||
|
$data['public_id'] = $publicId;
|
||||||
|
$invoice = Invoice::scope($publicId)->firstOrFail();
|
||||||
|
|
||||||
|
$this->invoiceRepo->delete($invoice);
|
||||||
|
|
||||||
|
$transformer = new InvoiceTransformer(\Auth::user()->account, Input::get('serializer'));
|
||||||
|
$data = $this->createItem($invoice, $transformer, 'invoice');
|
||||||
|
|
||||||
|
return $this->response($data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user