Skip to content

Commit

Permalink
added testmode
Browse files Browse the repository at this point in the history
added models for responses
  • Loading branch information
chielsen committed Mar 31, 2015
1 parent 7156761 commit be6e8e5
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/NextTalent/AcumulusPhp/InvoiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,10 @@ public function setMailAsPdf(EmailAsPdf $email) {
$this->emailAsPdf = $email;
}

/**
* @return InvoiceLine[]
*/
public function getInvoiceLines() {
return $this->invoiceLines;
}
}
25 changes: 25 additions & 0 deletions src/NextTalent/AcumulusPhp/Models/Response/AbstractResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Created by PhpStorm.
* User: mthal_000
* Date: 3/30/2015
* Time: 6:02 AM
*/

namespace NextTalent\AcumulusPhp\Models\Response;


abstract class AbstractResponse {
/**
* @var string
*/
public $status;
/**
* @var Errrors[]
*/
public $errors;
/**
* @var Warning[]
*/
public $warnings;
}
25 changes: 25 additions & 0 deletions src/NextTalent/AcumulusPhp/Models/Response/Error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Created by PhpStorm.
* User: mthal_000
* Date: 3/30/2015
* Time: 6:03 AM
*/

namespace NextTalent\AcumulusPhp\Models\Response;


class Warning {
/**
* @var string
*/
public $code;
/**
* @var string
*/
public $codetage;
/**
* @var string
*/
public $message;
}
26 changes: 26 additions & 0 deletions src/NextTalent/AcumulusPhp/Models/Response/Invoice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
namespace NextTalent\AcumulusPhp\Models\Response;

class Invoice {
public $invoicenumber;
public $token;
public $entryid;
public $paymentstatus;

function __construct($xml) {
if(isset($xml['entryid'])) {
$this->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'];
}

}

}
25 changes: 25 additions & 0 deletions src/NextTalent/AcumulusPhp/Models/Response/Warning.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Created by PhpStorm.
* User: mthal_000
* Date: 3/30/2015
* Time: 6:03 AM
*/

namespace NextTalent\AcumulusPhp\Models\Response;


class Warning {
/**
* @var string
*/
public $code;
/**
* @var string
*/
public $codetage;
/**
* @var string
*/
public $message;
}
5 changes: 3 additions & 2 deletions src/NextTalent/AcumulusPhp/Parsers/InvoiceParser.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

namespace NextTalent\AcumulusPhp\Parsers;
use NextTalent\AcumulusPhp\Models\Response\Invoice;

/**
* Class InvoiceParser
Expand All @@ -18,10 +19,10 @@ public function __construct($invoice)

/**
* Returns array with keys 'invoicenumber', 'token' and 'entryid'
* @return mixed
* @return Invoice
*/
public function parse()
{
return $this->invoice;
return new Invoice($this->invoice);
}
}
2 changes: 1 addition & 1 deletion src/NextTalent/AcumulusPhp/ResponseParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/NextTalent/AcumulusPhp/XmlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public function buildXML($xmlPayload, $config)

$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml .= '<myxml>';
if(!empty($config['testmode'])) {
$xml .= '<testmode>1</testmode>';
}
$xml .= '<format>json</format>';
$xml .= '<contract>';
$xml .= sprintf('<contractcode>%d</contractcode>', $config['contractcode']);
Expand Down

0 comments on commit be6e8e5

Please sign in to comment.