From be6e8e5b7a19e3be45d06ad64e95474cac67b9af Mon Sep 17 00:00:00 2001 From: Michiel Thalen Date: Tue, 31 Mar 2015 03:51:37 +0200 Subject: [PATCH] added testmode added models for responses --- src/NextTalent/AcumulusPhp/InvoiceBuilder.php | 6 +++++ .../Models/Response/AbstractResponse.php | 25 ++++++++++++++++++ .../AcumulusPhp/Models/Response/Error.php | 25 ++++++++++++++++++ .../AcumulusPhp/Models/Response/Invoice.php | 26 +++++++++++++++++++ .../AcumulusPhp/Models/Response/Warning.php | 25 ++++++++++++++++++ .../AcumulusPhp/Parsers/InvoiceParser.php | 5 ++-- src/NextTalent/AcumulusPhp/ResponseParser.php | 2 +- src/NextTalent/AcumulusPhp/XmlBuilder.php | 3 +++ 8 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 src/NextTalent/AcumulusPhp/Models/Response/AbstractResponse.php create mode 100644 src/NextTalent/AcumulusPhp/Models/Response/Error.php create mode 100644 src/NextTalent/AcumulusPhp/Models/Response/Invoice.php create mode 100644 src/NextTalent/AcumulusPhp/Models/Response/Warning.php diff --git a/src/NextTalent/AcumulusPhp/InvoiceBuilder.php b/src/NextTalent/AcumulusPhp/InvoiceBuilder.php index 2172f22..c17d822 100644 --- a/src/NextTalent/AcumulusPhp/InvoiceBuilder.php +++ b/src/NextTalent/AcumulusPhp/InvoiceBuilder.php @@ -146,4 +146,10 @@ public function setMailAsPdf(EmailAsPdf $email) { $this->emailAsPdf = $email; } + /** + * @return InvoiceLine[] + */ + public function getInvoiceLines() { + return $this->invoiceLines; + } } diff --git a/src/NextTalent/AcumulusPhp/Models/Response/AbstractResponse.php b/src/NextTalent/AcumulusPhp/Models/Response/AbstractResponse.php new file mode 100644 index 0000000..884e9dd --- /dev/null +++ b/src/NextTalent/AcumulusPhp/Models/Response/AbstractResponse.php @@ -0,0 +1,25 @@ +entryid = $xml['entryid']; + } + if(isset($xml['token'])) { + $this->token = $xml['token']; + } + if(isset($xml['invoicenumber'])) { + $this->invoicenumber = $xml['invoicenumber']; + } + if(isset($xml['paymentstatus'])) { + $this->invoicenumber = $xml['paymentstatus']; + } + + } + +} \ No newline at end of file diff --git a/src/NextTalent/AcumulusPhp/Models/Response/Warning.php b/src/NextTalent/AcumulusPhp/Models/Response/Warning.php new file mode 100644 index 0000000..953f764 --- /dev/null +++ b/src/NextTalent/AcumulusPhp/Models/Response/Warning.php @@ -0,0 +1,25 @@ +invoice; + return new Invoice($this->invoice); } } diff --git a/src/NextTalent/AcumulusPhp/ResponseParser.php b/src/NextTalent/AcumulusPhp/ResponseParser.php index ecfc609..eab04d8 100644 --- a/src/NextTalent/AcumulusPhp/ResponseParser.php +++ b/src/NextTalent/AcumulusPhp/ResponseParser.php @@ -46,7 +46,7 @@ public function parse() if ($response['status'] == 1) { throw new AcumulusException($response['errors']['error']['message']); } elseif ($response['status'] > 1) { - throw new AcumulusException($response['warnings']['warning']['message']); + throw new AcumulusException(current($response['warnings']['warning'])['message']); } // Get the key from the first element from the response diff --git a/src/NextTalent/AcumulusPhp/XmlBuilder.php b/src/NextTalent/AcumulusPhp/XmlBuilder.php index 536b281..52355a9 100644 --- a/src/NextTalent/AcumulusPhp/XmlBuilder.php +++ b/src/NextTalent/AcumulusPhp/XmlBuilder.php @@ -30,6 +30,9 @@ public function buildXML($xmlPayload, $config) $xml = ''; $xml .= ''; + if(!empty($config['testmode'])) { + $xml .= '1'; + } $xml .= 'json'; $xml .= ''; $xml .= sprintf('%d', $config['contractcode']);