1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Thomas Klein, All rights reserved. |
4
|
|
|
*/ |
5
|
|
|
declare(strict_types=1); |
6
|
|
|
|
7
|
|
|
namespace Zoho\Desk\Model; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @api |
11
|
|
|
*/ |
12
|
|
|
final class ListCriteriaBuilder |
13
|
|
|
{ |
14
|
|
|
private array $data = []; |
15
|
|
|
|
16
|
|
|
public function setFilters(array $filters): self |
17
|
|
|
{ |
18
|
|
|
$this->data['filters'] = $filters; |
19
|
|
|
|
20
|
|
|
return $this; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function setFields(array $fields): self |
24
|
|
|
{ |
25
|
|
|
$this->data['fields'] = $fields; |
26
|
|
|
|
27
|
|
|
return $this; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function setInclude(array $include): self |
31
|
|
|
{ |
32
|
|
|
$this->data['include'] = $include; |
33
|
|
|
|
34
|
|
|
return $this; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function setFrom(int $from): self |
38
|
|
|
{ |
39
|
|
|
$this->data['from'] = $from; |
40
|
|
|
|
41
|
|
|
return $this; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function setLimit(int $limit): self |
45
|
|
|
{ |
46
|
|
|
$this->data['limit'] = $limit; |
47
|
|
|
|
48
|
|
|
return $this; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function setSortBy(string $sortBy): self |
52
|
|
|
{ |
53
|
|
|
$this->data['sortBy'] = $sortBy; |
54
|
|
|
|
55
|
|
|
return $this; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function setSortOrder(string $sortOrder): self |
59
|
|
|
{ |
60
|
|
|
$this->data['sortOrder'] = $sortOrder; |
61
|
|
|
|
62
|
|
|
return $this; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function setViewId(int $viewId): self |
66
|
|
|
{ |
67
|
|
|
$this->data['viewId'] = $viewId; |
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function create(): ListCriteriaInterface |
73
|
|
|
{ |
74
|
|
|
$listCriteria = new ListCriteria( |
75
|
|
|
$this->data['filters'] ?? [], |
76
|
|
|
$this->data['fields'] ?? [], |
77
|
|
|
$this->data['include'] ?? [], |
78
|
|
|
$this->data['from'] ?? null, |
79
|
|
|
$this->data['limit'] ?? null, |
80
|
|
|
$this->data['sortBy'] ?? null, |
81
|
|
|
$this->data['sortOrder'] ?? null, |
82
|
|
|
$this->data['viewId'] ?? null |
83
|
|
|
); |
84
|
|
|
$this->data = []; |
85
|
|
|
|
86
|
|
|
return $listCriteria; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|