|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
/** |
|
5
|
|
|
* JobStatus.php |
|
6
|
|
|
* Copyright (c) 2020 [email protected]. |
|
7
|
|
|
* |
|
8
|
|
|
* This file is part of the Firefly III bunq importer |
|
9
|
|
|
* (https://github.com/firefly-iii/bunq-importer). |
|
10
|
|
|
* |
|
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
14
|
|
|
* License, or (at your option) any later version. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
22
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace App\Bunq\Download\JobStatus; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Class JobStatus. |
|
29
|
|
|
*/ |
|
30
|
|
|
class JobStatus |
|
31
|
|
|
{ |
|
32
|
|
|
/** @var string */ |
|
33
|
|
|
public const JOB_WAITING = 'waiting_to_start'; |
|
34
|
|
|
/** @var string */ |
|
35
|
|
|
public const JOB_RUNNING = 'job_running'; |
|
36
|
|
|
/** @var string */ |
|
37
|
|
|
public const JOB_ERRORED = 'job_errored'; |
|
38
|
|
|
/** @var string */ |
|
39
|
|
|
public const JOB_DONE = 'job_done'; |
|
40
|
|
|
/** @var array */ |
|
41
|
|
|
public $errors; |
|
42
|
|
|
/** @var array */ |
|
43
|
|
|
public $messages; |
|
44
|
|
|
/** @var string */ |
|
45
|
|
|
public $status; |
|
46
|
|
|
/** @var array */ |
|
47
|
|
|
public $warnings; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* JobStatus constructor. |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct() |
|
53
|
|
|
{ |
|
54
|
|
|
//app('log')->debug('Constructed download JobStatus'); |
|
55
|
|
|
$this->status = self::JOB_WAITING; |
|
56
|
|
|
$this->errors = []; |
|
57
|
|
|
$this->warnings = []; |
|
58
|
|
|
$this->messages = []; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param array $array |
|
63
|
|
|
* |
|
64
|
|
|
* @return static |
|
65
|
|
|
*/ |
|
66
|
|
|
public static function fromArray(array $array): self |
|
67
|
|
|
{ |
|
68
|
|
|
$config = new self; |
|
69
|
|
|
$config->status = $array['status']; |
|
70
|
|
|
$config->errors = $array['errors'] ?? []; |
|
71
|
|
|
$config->warnings = $array['warnings'] ?? []; |
|
72
|
|
|
$config->messages = $array['messages'] ?? []; |
|
73
|
|
|
|
|
74
|
|
|
return $config; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return array |
|
79
|
|
|
*/ |
|
80
|
|
|
public function toArray(): array |
|
81
|
|
|
{ |
|
82
|
|
|
return [ |
|
83
|
|
|
'status' => $this->status, |
|
84
|
|
|
'errors' => $this->errors, |
|
85
|
|
|
'warnings' => $this->warnings, |
|
86
|
|
|
'messages' => $this->messages, |
|
87
|
|
|
]; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|