Skip to content

Commit d32cc33

Browse files
committed
fix type phpstan, manage api return's cursor with the array of parameters
1 parent 5adecfa commit d32cc33

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/CategoryLookup.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Kiboko\Component\Flow\Magento2;
66

77
use Kiboko\Component\Bucket\AcceptanceResultBucket;
8+
use Kiboko\Component\Bucket\EmptyResultBucket;
89
use Kiboko\Component\Bucket\RejectionResultBucket;
910
use Kiboko\Contract\Mapping\CompiledMapperInterface;
1011
use Kiboko\Contract\Pipeline\TransformerInterface;
@@ -24,7 +25,7 @@ public function __construct(
2425

2526
public function transform(): \Generator
2627
{
27-
$line = yield;
28+
$line = yield new EmptyResultBucket();
2829
while (true) {
2930
if (null === $line[$this->mappingField]) {
3031
$line = yield new AcceptanceResultBucket($line);

src/Lookup.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Kiboko\Component\Bucket\AcceptanceResultBucket;
88
use Kiboko\Component\Bucket\RejectionResultBucket;
9+
use Kiboko\Component\Bucket\EmptyResultBucket;
910
use Kiboko\Contract\Mapping\CompiledMapperInterface;
1011
use Kiboko\Contract\Pipeline\TransformerInterface;
1112
use Psr\SimpleCache\CacheInterface;
@@ -25,7 +26,7 @@ public function __construct(
2526

2627
public function transform(): \Generator
2728
{
28-
$line = yield;
29+
$line = yield new EmptyResultBucket();
2930
while (true) {
3031
if (null === $line[$this->mappingField]) {
3132
$line = yield new AcceptanceResultBucket($line);

src/OrderExtractor.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
) {
2727
}
2828

29-
private function compileQueryParameters(int $currentPage = 1)
29+
private function compileQueryParameters(int $currentPage = 1): array
3030
{
3131
$parameters = $this->queryParameters;
3232
$parameters['searchCriteria[currentPage]'] = $currentPage;
@@ -37,7 +37,7 @@ private function compileQueryParameters(int $currentPage = 1)
3737
return array_merge($parameters, ...$filters);
3838
}
3939

40-
private function compileQueryLongParameters()
40+
private function compileQueryLongParameters(): array
4141
{
4242
$filters = array_map(fn (FilterGroup $item, int $key) => $item->compileLongFilters($key), $this->filters, array_keys($this->filters));
4343

@@ -96,8 +96,9 @@ public function extract(): iterable
9696
$currentPage = 1;
9797
$pageCount = ceil($response->getTotalCount() / $this->pageSize);
9898
while ($currentPage++ < $pageCount) {
99+
$finalQueryParameter['searchCriteria[currentPage]'] = $currentPage;
99100
$response = $this->client->salesOrderRepositoryV1GetListGet(
100-
queryParameters: $this->compileQueryParameters($currentPage),
101+
queryParameters: $finalQueryParameter,
101102
);
102103

103104
yield $this->processResponse($response);
@@ -108,7 +109,7 @@ public function extract(): iterable
108109
yield new RejectionResultBucket([
109110
'path' => 'order',
110111
'method' => 'get',
111-
'queryParameters' => $this->compileQueryParameters(),
112+
'queryParameters' => $this->generateFinalQueryParameters($this->compileQueryParameters(), $this->compileQueryLongParameters()),
112113
]);
113114
} catch (\Exception $exception) {
114115
$this->logger->critical($exception->getMessage(), ['exception' => $exception]);

0 commit comments

Comments
 (0)