From 8d6fcd3d446203a2a08bee90ff100761f442f8f0 Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Thu, 6 Feb 2014 16:06:46 +0100 Subject: [PATCH] Helper methods for PDF attachments. Methods to get the existing attachment and to upload a new attachment. --- Billogram/Api/Objects/BillogramObject.php | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Billogram/Api/Objects/BillogramObject.php b/Billogram/Api/Objects/BillogramObject.php index 6128c16..2cbd703 100644 --- a/Billogram/Api/Objects/BillogramObject.php +++ b/Billogram/Api/Objects/BillogramObject.php @@ -198,4 +198,31 @@ public function getInvoicePdf($letterId = null, $invoiceNo = null) return base64_decode($response->data->content); } + + /** + * Returns the PDF-file content for the billogram's attachment. + * + **/ + public function getAttachmentPdf() + { + $response = $this->api->get( + $this->url() . '/attachment.pdf', + null, + 'application/json' + ); + + return base64_decode($response->data->content); + } + + /** + * Attach a PDF to the billogram. + * + **/ + public function attachPdf($filepath) + { + $content = file_get_contents($filepath); + $filename = basename($filepath); + + return $this->performEvent('attach', array('filename' => $filename, 'content' => base64_encode('asdf'))); + } }