RecentlyUpdatedPull   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 33
ccs 0
cts 17
cp 0
rs 10
c 1
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 21 5
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
introduced by
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