Skip to content

Commit 77b53da

Browse files
committed
Fix client api version to 2.4
1 parent 3c3a255 commit 77b53da

9 files changed

+77
-10
lines changed

src/CategoryLookup.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/**
2222
* @template InputType of array
2323
* @template OutputType of InputType|array
24+
*
2425
* @implements TransformerInterface<InputType, OutputType>
2526
*/
2627
final readonly class CategoryLookup implements TransformerInterface
@@ -48,6 +49,7 @@ private function rejectErrorResponse(ErrorResponse $response): RejectionResultBu
4849
'method' => 'get',
4950
],
5051
);
52+
5153
return new RejectionResultBucket($response->getMessage(), null);
5254
}
5355

@@ -63,24 +65,26 @@ private function rejectInvalidResponse(): RejectionResultBucketInterface
6365
'method' => 'get',
6466
],
6567
);
68+
6669
return new RejectionResultBucket($message, null);
6770
}
6871

6972
/**
7073
* @param InputType $line
74+
*
7175
* @return OutputType
7276
*/
7377
public function passThrough(array $line): array
7478
{
75-
/** @var OutputType $line */
79+
/* @var OutputType $line */
7680
return $line;
7781
}
7882

7983
public function transform(): \Generator
8084
{
8185
$line = yield new EmptyResultBucket();
8286
while (true) {
83-
if ($line === null) {
87+
if (null === $line) {
8488
$line = yield new EmptyResultBucket();
8589
continue;
8690
}
@@ -154,6 +158,7 @@ public function transform(): \Generator
154158
$exception,
155159
$this->passThrough($line),
156160
);
161+
157162
return;
158163
}
159164

src/CustomerExtractor.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function __construct(
3333

3434
/**
3535
* @param array<string,string> $parameters
36+
*
3637
* @return array<string,string>
3738
*/
3839
private function applyPagination(array $parameters, int $currentPage, int $pageSize): array
@@ -46,6 +47,7 @@ private function applyPagination(array $parameters, int $currentPage, int $pageS
4647

4748
/**
4849
* @param array<string,string> $parameters
50+
*
4951
* @return RejectionResultBucketInterface<CustomerDataCustomerInterface>
5052
*/
5153
private function rejectErrorResponse(ErrorResponse $response, array $parameters, int $currentPage): RejectionResultBucketInterface
@@ -60,11 +62,13 @@ private function rejectErrorResponse(ErrorResponse $response, array $parameters,
6062
'pageSize' => $this->pageSize,
6163
],
6264
);
65+
6366
return new RejectionResultBucket($response->getMessage(), null);
6467
}
6568

6669
/**
6770
* @param array<string,string> $parameters
71+
*
6872
* @return RejectionResultBucketInterface<CustomerDataCustomerInterface>
6973
*/
7074
private function rejectInvalidResponse(array $parameters, int $currentPage): RejectionResultBucketInterface
@@ -79,6 +83,7 @@ private function rejectInvalidResponse(array $parameters, int $currentPage): Rej
7983
'pageSize' => $this->pageSize,
8084
],
8185
);
86+
8287
return new RejectionResultBucket($message, null);
8388
}
8489

@@ -92,10 +97,12 @@ public function extract(): iterable
9297
);
9398
if ($response instanceof ErrorResponse) {
9499
yield $this->rejectErrorResponse($response, $parameters, $currentPage);
100+
95101
return;
96102
}
97103
if (!$response instanceof CustomerDataCustomerSearchResultsInterface) {
98104
yield $this->rejectInvalidResponse($parameters, $currentPage);
105+
99106
return;
100107
}
101108
$pageCount = (int) ceil($response->getTotalCount() / $this->pageSize);
@@ -108,10 +115,12 @@ public function extract(): iterable
108115
);
109116
if ($response instanceof ErrorResponse) {
110117
yield $this->rejectErrorResponse($response, $parameters, $currentPage);
118+
111119
return;
112120
}
113121
if (!$response instanceof CustomerDataCustomerSearchResultsInterface) {
114122
yield $this->rejectInvalidResponse($parameters, $currentPage);
123+
115124
return;
116125
}
117126

@@ -133,34 +142,39 @@ public function extract(): iterable
133142
'There are some network difficulties. We could not properly connect to the Magento API. There is nothing we could no to fix this currently. Please contact the Magento administrator.',
134143
$exception,
135144
);
145+
136146
return;
137147
} catch (GetV1CustomersSearchUnauthorizedException $exception) {
138148
$this->logger->warning($exception->getMessage(), ['exception' => $exception]);
139149
yield new RejectionResultBucket(
140150
'The source API responded we are not authorized to access this resource. Aborting. Please check the credentials you provided.',
141151
$exception,
142152
);
153+
143154
return;
144155
} catch (GetV1CustomersSearchInternalServerErrorException $exception) {
145156
$this->logger->error($exception->getMessage(), ['exception' => $exception]);
146157
yield new RejectionResultBucket(
147158
'The source API responded it is currently unavailable due to an internal error. Aborting. Please check the availability of the source API.',
148159
$exception,
149160
);
161+
150162
return;
151163
} catch (UnexpectedStatusCodeException $exception) {
152164
$this->logger->critical($exception->getMessage(), ['exception' => $exception]);
153165
yield new RejectionResultBucket(
154166
'The source API responded with a status we did not expect. Aborting. Please check the availability of the source API and if there are no rate limiting or redirections active.',
155167
$exception,
156168
);
169+
157170
return;
158171
} catch (\Throwable $exception) {
159172
$this->logger->emergency($exception->getMessage(), ['exception' => $exception]);
160173
yield new RejectionResultBucket(
161174
'The client failed critically. Aborting. Please contact customer support or your system administrator.',
162175
$exception,
163176
);
177+
164178
return;
165179
}
166180
}

src/Filter/ScalarFilter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ final class ScalarFilter implements FilterInterface, \IteratorAggregate
1212
public function __construct(
1313
public string $field,
1414
public string $conditionType,
15-
public bool|int|float|string|\DateTimeInterface $value,
16-
) {}
15+
public bool|\DateTimeInterface|float|int|string $value,
16+
) {
17+
}
1718

1819
/**
1920
* @return \Traversable<int,array{"field":string,"value":string,"conditionType":string}>

src/FilterGroup.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ public function withFilter(FilterInterface $filter): self
2121

2222
public function withFilters(FilterInterface ...$filters): self
2323
{
24-
array_push($this->filters, ...$filters);
24+
array_push($this->filters, ...$filters);
2525

2626
return $this;
2727
}
2828

2929
/**
3030
* @param array<string,string> $parameters
31+
*
3132
* @return \Traversable<int,array<string,string>>
3233
*/
3334
public function walkFilters(array $parameters, int $groupIndex = 0): \Traversable
@@ -41,6 +42,7 @@ public function walkFilters(array $parameters, int $groupIndex = 0): \Traversabl
4142

4243
/**
4344
* @param array<string,string> $parameters
45+
*
4446
* @return \Traversable<int,array<string,string>>
4547
*/
4648
private function buildFilters(array $parameters, int $groupIndex, int $filterIndex, FilterInterface $first, FilterInterface ...$next): \Traversable

src/InvoiceExtractor.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function __construct(
3232

3333
/**
3434
* @param array<string,string> $parameters
35+
*
3536
* @return array<string,string>
3637
*/
3738
private function applyPagination(array $parameters, int $currentPage, int $pageSize): array
@@ -45,6 +46,7 @@ private function applyPagination(array $parameters, int $currentPage, int $pageS
4546

4647
/**
4748
* @param array<string,string> $parameters
49+
*
4850
* @return RejectionResultBucketInterface<SalesDataInvoiceInterface>
4951
*/
5052
private function rejectErrorResponse(ErrorResponse $response, array $parameters, int $currentPage): RejectionResultBucketInterface
@@ -59,11 +61,13 @@ private function rejectErrorResponse(ErrorResponse $response, array $parameters,
5961
'pageSize' => $this->pageSize,
6062
],
6163
);
64+
6265
return new RejectionResultBucket($response->getMessage(), null);
6366
}
6467

6568
/**
6669
* @param array<string,string> $parameters
70+
*
6771
* @return RejectionResultBucketInterface<SalesDataInvoiceInterface>
6872
*/
6973
private function rejectInvalidResponse(array $parameters, int $currentPage): RejectionResultBucketInterface
@@ -78,6 +82,7 @@ private function rejectInvalidResponse(array $parameters, int $currentPage): Rej
7882
'pageSize' => $this->pageSize,
7983
],
8084
);
85+
8186
return new RejectionResultBucket($message, null);
8287
}
8388

@@ -91,10 +96,12 @@ public function extract(): iterable
9196
);
9297
if ($response instanceof ErrorResponse) {
9398
yield $this->rejectErrorResponse($response, $parameters, $currentPage);
99+
94100
return;
95101
}
96102
if (!$response instanceof SalesDataInvoiceSearchResultInterface) {
97103
yield $this->rejectInvalidResponse($parameters, $currentPage);
104+
98105
return;
99106
}
100107
$pageCount = (int) ceil($response->getTotalCount() / $this->pageSize);
@@ -107,10 +114,12 @@ public function extract(): iterable
107114
);
108115
if ($response instanceof ErrorResponse) {
109116
yield $this->rejectErrorResponse($response, $parameters, $currentPage);
117+
110118
return;
111119
}
112120
if (!$response instanceof SalesDataInvoiceSearchResultInterface) {
113121
yield $this->rejectInvalidResponse($parameters, $currentPage);
122+
114123
return;
115124
}
116125

@@ -132,27 +141,31 @@ public function extract(): iterable
132141
'There are some network difficulties. We could not properly connect to the Magento API. There is nothing we could no to fix this currently. Please contact the Magento administrator.',
133142
$exception,
134143
);
144+
135145
return;
136146
} catch (GetV1InvoicesUnauthorizedException $exception) {
137147
$this->logger->warning($exception->getMessage(), ['exception' => $exception]);
138148
yield new RejectionResultBucket(
139149
'The source API responded we are not authorized to access this resource. Aborting. Please check the credentials you provided.',
140150
$exception,
141151
);
152+
142153
return;
143154
} catch (UnexpectedStatusCodeException $exception) {
144155
$this->logger->critical($exception->getMessage(), ['exception' => $exception]);
145156
yield new RejectionResultBucket(
146157
'The source API responded with a status we did not expect. Aborting. Please check the availability of the source API and if there are no rate limiting or redirections active.',
147158
$exception,
148159
);
160+
149161
return;
150162
} catch (\Throwable $exception) {
151163
$this->logger->emergency($exception->getMessage(), ['exception' => $exception]);
152164
yield new RejectionResultBucket(
153165
'The client failed critically. Aborting. Please contact customer support or your system administrator.',
154166
$exception,
155167
);
168+
156169
return;
157170
}
158171
}

src/OrderExtractor.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function __construct(
3232

3333
/**
3434
* @param array<string,string> $parameters
35+
*
3536
* @return array<string,string>
3637
*/
3738
private function applyPagination(array $parameters, int $currentPage, int $pageSize): array
@@ -45,6 +46,7 @@ private function applyPagination(array $parameters, int $currentPage, int $pageS
4546

4647
/**
4748
* @param array<string,string> $parameters
49+
*
4850
* @return RejectionResultBucketInterface<SalesDataOrderInterface>
4951
*/
5052
private function rejectErrorResponse(ErrorResponse $response, array $parameters, int $currentPage): RejectionResultBucketInterface
@@ -59,11 +61,13 @@ private function rejectErrorResponse(ErrorResponse $response, array $parameters,
5961
'pageSize' => $this->pageSize,
6062
],
6163
);
64+
6265
return new RejectionResultBucket($response->getMessage(), null);
6366
}
6467

6568
/**
6669
* @param array<string,string> $parameters
70+
*
6771
* @return RejectionResultBucketInterface<SalesDataOrderInterface>
6872
*/
6973
private function rejectInvalidResponse(array $parameters, int $currentPage): RejectionResultBucketInterface
@@ -78,6 +82,7 @@ private function rejectInvalidResponse(array $parameters, int $currentPage): Rej
7882
'pageSize' => $this->pageSize,
7983
],
8084
);
85+
8186
return new RejectionResultBucket($message, null);
8287
}
8388

@@ -91,10 +96,12 @@ public function extract(): iterable
9196
);
9297
if ($response instanceof ErrorResponse) {
9398
yield $this->rejectErrorResponse($response, $parameters, $currentPage);
99+
94100
return;
95101
}
96102
if (!$response instanceof SalesDataOrderSearchResultInterface) {
97103
yield $this->rejectInvalidResponse($parameters, $currentPage);
104+
98105
return;
99106
}
100107
$pageCount = (int) ceil($response->getTotalCount() / $this->pageSize);
@@ -107,10 +114,12 @@ public function extract(): iterable
107114
);
108115
if ($response instanceof ErrorResponse) {
109116
yield $this->rejectErrorResponse($response, $parameters, $currentPage);
117+
110118
return;
111119
}
112120
if (!$response instanceof SalesDataOrderSearchResultInterface) {
113121
yield $this->rejectInvalidResponse($parameters, $currentPage);
122+
114123
return;
115124
}
116125

@@ -132,27 +141,31 @@ public function extract(): iterable
132141
'There are some network difficulties. We could not properly connect to the Magento API. There is nothing we could no to fix this currently. Please contact the Magento administrator.',
133142
$exception,
134143
);
144+
135145
return;
136146
} catch (GetV1OrdersUnauthorizedException $exception) {
137147
$this->logger->warning($exception->getMessage(), ['exception' => $exception]);
138148
yield new RejectionResultBucket(
139149
'The source API responded we are not authorized to access this resource. Aborting. Please check the credentials you provided.',
140150
$exception,
141151
);
152+
142153
return;
143154
} catch (UnexpectedStatusCodeException $exception) {
144155
$this->logger->critical($exception->getMessage(), ['exception' => $exception]);
145156
yield new RejectionResultBucket(
146157
'The source API responded with a status we did not expect. Aborting. Please check the availability of the source API and if there are no rate limiting or redirections active.',
147158
$exception,
148159
);
160+
149161
return;
150162
} catch (\Throwable $exception) {
151163
$this->logger->emergency($exception->getMessage(), ['exception' => $exception]);
152164
yield new RejectionResultBucket(
153165
'The client failed critically. Aborting. Please contact customer support or your system administrator.',
154166
$exception,
155167
);
168+
156169
return;
157170
}
158171
}

0 commit comments

Comments
 (0)