From e3ce94dafa2738c7453f3ac494ecf0c02f9ff655 Mon Sep 17 00:00:00 2001 From: Dominik Nguyen Date: Mon, 9 Sep 2019 10:30:20 +0200 Subject: [PATCH] Update README.md --- README.md | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2a93240..6331ecf 100644 --- a/README.md +++ b/README.md @@ -65,11 +65,37 @@ return [ ## Examples -### Create Subject +### Create Subject, Create Invoice, Send Invoice ```php -\Fakturoid::createSubject(array('name' => 'Firma s.r.o.', 'email' => 'aloha@pokus.cz')); +use Fakturoid; +use Fakturoid\Exception; + +try { + // create subject + $subject = Fakturoid::createSubject(array( + 'name' => 'Firma s.r.o.', + 'email' => 'aloha@pokus.cz' + )); + if ($subject->getBody()) { + $subject = $subject->getBody(); + + // create invoice with lines + $lines = array(array( + 'name' => 'Big sale', + 'quantity' => 1, + 'unit_price' => 1000 + )); + $invoice = Fakturoid::createInvoice(array('subject_id' => $subject->id, 'lines' => $lines)); + $invoice = $invoice->getBody(); + + // send created invoice + Fakturoid::fireInvoice($invoice->id, 'deliver'); + } +} catch (Exception $e) { + dd($e->getCode() . ": " . $e->getMessage()); +} ```