Issues (38)

src/Jobs/Bookings/RecentlyUpdatedPull.php (1 issue)

Severity
1
<?php
2
3
namespace IproSync\Jobs\Bookings;
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 LaravelIproSoftwareApi\IproSoftwareFacade;
11
12
/**
13
 * @deprecated
14
 */
15
class RecentlyUpdatedPull implements ShouldQueue
16
{
17
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
0 ignored issues
show
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by IproSync\Jobs\Bookings\RecentlyUpdatedPull: $collectionClass, $id, $relations, $class, $keyBy
Loading history...
18
19
    protected int $minutesAgo;
20
21
    public function __construct(int $minutesAgo = 60)
22
    {
23
        $this->minutesAgo = $minutesAgo;
24
    }
25
26
27
    public function handle()
28
    {
29
        $response = IproSoftwareFacade::getPropertyDayAvailabilityCheck([
30
            'query' => [
31
                'lastUpdated' => $this->minutesAgo,
32
            ],
33
        ])->onlySuccessful();
34
35
        $changedProperties = $response->json('PropertyIDs');
36
37
        if(is_array($changedProperties)) {
38
            foreach ($changedProperties as $changedPropertyId) {
39
                if(!$changedPropertyId || !is_numeric($changedPropertyId)) {
40
                    continue;
41
                }
42
43
                BlockoutsPull::dispatch($changedPropertyId)
44
                    ->onQueue($this->queue);
45
46
                BookingsPull::dispatch(null, ['propertyids' => $changedPropertyId])
47
                    ->onQueue($this->queue);
48
            }
49
        }
50
    }
51
}
52