Skip to content

Commit d41e745

Browse files
committed
controller
1 parent 35d3d78 commit d41e745

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

web/rest/brand/config/api/raw/provider.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,7 @@ Ivoz\Provider\Domain\Model\Terminal\Terminal:
15991599
get_status_collection:
16001600
method: 'GET'
16011601
path: 'terminals/status'
1602+
controller: 'Controller\Provider\TerminalStatusController'
16021603
operation_normalization_context: !php/const Ivoz\Provider\Domain\Model\Terminal\TerminalDto::CONTEXT_STATUS
16031604
normalization_context:
16041605
groups: [

web/rest/brand/features/provider/terminal/getTerminalStatus.feature

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,54 @@ Feature: Retrieve terminals status
5353
}
5454
]
5555
"""
56+
57+
@createSchema
58+
Scenario: Retrieve the terminals status json list
59+
Given I add Brand Authorization header
60+
When I add "Accept" header equal to "application/json"
61+
And I send a "GET" request to "terminals/status?_pagination=false"
62+
Then the response status code should be 200
63+
And the response should be in JSON
64+
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
65+
And the JSON should be equal to:
66+
"""
67+
[
68+
{
69+
"name": "alice",
70+
"id": 1,
71+
"company": 1,
72+
"domainName": "127.0.0.1",
73+
"status": [
74+
{
75+
"contact": "sip:yealinktest@10.10.1.106:5060",
76+
"publicContact": false,
77+
"received": "sip:212.64.172.23:5060",
78+
"publicReceived": true,
79+
"expires": "2031-01-01 00:59:59",
80+
"userAgent": "Yealink SIP-T23G 44.80.0.130"
81+
}
82+
]
83+
},
84+
{
85+
"name": "bob",
86+
"id": 2,
87+
"company": 1,
88+
"domainName": "127.0.0.1",
89+
"status": []
90+
},
91+
{
92+
"name": "testTerminal",
93+
"id": 3,
94+
"company": 1,
95+
"domainName": "127.0.0.1",
96+
"status": []
97+
},
98+
{
99+
"name": "testTerminal4",
100+
"id": 4,
101+
"company": 1,
102+
"domainName": "127.0.0.1",
103+
"status": []
104+
}
105+
]
106+
"""
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Controller\Provider;
4+
5+
use Ivoz\Provider\Domain\Model\Terminal\TerminalRepository;
6+
use Ivoz\Provider\Domain\Assembler\Terminal\TerminalDtoAssembler;
7+
8+
class TerminalStatusController
9+
{
10+
public function __construct(
11+
private TerminalRepository $terminalRepository,
12+
private TerminalDtoAssembler $terminalDtoAssembler
13+
) {
14+
}
15+
16+
public function __invoke()
17+
{
18+
$terminals = $this->terminalRepository->findAll();
19+
20+
return array_map(
21+
fn($terminal) => $this->terminalDtoAssembler->toDto($terminal, 0, 'status'),
22+
$terminals
23+
);
24+
}
25+
}

0 commit comments

Comments
 (0)