From 483953d983142761868aed7fa4d9de54a5e71eb9 Mon Sep 17 00:00:00 2001 From: StijnVrolijk Date: Tue, 19 Nov 2019 11:49:49 +0100 Subject: [PATCH] Add a payment method property --- Invoice/Invoice.php | 21 ++++++++++++++++++++- tests/index.php | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Invoice/Invoice.php b/Invoice/Invoice.php index 343ed10..0b915de 100644 --- a/Invoice/Invoice.php +++ b/Invoice/Invoice.php @@ -19,7 +19,7 @@ class Invoice /** * @var string */ - protected $iid, $state, $description, $shownRemark; + protected $iid, $state, $paymentMethod, $description, $shownRemark; /** * @var \DateTime @@ -288,6 +288,23 @@ public function getState() return $this->state; } + /** + * @param string $paymentMethod Possible payment methods are: + * not_paid, cheque, transfer, bankcontact, cash, direct_debit and paid + */ + public function setPaymentMethod($paymentMethod) + { + $this->paymentMethod = $paymentMethod; + } + + /** + * @return string + */ + public function getPaymentMethod() + { + return $this->paymentMethod; + } + /** * @param float $total */ @@ -391,6 +408,7 @@ public static function initializeWithRawData($data) if(isset($data['client_id'])) $item->setClientId($data['client_id']); if(isset($data['iid'])) $item->setIid($data['iid']); if(isset($data['state'])) $item->setState($data['state']); + if(isset($data['payment_method'])) $item->setPaymentMethod($data['payment_method']); if(isset($data['generated'])) $item->setGenerated(new \DateTime('@' . strtotime($data['generated']))); if(isset($data['description'])) $item->setDescription($data['description']); if(isset($data['shown_remark'])) $item->setShownRemark($data['shown_remark']); @@ -433,6 +451,7 @@ public function toArray($forApi = false) $data = array(); $data['client_id'] = $this->getClientId(); $data['state'] = $this->getState(); + $data['payment_method'] = $this->getPaymentMethod(); $data['description'] = $this->getDescription(); $data['shown_remark'] = $this->getShownRemark(); $discount = $this->getDiscount(); diff --git a/tests/index.php b/tests/index.php index 64bb510..30b3c69 100644 --- a/tests/index.php +++ b/tests/index.php @@ -55,6 +55,7 @@ $invoice->setDescription('description'); $invoice->setShownRemark('shown_remark'); $invoice->setState('created'); +$invoice->setPaymentMethod('not_paid'); try { // $response = $factr->accountApiToken(USERNAME, PASSWORD);