mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 00:50:54 -04:00
API changes for Zapier
This commit is contained in:
parent
fc0a7cfbf0
commit
e36d23fcdc
@ -225,4 +225,15 @@ class BaseAPIController extends Controller
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function fileReponse($name, $data)
|
||||
{
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Length: ' . strlen($data));
|
||||
header('Content-disposition: attachment; filename="' . $name . '"');
|
||||
header('Cache-Control: public, must-revalidate, max-age=0');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -184,6 +184,10 @@ class InvoiceApiController extends BaseAPIController
|
||||
->with('client', 'invoice_items', 'invitations')
|
||||
->first();
|
||||
|
||||
if (isset($data['download_invoice']) && boolval($data['download_invoice'])) {
|
||||
return $this->fileReponse($invoice->getFileName(), $invoice->getPDFString());
|
||||
}
|
||||
|
||||
return $this->itemResponse($invoice);
|
||||
}
|
||||
|
||||
@ -361,14 +365,7 @@ class InvoiceApiController extends BaseAPIController
|
||||
public function download(InvoiceRequest $request)
|
||||
{
|
||||
$invoice = $request->entity();
|
||||
$pdfString = $invoice->getPDFString();
|
||||
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Length: ' . strlen($pdfString));
|
||||
header('Content-disposition: attachment; filename="' . $invoice->getFileName() . '"');
|
||||
header('Cache-Control: public, must-revalidate, max-age=0');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
return $pdfString;
|
||||
return $this->fileReponse($invoice->getFileName(), $invoice->getPDFString());
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ class PaymentTransformer extends EntityTransformer
|
||||
'is_deleted' => (bool) $payment->is_deleted,
|
||||
'payment_type_id' => (int) $payment->payment_type_id,
|
||||
'invoice_id' => (int) ($this->invoice ? $this->invoice->public_id : $payment->invoice->public_id),
|
||||
'invoice_number' => $this->invoice ? $this->invoice->invoice_number : $payment->invoice->invoice_number,
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user