|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace CCT\Kong\Http\Request; |
|
4
|
|
|
|
|
5
|
|
|
use CCT\Kong\Config; |
|
6
|
|
|
use CCT\Kong\Exception\InvalidParameterException; |
|
7
|
|
|
use CCT\Kong\Exception\InvalidResourceException; |
|
|
|
|
|
|
8
|
|
|
use CCT\Kong\Http\Definition\QueryParams; |
|
9
|
|
|
use CCT\Kong\Http\Request; |
|
10
|
|
|
use CCT\Kong\Http\ResponseInterface; |
|
11
|
|
|
use CCT\Kong\Model\Consumer; |
|
12
|
|
|
use JMS\Serializer\SerializationContext; |
|
13
|
|
|
|
|
14
|
|
|
class ConsumerRequest extends Request |
|
15
|
|
|
{ |
|
16
|
12 |
|
protected function setUp() |
|
17
|
|
|
{ |
|
18
|
12 |
|
$this->config->set(Config::URI_PREFIX, '/consumers/'); |
|
19
|
12 |
|
} |
|
20
|
|
|
|
|
21
|
2 |
|
public function list(QueryParams $queryParams = null): ResponseInterface |
|
22
|
|
|
{ |
|
23
|
2 |
|
$this->config->set('serialization_context', SerializationContext::create()->setGroups('read')); |
|
24
|
|
|
|
|
25
|
2 |
|
return parent::requestGet($this->getUri(), $queryParams); |
|
|
|
|
|
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
2 |
|
public function create(Consumer $consumer): ResponseInterface |
|
29
|
|
|
{ |
|
30
|
2 |
|
$this->config->set('serialization_context', SerializationContext::create()->setGroups('create')); |
|
31
|
|
|
|
|
32
|
2 |
|
return parent::requestPost($this->getUri(), $consumer, null); |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
1 |
|
public function update(Consumer $consumer): ResponseInterface |
|
36
|
|
|
{ |
|
37
|
1 |
|
$this->validateObjectId($consumer); |
|
38
|
1 |
|
$this->config->set('serialization_context', SerializationContext::create()->setGroups('update')); |
|
39
|
|
|
|
|
40
|
1 |
|
return parent::requestPatch($this->appendToUri($consumer->getId()), $consumer, null); |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
1 |
|
public function updateOrCreate(Consumer $consumer): ResponseInterface |
|
44
|
|
|
{ |
|
45
|
1 |
|
$this->config->set('serialization_context', SerializationContext::create()->setGroups('update')); |
|
46
|
|
|
|
|
47
|
|
|
try { |
|
48
|
1 |
|
$this->validateObjectId($consumer); |
|
49
|
1 |
|
$uri = $this->appendToUri($consumer->getId()); |
|
50
|
|
|
} catch (InvalidParameterException $e) { |
|
51
|
|
|
$uri = $this->getUri(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
1 |
|
return parent::requestPut($uri, $consumer, null); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
5 |
|
public function retrieve(string $usernameOrId): ResponseInterface |
|
58
|
|
|
{ |
|
59
|
5 |
|
$this->config->set('serialization_context', SerializationContext::create()->setGroups('read')); |
|
60
|
|
|
|
|
61
|
5 |
|
return parent::requestGet($this->appendToUri($usernameOrId), null); |
|
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
3 |
|
public function delete(Consumer $consumer): ResponseInterface |
|
65
|
|
|
{ |
|
66
|
3 |
|
$this->validateObjectId($consumer); |
|
67
|
2 |
|
$this->config->set('serialization_context', SerializationContext::create()->setGroups('delete')); |
|
68
|
|
|
|
|
69
|
2 |
|
return parent::requestDelete($this->appendToUri($consumer->getId()), null); |
|
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths