Issues (38)

src/Jobs/Contacts/ContactsPull.php (2 issues)

1
<?php
2
3
namespace IproSync\Jobs\Contacts;
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 ContactsPull 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\Contacts\ContactsPull: $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
    public function handle()
27
    {
28
        $response = IproSoftwareFacade::searchContacts([
29
            'query' => $this->pagination->amendQuery($this->requestParams),
30
        ])->onlySuccessful();
31
32
        $items = $response->json('Items');
33
        $total = $response->json('TotalHits');
34
        foreach ($items as $item) {
35
            ContactPull::createOrUpdateContact($item);
36
        }
37
38
        if ($nextPagination = $this->pagination->nextPagination($total)) {
39
            static::dispatch($nextPagination, $this->requestParams)
40
                ->onQueue($this->queue);
41
        }
42
    }
43
}
44