Refactor mobile to use OpenApi generated SDK (#336)

This commit is contained in:
Alex 2022-07-13 07:23:48 -05:00 committed by GitHub
parent d69470e207
commit ae7e582ec8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
276 changed files with 14513 additions and 3003 deletions

View file

@ -0,0 +1,30 @@
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:openapi/api.dart';
final apiServiceProvider = Provider((ref) => ApiService());
class ApiService {
late ApiClient _apiClient;
late UserApi userApi;
late AuthenticationApi authenticationApi;
late AlbumApi albumApi;
late AssetApi assetApi;
late ServerInfoApi serverInfoApi;
late DeviceInfoApi deviceInfoApi;
setEndpoint(String endpoint) {
_apiClient = ApiClient(basePath: endpoint);
userApi = UserApi(_apiClient);
authenticationApi = AuthenticationApi(_apiClient);
albumApi = AlbumApi(_apiClient);
assetApi = AssetApi(_apiClient);
serverInfoApi = ServerInfoApi(_apiClient);
deviceInfoApi = DeviceInfoApi(_apiClient);
}
setAccessToken(String accessToken) {
_apiClient.addDefaultHeader('Authorization', 'bearer $accessToken');
}
}