@@ -12,171 +12,118 @@ public class DoorBirdController(IDoorBirdQueryService doorBirdQuerySvc) : Contro
1212{
1313 /// <inheritdoc cref="DoorBirdQueryService.GetSnapshot"/>
1414 [ HttpGet ]
15- [ ProducesResponseType < DoorBirdSnapshot > ( StatusCodes . Status200OK ) ]
16- public async Task < IActionResult > GetSnapshot ( )
17- => Ok ( await doorBirdQuerySvc . GetSnapshot ( ) ) ;
15+ public async Task < Ok < DoorBirdSnapshot > > GetSnapshot ( )
16+ => TypedResults . Ok ( await doorBirdQuerySvc . GetSnapshot ( ) ) ;
1817
1918 /// <inheritdoc cref="DoorBirdQueryService.GetRealTimePhoto"/>
2019 [ HttpGet ( "photo" ) ]
2120 [ Produces ( "image/jpeg" ) ]
22- [ ProducesResponseType ( StatusCodes . Status200OK ) ]
23- [ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
24- public async Task < IActionResult > GetRealTimePhoto ( )
21+ public async Task < Results < FileContentHttpResult , NotFound < string > > > GetRealTimePhoto ( )
2522 {
2623 var blob = await doorBirdQuerySvc . GetRealTimePhoto ( ) ;
2724 return blob . bytes . Length == 0
28- ? NotFound ( "No image returned from DoorBird device." )
29- : File ( blob . bytes , "image/jpeg" ) ;
25+ ? TypedResults . NotFound ( "No image returned from DoorBird device." )
26+ : TypedResults . File ( blob . bytes , "image/jpeg" ) ;
3027 }
3128
3229 /// <inheritdoc cref="DoorBirdQueryService.GetVideoStreamUrl"/>
3330 [ HttpGet ( "video" ) ]
34- [ ProducesResponseType < string > ( StatusCodes . Status200OK ) ]
35- public IActionResult GetVideoStreamUrl ( )
36- => Ok ( doorBirdQuerySvc . GetVideoStreamUrl ( ) . ToString ( ) ) ;
31+ public Ok < string > GetVideoStreamUrl ( )
32+ => TypedResults . Ok ( doorBirdQuerySvc . GetVideoStreamUrl ( ) . ToString ( ) ) ;
3733
3834 /// <inheritdoc cref="DoorBirdQueryService.UnlockFrontDoor()"/>
3935 [ HttpPost ( "relay" ) ]
40- [ ProducesResponseType ( StatusCodes . Status200OK ) ]
41- public async Task < IActionResult > UnlockFrontDoor ( [ FromQuery ] string ? doorControllerID = null , [ FromQuery ] string ? relayName = null )
42- {
43- var result = await doorBirdQuerySvc . UnlockFrontDoor ( doorControllerID , relayName ) ;
44- return Ok ( result ) ;
45- }
36+ public async Task < Ok < bool > > UnlockFrontDoor ( [ FromQuery ] string ? doorControllerID = null , [ FromQuery ] string ? relayName = null )
37+ => TypedResults . Ok ( await doorBirdQuerySvc . UnlockFrontDoor ( doorControllerID , relayName ) ) ;
4638
4739 /// <inheritdoc cref="DoorBirdQueryService.LightOn"/>
4840 [ HttpPost ( "light" ) ]
49- [ ProducesResponseType < LightOnResponse > ( StatusCodes . Status200OK ) ]
50- public async Task < IActionResult > LightOn ( )
51- {
52- var result = await doorBirdQuerySvc . LightOn ( ) ;
53- return Ok ( result ) ;
54- }
41+ public async Task < Ok < LightOnResponse > > LightOn ( )
42+ => TypedResults . Ok ( await doorBirdQuerySvc . LightOn ( ) ) ;
5543
5644 /// <inheritdoc cref="DoorBirdQueryService.GetInfo"/>
5745 [ HttpGet ( "info" ) ]
58- [ ProducesResponseType < InfoResponse > ( StatusCodes . Status200OK ) ]
59- public async Task < IActionResult > GetInfo ( )
60- {
61- var info = await doorBirdQuerySvc . GetInfo ( ) ;
62- return Ok ( info ) ;
63- }
46+ public async Task < Ok < InfoResponse > > GetInfo ( )
47+ => TypedResults . Ok ( await doorBirdQuerySvc . GetInfo ( ) ) ;
6448
6549 /// <inheritdoc cref="DoorBirdQueryService.Restart"/>
6650 [ HttpPost ( "restart" ) ]
67- [ ProducesResponseType < RestartResponse > ( StatusCodes . Status200OK ) ]
68- public async Task < IActionResult > Restart ( )
69- {
70- var result = await doorBirdQuerySvc . Restart ( ) ;
71- return Ok ( result ) ;
72- }
51+ public async Task < Ok < RestartResponse > > Restart ( )
52+ => TypedResults . Ok ( await doorBirdQuerySvc . Restart ( ) ) ;
7353
7454 /// <inheritdoc cref="DoorBirdQueryService.GetSipStatus"/>
7555 [ HttpGet ( "sip" ) ]
76- [ ProducesResponseType < SipStatusResponse > ( StatusCodes . Status200OK ) ]
77- public async Task < IActionResult > GetSipStatus ( )
78- {
79- var result = await doorBirdQuerySvc . GetSipStatus ( ) ;
80- return Ok ( result ) ;
81- }
56+ public async Task < Ok < SipStatusResponse > > GetSipStatus ( )
57+ => TypedResults . Ok ( await doorBirdQuerySvc . GetSipStatus ( ) ) ;
8258
8359 /// <inheritdoc cref="DoorBirdQueryService.GetSession"/>
8460 [ HttpGet ( "session" ) ]
85- [ ProducesResponseType < SessionResponse > ( StatusCodes . Status200OK ) ]
86- public async Task < IActionResult > GetSession ( )
87- {
88- var result = await doorBirdQuerySvc . GetSession ( ) ;
89- return Ok ( result ) ;
90- }
61+ public async Task < Ok < SessionResponse > > GetSession ( )
62+ => TypedResults . Ok ( await doorBirdQuerySvc . GetSession ( ) ) ;
9163
9264 /// <inheritdoc cref="DoorBirdQueryService.GetFavorites"/>
9365 [ HttpGet ( "favorites" ) ]
94- [ ProducesResponseType < string > ( StatusCodes . Status200OK ) ]
95- public async Task < IActionResult > GetFavorites ( )
96- {
97- var result = await doorBirdQuerySvc . GetFavorites ( ) ;
98- return Ok ( result ) ;
99- }
66+ public async Task < Ok < string > > GetFavorites ( )
67+ => TypedResults . Ok ( await doorBirdQuerySvc . GetFavorites ( ) ) ;
10068
10169 /// <inheritdoc cref="DoorBirdQueryService.GetSchedule"/>
10270 [ HttpGet ( "schedule" ) ]
103- [ ProducesResponseType < string > ( StatusCodes . Status200OK ) ]
104- public async Task < IActionResult > GetSchedule ( )
105- {
106- var result = await doorBirdQuerySvc . GetSchedule ( ) ;
107- return Ok ( result ) ;
108- }
71+ public async Task < Ok < string > > GetSchedule ( )
72+ => TypedResults . Ok ( await doorBirdQuerySvc . GetSchedule ( ) ) ;
10973
11074 /// <inheritdoc cref="DoorBirdQueryService.GetHistoryImage"/>
11175 [ HttpGet ( "history/image" ) ]
11276 [ Produces ( "image/jpeg" ) ]
113- [ ProducesResponseType ( StatusCodes . Status200OK ) ]
114- [ ProducesResponseType ( StatusCodes . Status404NotFound ) ]
115- public async Task < IActionResult > GetHistoryImage ( [ FromQuery ] int index = 1 , [ FromQuery ] DoorBirdEventType ? eventType = null )
77+ public async Task < Results < FileContentHttpResult , NotFound < string > > > GetHistoryImage ( [ FromQuery ] int index = 1 , [ FromQuery ] DoorBirdEventType ? eventType = null )
11678 {
11779 var bytes = await doorBirdQuerySvc . GetHistoryImage ( index , eventType ) ;
11880 return bytes is null
119- ? NotFound ( "No history image found." )
120- : File ( bytes , "image/jpeg" ) ;
81+ ? TypedResults . NotFound ( "No history image found." )
82+ : TypedResults . File ( bytes , "image/jpeg" ) ;
12183 }
12284
12385 /// <inheritdoc cref="DoorBirdQueryService.ListNotifications"/>
12486 [ HttpGet ( "notifications" ) ]
125- [ ProducesResponseType < NotificationListResponse > ( StatusCodes . Status200OK ) ]
126- public async Task < IActionResult > ListNotifications ( )
127- {
128- var result = await doorBirdQuerySvc . ListNotifications ( ) ;
129- return Ok ( result ) ;
130- }
87+ public async Task < Ok < NotificationListResponse > > ListNotifications ( )
88+ => TypedResults . Ok ( await doorBirdQuerySvc . ListNotifications ( ) ) ;
13189
13290 /// <inheritdoc cref="DoorBirdQueryService.SubscribeNotification"/>
13391 [ HttpPost ( "notifications/subscribe" ) ]
134- [ ProducesResponseType ( StatusCodes . Status200OK ) ]
135- public async Task < IActionResult > SubscribeNotification ( [ FromQuery ] string subscriberUrl , [ FromQuery ] string eventType , [ FromQuery ] int ? relaxation = null )
136- {
137- var result = await doorBirdQuerySvc . SubscribeNotification ( subscriberUrl , eventType , relaxation ) ;
138- return Ok ( result ) ;
139- }
92+ public async Task < Ok < bool > > SubscribeNotification ( [ FromQuery ] string subscriberUrl , [ FromQuery ] string eventType , [ FromQuery ] int ? relaxation = null )
93+ => TypedResults . Ok ( await doorBirdQuerySvc . SubscribeNotification ( subscriberUrl , eventType , relaxation ) ) ;
14094
14195 /// <inheritdoc cref="DoorBirdQueryService.UnsubscribeNotification"/>
14296 [ HttpPost ( "notifications/unsubscribe" ) ]
143- [ ProducesResponseType ( StatusCodes . Status200OK ) ]
144- public async Task < IActionResult > UnsubscribeNotification ( [ FromQuery ] string subscriberUrl , [ FromQuery ] string eventType )
145- {
146- var result = await doorBirdQuerySvc . UnsubscribeNotification ( subscriberUrl , eventType ) ;
147- return Ok ( result ) ;
148- }
97+ public async Task < Ok < bool > > UnsubscribeNotification ( [ FromQuery ] string subscriberUrl , [ FromQuery ] string eventType )
98+ => TypedResults . Ok ( await doorBirdQuerySvc . UnsubscribeNotification ( subscriberUrl , eventType ) ) ;
14999
150100 #region Event callbacks
151101
152102 /// <inheritdoc cref="DoorBirdQueryService.SendAlert"/>
153103 [ AllowAnonymous ]
154104 [ HttpGet ( "event/ring" ) ]
155- [ ProducesResponseType ( StatusCodes . Status200OK ) ]
156- public async Task < IActionResult > DoorBirdRing ( )
105+ public async Task < Ok < string > > DoorBirdRing ( )
157106 {
158107 await doorBirdQuerySvc . SendAlert ( DoorBirdEventType . Doorbell ) ;
159- return Ok ( "ok" ) ;
108+ return TypedResults . Ok ( "ok" ) ;
160109 }
161110
162111 /// <inheritdoc cref="DoorBirdQueryService.SendAlert"/>
163112 [ AllowAnonymous ]
164113 [ HttpGet ( "event/motion" ) ]
165- [ ProducesResponseType ( StatusCodes . Status200OK ) ]
166- public async Task < IActionResult > DoorBirdMotion ( )
114+ public async Task < Ok < string > > DoorBirdMotion ( )
167115 {
168116 await doorBirdQuerySvc . SendAlert ( DoorBirdEventType . MotionSensor ) ;
169- return Ok ( "ok" ) ;
117+ return TypedResults . Ok ( "ok" ) ;
170118 }
171119
172120 /// <inheritdoc cref="DoorBirdQueryService.SendAlert"/>
173121 [ AllowAnonymous ]
174122 [ HttpGet ( "event/rfid" ) ]
175- [ ProducesResponseType ( StatusCodes . Status200OK ) ]
176- public async Task < IActionResult > DoorBirdRfid ( )
123+ public async Task < Ok < string > > DoorBirdRfid ( )
177124 {
178125 await doorBirdQuerySvc . SendAlert ( DoorBirdEventType . Rfid ) ;
179- return Ok ( "ok" ) ;
126+ return TypedResults . Ok ( "ok" ) ;
180127 }
181128
182129 #endregion
0 commit comments