Issues (38)

src/Jobs/Properties/PropertiesPull.php (2 issues)

1
<?php
2
3
namespace IproSync\Jobs\Properties;
4
5
use Illuminate\Bus\Queueable;
6
use Illuminate\Contracts\Queue\ShouldQueue;
7
use Illuminate\Foundation\Bus\Dispatchable;
8
use Illuminate\Queue\InteractsWithQueue;
9
use Illuminate\Queue\SerializesModels;
10
use IproSync\Ipro\PullPagination;
0 ignored issues
show
The type IproSync\Ipro\PullPagination was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use LaravelIproSoftwareApi\IproSoftwareFacade;
12
13
class PropertiesPull implements ShouldQueue
14
{
15
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
0 ignored issues
show
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by IproSync\Jobs\Properties\PropertiesPull: $collectionClass, $id, $relations, $class, $keyBy
Loading history...
16
17
    protected PullPagination $pagination;
18
    protected array $requestParams;
19
20
    public function __construct(?PullPagination $pagination = null, array $requestParams = [])
21
    {
22
        $this->pagination    = $pagination ?? PullPagination::allPages();
23
        $this->requestParams = $requestParams;
24
    }
25
26
27
    public function handle()
28
    {
29
        $response = IproSoftwareFacade::searchLiteProperties([
30
            'query' => $this->pagination->amendQuery($this->requestParams),
31
        ])->onlySuccessful();
32
33
        $items = $response->json('Items');
34
        $total = $response->json('TotalHits');
35
        foreach ($items as $item) {
36
            if (!empty($item['Id'])) {
37
                PropertyPull::dispatch($item['Id']);
38
            }
39
        }
40
41
        if ($nextPagination = $this->pagination->nextPagination($total)) {
42
            static::dispatch($nextPagination, $this->requestParams)
43
                ->onQueue($this->queue);
44
        }
45
    }
46
}
47