import 'package:dio/dio.dart'; import '../../errors/marianumconnect_error.dart'; import '../../marianumconnect_api.dart'; import '../../marianumconnect_endpoint.dart'; import 'get_ticker_response.dart'; /// Fetches the current "Aktuelles" ticker post from /// `GET /api/mobile/v1/ticker`. Bearer token is attached by the shared dio. class GetTicker { final Dio _dio; GetTicker({Dio? dio}) : _dio = dio ?? MarianumConnectApi.dio(); Future run() async { try { final response = await _dio.get>( MarianumConnectEndpoint.resolve('ticker'), ); return TickerResponse.fromJson(response.data!); } on DioException catch (e) { throw mapMarianumConnectError(e); } } }