Skip to content

Commit

Permalink
Tested version
Browse files Browse the repository at this point in the history
  • Loading branch information
lashnev committed Sep 19, 2018
1 parent c90b2d9 commit eafbc15
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/services/ComplexRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ class ComplexRequest extends BaseServiceRequest
protected $documentType;
/** @var int */
protected $TaxMode;
/** @var int */
private $phone;
/** @var string */
private $email;
/** @var string */
protected $Place;
/** @var Line[] */
protected $lines;
/** @var string */
protected $Password;
/** @var float */
Expand All @@ -45,6 +39,12 @@ class ComplexRequest extends BaseServiceRequest
protected $Address;
/** @var string */
protected $Terminal;
/** @var int */
private $phone;
/** @var string */
private $email;
/** @var Line[] */
private $lines;

/**
* @inheritdoc
Expand Down Expand Up @@ -213,6 +213,9 @@ public function getParameters()
$params = parent::getParameters();
$params['PhoneOrEmail'] = $this->email ? $this->email : $this->phone;
$params['FullResponse'] = true;
foreach($this->lines as $line){
$params['Lines'][] = $line->getParameters();
}
return $params;
}
}
2 changes: 2 additions & 0 deletions tests/integration/ComplexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Platron\Starrys\handbooks\DocumentTypes;
use Platron\Starrys\handbooks\PayAttributeTypes;
use Platron\Starrys\handbooks\Taxes;
use Platron\Starrys\handbooks\TaxModes;
use Platron\Starrys\services\ComplexRequest;
use Platron\Starrys\services\ComplexResponse;

Expand All @@ -20,6 +21,7 @@ class ComplexTest extends IntegrationTestBase
public function testComplex()
{
$client = new PostClient($this->starrysApiUrl, $this->secretKeyPath, $this->certPath);
$client->setLogger(new TestLogger());
$complexRequest = $this->createComplexRequest();
$response = new ComplexResponse($client->sendRequest($complexRequest));
$this->assertTrue($response->isValid());
Expand Down
59 changes: 59 additions & 0 deletions tests/integration/TestLogger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Platron\Starrys\tests\integration;

use Psr\Log\LoggerInterface;

class TestLogger implements LoggerInterface
{
public function emergency($message, array $context = array())
{
$this->logToFile($message);
}

public function alert($message, array $context = array())
{
$this->logToFile($message);
}

public function critical($message, array $context = array())
{
$this->logToFile($message);
}

public function error($message, array $context = array())
{
$this->logToFile($message);
}

public function warning($message, array $context = array())
{
$this->logToFile($message);
}

public function notice($message, array $context = array())
{
$this->logToFile($message);
}

public function info($message, array $context = array())
{
$this->logToFile($message);
}

public function debug($message, array $context = array())
{
$this->logToFile($message);
}

public function log($level, $message, array $context = array())
{
$this->logToFile($message);
}

private function logToFile($message)
{
$preparedString = date('Y-m-d H:i:s') . '; ' . $message . PHP_EOL;
file_put_contents(__DIR__ . '/logs/' . date('Y-m-d') . '.log', $preparedString, FILE_APPEND);
}
}

0 comments on commit eafbc15

Please sign in to comment.