Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
ProcessHubspotAsyncJob | |
0.00% |
0 / 12 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
handle | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
backoff | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
failed | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace App\Jobs; |
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 App\Http\Models\Auth\User; |
11 | use App\Http\Models\HubspotFailedSync; |
12 | use App\Http\Services\HubspotServiceV2; |
13 | |
14 | class ProcessHubspotAsyncJob implements ShouldQueue |
15 | { |
16 | use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; |
17 | |
18 | public $tries = 5; |
19 | |
20 | public function __construct( |
21 | public string $hubspotId, |
22 | public array $properties = [] |
23 | ) {} |
24 | |
25 | public function handle(): void |
26 | { |
27 | $hpService = new HubspotServiceV2(); |
28 | |
29 | $hpService->sendToHusbpot($this->hubspotId, $this->properties); |
30 | } |
31 | |
32 | public function backoff() |
33 | { |
34 | return [10, 30, 60, 120, 300]; |
35 | } |
36 | |
37 | public function failed(\Throwable $exception) |
38 | { |
39 | $user = User::firstWhere('hubspot_id', $this->hubspotId); |
40 | |
41 | HubspotFailedSync::create([ |
42 | 'user_id' => $user?->id ?? null, |
43 | 'email' => $user?->email ?? null, |
44 | 'hubspot_id' => $this->hubspotId, |
45 | 'data' => json_encode($this->properties), |
46 | 'error' => $exception->getMessage(), |
47 | ]); |
48 | } |
49 | } |