11
11
use Fastbolt \EntityImporter \EntityImporterDefinition ;
12
12
use Fastbolt \EntityImporter \Reader \Api \PagePaginationStrategy ;
13
13
use Fastbolt \EntityImporter \Reader \Api \PaginationStrategy ;
14
+ use Fastbolt \EntityImporter \Types \ImportSourceDefinition \Api ;
14
15
use Fastbolt \EntityImporter \Types \ImportSourceDefinition \ImportSourceDefinition ;
15
16
use GuzzleHttp \Client ;
16
17
use GuzzleHttp \Exception \RequestException ;
@@ -29,7 +30,7 @@ class ApiReader implements ReaderInterface
29
30
30
31
private EntityImporterDefinition $ importerDefinition ;
31
32
32
- private ImportSourceDefinition $ importSourceDefinition ;
33
+ private ImportSourceDefinition | Api $ importSourceDefinition ;
33
34
34
35
private array $ options ;
35
36
@@ -54,9 +55,12 @@ public function __construct(
54
55
) {
55
56
$ this ->clientFactory = $ clientFactory ;
56
57
$ this ->importerDefinition = $ importerDefinition ;
57
- $ this ->importSourceDefinition = $ importerDefinition ->getImportSourceDefinition ();
58
58
$ this ->options = $ options ;
59
59
60
+ /** @var Api $apiTmp */
61
+ $ apiTmp = $ importerDefinition ->getImportSourceDefinition ();
62
+ $ this ->importSourceDefinition = $ apiTmp ;
63
+
60
64
Assert::keyExists ($ this ->options , 'api_key ' );
61
65
62
66
if (!isset ($ this ->options ['pagination_strategy ' ])) {
@@ -120,23 +124,26 @@ public function valid(): bool
120
124
*/
121
125
private function loadBulkData (int $ offset ): void
122
126
{
127
+ /** @var Api $importSourceDefinition */
128
+ $ importSourceDefinition = $ this ->importSourceDefinition ;
123
129
$ clientFactory = $ this ->clientFactory ;
124
130
$ client = $ clientFactory ();
125
131
126
132
/** @var PaginationStrategy $paginationStrategy */
127
133
$ paginationStrategy = $ this ->options ['pagination_strategy ' ];
128
134
$ paginationParameters = $ paginationStrategy ->getRequestParameters ($ offset );
135
+ $ queryParameters = $ importSourceDefinition ->getQueryParameters ();
129
136
$ requestParameters = array_merge_recursive (
130
137
[
131
138
'verify ' => false ,
132
139
'headers ' => [
133
140
'Accept ' => 'application/json ' ,
134
- 'X-AUTH-TOKEN ' => $ this -> importSourceDefinition ->getOptions ()['api_key ' ],
141
+ 'X-AUTH-TOKEN ' => ( string ) $ importSourceDefinition ->getOptions ()['api_key ' ],
135
142
],
136
143
],
137
- $ paginationParameters
144
+ array_merge_recursive ( $ queryParameters , $ paginationParameters)
138
145
);
139
- $ url = $ this -> importSourceDefinition ->getSource ();
146
+ $ url = $ importSourceDefinition ->getSource ();
140
147
$ requestMethod = Request::METHOD_GET ;
141
148
142
149
try {
0 commit comments