1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the pexels-library package. |
5
|
|
|
* |
6
|
|
|
* (c) 2019 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Library\Pexels\Request; |
13
|
|
|
|
14
|
|
|
use WBW\Library\Pexels\Response\AbstractResponse; |
15
|
|
|
use WBW\Library\Pexels\Serializer\RequestSerializer; |
16
|
|
|
use WBW\Library\Pexels\Serializer\ResponseDeserializer; |
17
|
|
|
use WBW\Library\Traits\Integers\IntegerPageTrait; |
18
|
|
|
use WBW\Library\Traits\Integers\IntegerPerPageTrait; |
19
|
|
|
use WBW\Library\Traits\Strings\StringLocaleTrait; |
20
|
|
|
use WBW\Library\Traits\Strings\StringOrientationTrait; |
21
|
|
|
use WBW\Library\Traits\Strings\StringQueryTrait; |
22
|
|
|
use WBW\Library\Traits\Strings\StringSizeTrait; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Search photos request. |
26
|
|
|
* |
27
|
|
|
* @author webeweb <https://github.com/webeweb> |
28
|
|
|
* @package WBW\Library\Pexels\Request |
29
|
|
|
*/ |
30
|
|
|
class SearchPhotosRequest extends AbstractRequest { |
31
|
|
|
|
32
|
|
|
use IntegerPageTrait; |
33
|
|
|
use IntegerPerPageTrait; |
34
|
|
|
use StringLocaleTrait; |
35
|
|
|
use StringOrientationTrait; |
36
|
|
|
use StringQueryTrait; |
37
|
|
|
use StringSizeTrait; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Search photos resource path. |
41
|
|
|
* |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
const SEARCH_PHOTOS_RESOURCE_PATH = "/v1/search"; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Color. |
48
|
|
|
* |
49
|
|
|
* @var string|null |
50
|
|
|
*/ |
51
|
|
|
private $color; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Constructor. |
55
|
|
|
*/ |
56
|
|
|
public function __construct() { |
57
|
|
|
parent::__construct(); |
58
|
|
|
|
59
|
|
|
$this->setPage(1); |
60
|
|
|
$this->setPerPage(self::PER_PAGE_DEFAULT); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* {@inheritdoc} |
65
|
|
|
*/ |
66
|
|
|
public function deserializeResponse(string $rawResponse): AbstractResponse { |
67
|
|
|
return ResponseDeserializer::deserializePhotosResponse($rawResponse); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Get the color. |
72
|
|
|
* |
73
|
|
|
* @return string|null Returns the color. |
74
|
|
|
*/ |
75
|
|
|
public function getColor(): ?string { |
76
|
|
|
return $this->color; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* {@inheritdoc} |
81
|
|
|
*/ |
82
|
|
|
public function getResourcePath(): string { |
83
|
|
|
return self::SEARCH_PHOTOS_RESOURCE_PATH; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* {@inheritdoc} |
88
|
|
|
*/ |
89
|
|
|
public function serializeRequest(): array { |
90
|
|
|
return RequestSerializer::serializeSearchPhotosRequest($this); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Set the color. |
95
|
|
|
* |
96
|
|
|
* @param string|null $color The color. |
97
|
|
|
* @return SearchPhotosRequest Returns this search photos request. |
98
|
|
|
*/ |
99
|
|
|
public function setColor(?string $color): SearchPhotosRequest { |
100
|
|
|
$this->color = $color; |
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|