Skip to content

Commit

Permalink
Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
iranl committed Jul 9, 2019
1 parent 9b62945 commit a366c77
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 119 deletions.
21 changes: 0 additions & 21 deletions src/ApiConnectors/ArticleApiConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use PhpTwinfield\Mappers\ArticleMapper;
use PhpTwinfield\Office;
use PhpTwinfield\Request as Request;
use PhpTwinfield\Response\IndividualMappedResponse;
use PhpTwinfield\Response\MappedResponseCollection;
use PhpTwinfield\Response\Response;
use PhpTwinfield\Response\ResponseException;
Expand Down Expand Up @@ -130,26 +129,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa
return [$equal, $returnedObject];
}

/**
* @param HasMessageInterface $returnedObject
* @return IndividualMappedResponse
*/
public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse
{
Assert::IsInstanceOf($returnedObject, Article::class);

$request_article = new Request\Read\Article();
$request_article->setOffice($returnedObject->getOffice())
->setCode($returnedObject->getCode());
$response = $this->sendXmlDocument($request_article);

$mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "article", function(Response $response): Article {
return ArticleMapper::map($response, $this->getConnection());
});

return ($mappedResponseCollection[0]);
}

/**
* List all articles.
*
Expand Down
21 changes: 0 additions & 21 deletions src/ApiConnectors/AssetMethodApiConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use PhpTwinfield\Mappers\AssetMethodMapper;
use PhpTwinfield\Office;
use PhpTwinfield\Request as Request;
use PhpTwinfield\Response\IndividualMappedResponse;
use PhpTwinfield\Response\MappedResponseCollection;
use PhpTwinfield\Response\Response;
use PhpTwinfield\Response\ResponseException;
Expand Down Expand Up @@ -133,26 +132,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa
return [$equal, $returnedObject];
}

/**
* @param HasMessageInterface $returnedObject
* @return IndividualMappedResponse
*/
public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse
{
Assert::IsInstanceOf($returnedObject, AssetMethod::class);

$request_assetMethod = new Request\AssetMethod();
$request_assetMethod->setOffice($returnedObject->getOffice())
->setCode($returnedObject->getCode());
$response = $this->sendXmlDocument($request_assetMethod);

$mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "assetmethod", function(Response $response): AssetMethod {
return AssetMethodMapper::map($response);
});

return ($mappedResponseCollection[0]);
}

/**
* List all asset methods.
*
Expand Down
27 changes: 4 additions & 23 deletions src/ApiConnectors/BaseApiConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,29 +262,10 @@ public function testSentEqualsResponse(HasEqualInterface $apiConnector, array $s
$returnedObject = $testResult[1];

if (!$equal) {
$tempMappedResponse = $apiConnector->sendAll([$returnedObject], true)[0];
$tempReturnedObject = $tempMappedResponse->unwrap();

if ($tempReturnedObject->getResult() == 1) {
$individualMappedResponse = $tempMappedResponse;
$returnedObject = $tempReturnedObject;

$testResult = $apiConnector->testEqual($returnedObject, $sentObjects[$key]);
$equal = $testResult[0];
$returnedObject = $testResult[1];

if (!$equal || is_a($returnedObject, \PhpTwinfield\Currency::class)) {
sleep(2);

$tempMappedResponse = $apiConnector->getMappedResponse($returnedObject, $sentObjects[$key]);
$tempReturnedObject = $tempMappedResponse->unwrap();

if ($returnedObject->getResult() == 1) {
$individualMappedResponse = $tempMappedResponse;
$returnedObject = $tempReturnedObject;
}
}
}
$apiConnector->sendAll([$returnedObject], true)[0];
sleep(2);
$sentObjects[$key]->setCode($returnedObject->getCode());
$individualMappedResponse = $apiConnector->sendAll([$sentObjects[$key]], true)[0];
}
}

Expand Down
10 changes: 0 additions & 10 deletions src/ApiConnectors/CurrencyApiConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use PhpTwinfield\Mappers\CurrencyMapper;
use PhpTwinfield\Office;
use PhpTwinfield\Request as Request;
use PhpTwinfield\Response\IndividualMappedResponse;
use PhpTwinfield\Response\MappedResponseCollection;
use PhpTwinfield\Response\Response;
use PhpTwinfield\Response\ResponseException;
Expand Down Expand Up @@ -170,15 +169,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa
return [$equal, $returnedObject];
}

/**
* @param HasMessageInterface $returnedObject
* @return IndividualMappedResponse
*/
public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse
{
return $this->sendAll([$sentObject], true)[0];
}

/**
* List all currencies.
*
Expand Down
3 changes: 0 additions & 3 deletions src/ApiConnectors/HasEqualInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace PhpTwinfield\ApiConnectors;

use PhpTwinfield\HasMessageInterface;
use PhpTwinfield\Response\IndividualMappedResponse;
use PhpTwinfield\Response\MappedResponseCollection;

/**
Expand All @@ -15,6 +14,4 @@ interface HasEqualInterface
public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array;

public function sendAll(array $objects, bool $reSend): MappedResponseCollection;

public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse;
}
21 changes: 0 additions & 21 deletions src/ApiConnectors/RateApiConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use PhpTwinfield\Office;
use PhpTwinfield\Rate;
use PhpTwinfield\Request as Request;
use PhpTwinfield\Response\IndividualMappedResponse;
use PhpTwinfield\Response\MappedResponseCollection;
use PhpTwinfield\Response\Response;
use PhpTwinfield\Response\ResponseException;
Expand Down Expand Up @@ -131,26 +130,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa
return [$equal, $returnedObject];
}

/**
* @param HasMessageInterface $returnedObject
* @return IndividualMappedResponse
*/
public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse
{
Assert::IsInstanceOf($returnedObject, Rate::class);

$request_rate = new Request\Read\Rate();
$request_rate->setOffice($returnedObject->getOffice())
->setCode($returnedObject->getCode());
$response = $this->sendXmlDocument($request_rate);

$mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "projectrate", function(Response $response): Rate {
return RateMapper::map($response);
});

return ($mappedResponseCollection[0]);
}

/**
* List all rates.
*
Expand Down
20 changes: 0 additions & 20 deletions src/ApiConnectors/VatCodeApiConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use PhpTwinfield\Mappers\VatCodeMapper;
use PhpTwinfield\Office;
use PhpTwinfield\Request as Request;
use PhpTwinfield\Response\IndividualMappedResponse;
use PhpTwinfield\Response\MappedResponseCollection;
use PhpTwinfield\Response\Response;
use PhpTwinfield\Response\ResponseException;
Expand Down Expand Up @@ -132,25 +131,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa
return [$equal, $returnedObject];
}

/**
* @param HasMessageInterface $returnedObject
* @return IndividualMappedResponse
*/
public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse
{
Assert::IsInstanceOf($returnedObject, VatCode::class);

$request_vatCode = new Request\Read\VatCode();
$request_vatCode->setCode($returnedObject->getCode());
$response = $this->sendXmlDocument($request_vatCode);

$mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "vat", function(Response $response): VatCode {
return VatCodeMapper::map($response);
});

return ($mappedResponseCollection[0]);
}

/**
* List all VAT codes.
*
Expand Down

0 comments on commit a366c77

Please sign in to comment.