Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Infrastructure] Updated the file services + minor changes
- Loading branch information
Showing
18 changed files
with
228 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:shiori/domain/services/api_service.dart'; | ||
import 'package:shiori/domain/services/logging_service.dart'; | ||
import 'package:shiori/infrastructure/secrets.dart'; | ||
|
||
class ApiServiceImpl implements ApiService { | ||
final LoggingService _loggingService; | ||
|
||
final _dio = Dio(); | ||
|
||
ApiServiceImpl(this._loggingService); | ||
|
||
@override | ||
Future<String> getChangelog(String defaultValue) async { | ||
try { | ||
final url = '${Secrets.assetsBaseUrl}/changelog.md'; | ||
final response = await _dio.getUri<String>(Uri.parse(url)); | ||
if (response.statusCode != 200) { | ||
_loggingService.warning( | ||
runtimeType, | ||
'getChangelog: Could not retrieve changelog, got status code = ${response.statusCode}, falling back to the default one', | ||
); | ||
return defaultValue; | ||
} | ||
|
||
return response.data!; | ||
} catch (e, s) { | ||
_loggingService.error(runtimeType, 'getChangelog: Unknown error occurred', e, s); | ||
return defaultValue; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.