-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetNodes.php
85 lines (75 loc) · 4.99 KB
/
GetNodes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
declare(strict_types=1);
namespace Yproximite\IovoxBundle\Api\AccountSetup\Nodes;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Yproximite\IovoxBundle\Api\ErrorResult\GenericErrorResult;
use Yproximite\IovoxBundle\Api\ErrorResult\InternalErrorResult;
use Yproximite\IovoxBundle\Api\ErrorResult\LimitIntegerErrorResult;
use Yproximite\IovoxBundle\Api\ErrorResult\LimitIntervalErrorResult;
use Yproximite\IovoxBundle\Api\ErrorResult\OutputInvalidErrorResult;
use Yproximite\IovoxBundle\Api\ErrorResult\PageIntegerErrorResult;
use Yproximite\IovoxBundle\Api\ErrorResult\RequestMethodInvalidErrorResult;
use Yproximite\IovoxBundle\Api\ErrorResult\VersionEmptyErrorResult;
use Yproximite\IovoxBundle\Api\ErrorResult\VersionInvalidErrorResult;
use Yproximite\IovoxBundle\Api\QueryParameter\GenericQueryParameter;
use Yproximite\IovoxBundle\Api\QueryParameter\LimitQueryParameter;
use Yproximite\IovoxBundle\Api\QueryParameter\MethodQueryParameter;
use Yproximite\IovoxBundle\Api\QueryParameter\OutputQueryParameter;
use Yproximite\IovoxBundle\Api\QueryParameter\PageQueryParameter;
use Yproximite\IovoxBundle\Api\QueryParameter\VersionQueryParameter;
use Yproximite\IovoxBundle\Exception\Api\BadResponseReturnException;
use Yproximite\IovoxBundle\Model\Nodes\GetNodesModel;
/**
* @see https://docs.iovox.com/display/RA/getNodes
*/
class GetNodes extends AbstractNodes implements GetNodesInterface
{
public function executeQuery(array $queryParameters = []): GetNodesModel
{
$query = $this->createQuery($queryParameters);
$response = $this->client->executeQuery($query);
if (Response::HTTP_OK === $response->getStatusCode()) {
return GetNodesModel::create($response->toArray());
}
throw new BadResponseReturnException($response, $this->errorResults);
}
protected function setMethod(): void
{
$this->method = Request::METHOD_GET;
}
protected function setQueryParameters(): void
{
$this->editableQueryParameters = [
PageQueryParameter::getParameterName() => new PageQueryParameter(),
LimitQueryParameter::getParameterName() => new LimitQueryParameter(),
self::QUERY_PARAMETER_NODE_ID => new GenericQueryParameter(self::QUERY_PARAMETER_NODE_ID, GenericQueryParameter::TYPE_STRING, 'Returns the specified Node ID'),
self::QUERY_PARAMETER_NODE_TYPE => new GenericQueryParameter(self::QUERY_PARAMETER_NODE_TYPE, GenericQueryParameter::TYPE_STRING, 'Returns all nodes for the specified Node Type'),
self::QUERY_PARAMETER_LINK_ID => new GenericQueryParameter(self::QUERY_PARAMETER_LINK_ID, GenericQueryParameter::TYPE_STRING, 'Returns the node for the specified Link ID'),
self::QUERY_PARAMETER_LINK_TYPE => new GenericQueryParameter(self::QUERY_PARAMETER_LINK_TYPE, GenericQueryParameter::TYPE_STRING, 'Returns all nodes for the specified Link Type'),
self::QUERY_PARAMETER_VOXNUMBER => new GenericQueryParameter(self::QUERY_PARAMETER_VOXNUMBER, GenericQueryParameter::TYPE_STRING, 'Returns all nodes for the specified VoxNumber'),
self::QUERY_PARAMETER_REQ_FIELDS => new GenericQueryParameter(self::QUERY_PARAMETER_REQ_FIELDS, GenericQueryParameter::TYPE_STRING, 'Comma separated list of abbreviated fields to return in response. nid=Node id, nn= Node Name, nt= Node Type, lid = Link Id, ln = Link Name, lt = Link Type, rtn=Rule Template Name.'),
self::QUERY_PARAMETER_RULE_NAME => new GenericQueryParameter(self::QUERY_PARAMETER_RULE_NAME, GenericQueryParameter::TYPE_STRING, 'Returns all nodes that have the specified rule name'),
self::QUERY_PARAMETER_ORDER => new GenericQueryParameter(self::QUERY_PARAMETER_ORDER, GenericQueryParameter::TYPE_STRING, 'Determines which field to order the output result by. Use a field name from the req_fields list and suffix with ASC or DESC for ascending or descending respectively. For example, "nd_DESC" will return results ordered by order_date with the most recent first'),
];
$this->allQueryParameters = array_merge([
VersionQueryParameter::getParameterName() => new VersionQueryParameter(),
MethodQueryParameter::getParameterName() => new MethodQueryParameter('getNodes'),
OutputQueryParameter::getParameterName() => new OutputQueryParameter(),
], $this->editableQueryParameters);
}
protected function setErrorResults(): void
{
$this->errorResults = [
new VersionEmptyErrorResult(),
new VersionInvalidErrorResult(),
new RequestMethodInvalidErrorResult($this->method),
new PageIntegerErrorResult(),
new LimitIntegerErrorResult(),
new LimitIntervalErrorResult(),
new GenericErrorResult(400, 'Order Field Invalid', 'Correct order parameter'),
new OutputInvalidErrorResult(),
new InternalErrorResult(),
];
}
}