refactor(apps): simplify API layer by removing redundant wrapper classes
- Remove ApiClientWrapper and MockApiClientWrapper - Simplify IApiClient interface - Update dependency injection configuration - Optimize calendar service and AG-UI chat models
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'api_exception.dart';
|
import 'api_exception.dart';
|
||||||
import 'api_interceptor.dart';
|
import 'api_interceptor.dart';
|
||||||
|
import 'i_api_client.dart';
|
||||||
import '../storage/token_storage.dart';
|
import '../storage/token_storage.dart';
|
||||||
|
|
||||||
class ApiClient {
|
class ApiClient implements IApiClient {
|
||||||
final Dio _dio;
|
final Dio _dio;
|
||||||
final TokenStorage _tokenStorage;
|
final TokenStorage _tokenStorage;
|
||||||
final ApiInterceptor _interceptor;
|
final ApiInterceptor _interceptor;
|
||||||
@@ -44,6 +45,7 @@ class ApiClient {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Future<Response<T>> get<T>(String path, {Options? options}) async {
|
Future<Response<T>> get<T>(String path, {Options? options}) async {
|
||||||
try {
|
try {
|
||||||
return await _dio.get<T>(path, options: options);
|
return await _dio.get<T>(path, options: options);
|
||||||
@@ -52,6 +54,7 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Future<Response<T>> post<T>(
|
Future<Response<T>> post<T>(
|
||||||
String path, {
|
String path, {
|
||||||
dynamic data,
|
dynamic data,
|
||||||
@@ -64,6 +67,7 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Future<Response<T>> patch<T>(
|
Future<Response<T>> patch<T>(
|
||||||
String path, {
|
String path, {
|
||||||
dynamic data,
|
dynamic data,
|
||||||
@@ -76,6 +80,7 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Future<Response<T>> delete<T>(
|
Future<Response<T>> delete<T>(
|
||||||
String path, {
|
String path, {
|
||||||
dynamic data,
|
dynamic data,
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'api_client.dart';
|
|
||||||
import 'mock_api_client.dart';
|
|
||||||
|
|
||||||
abstract class IApiClient {
|
abstract class IApiClient {
|
||||||
Future<Response<T>> get<T>(String path, {Options? options});
|
Future<Response<T>> get<T>(String path, {Options? options});
|
||||||
@@ -8,53 +6,3 @@ abstract class IApiClient {
|
|||||||
Future<Response<T>> patch<T>(String path, {dynamic data, Options? options});
|
Future<Response<T>> patch<T>(String path, {dynamic data, Options? options});
|
||||||
Future<Response<T>> delete<T>(String path, {dynamic data, Options? options});
|
Future<Response<T>> delete<T>(String path, {dynamic data, Options? options});
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApiClientWrapper implements IApiClient {
|
|
||||||
final ApiClient _client;
|
|
||||||
|
|
||||||
ApiClientWrapper(this._client);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Response<T>> get<T>(String path, {Options? options}) =>
|
|
||||||
_client.get(path, options: options);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Response<T>> post<T>(String path, {dynamic data, Options? options}) =>
|
|
||||||
_client.post(path, data: data, options: options);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Response<T>> patch<T>(String path, {dynamic data, Options? options}) =>
|
|
||||||
_client.patch(path, data: data, options: options);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Response<T>> delete<T>(
|
|
||||||
String path, {
|
|
||||||
dynamic data,
|
|
||||||
Options? options,
|
|
||||||
}) => _client.delete(path, data: data, options: options);
|
|
||||||
}
|
|
||||||
|
|
||||||
class MockApiClientWrapper implements IApiClient {
|
|
||||||
final MockApiClient _client;
|
|
||||||
|
|
||||||
MockApiClientWrapper(this._client);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Response<T>> get<T>(String path, {Options? options}) =>
|
|
||||||
_client.get(path, options: options);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Response<T>> post<T>(String path, {dynamic data, Options? options}) =>
|
|
||||||
_client.post(path, data: data, options: options);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Response<T>> patch<T>(String path, {dynamic data, Options? options}) =>
|
|
||||||
_client.patch(path, data: data, options: options);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<Response<T>> delete<T>(
|
|
||||||
String path, {
|
|
||||||
dynamic data,
|
|
||||||
Options? options,
|
|
||||||
}) => _client.delete(path, data: data, options: options);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'i_api_client.dart';
|
||||||
|
|
||||||
class MockApiClient {
|
typedef MockHandler = dynamic Function(dynamic data);
|
||||||
final Map<String, _MockHandler> _handlers = {};
|
|
||||||
|
|
||||||
void registerHandler(String path, String method, _MockHandler handler) {
|
class MockApiClient implements IApiClient {
|
||||||
|
final Map<String, MockHandler> _handlers = {};
|
||||||
|
|
||||||
|
void registerHandler(String path, String method, MockHandler handler) {
|
||||||
final key = '$path:$method';
|
final key = '$path:$method';
|
||||||
_handlers[key] = handler;
|
_handlers[key] = handler;
|
||||||
}
|
}
|
||||||
@@ -12,10 +15,12 @@ class MockApiClient {
|
|||||||
_handlers.clear();
|
_handlers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Future<Response<T>> get<T>(String path, {Options? options}) async {
|
Future<Response<T>> get<T>(String path, {Options? options}) async {
|
||||||
return _handleRequest('GET', path, options: options);
|
return _handleRequest('GET', path, options: options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Future<Response<T>> post<T>(
|
Future<Response<T>> post<T>(
|
||||||
String path, {
|
String path, {
|
||||||
dynamic data,
|
dynamic data,
|
||||||
@@ -24,6 +29,7 @@ class MockApiClient {
|
|||||||
return _handleRequest('POST', path, data: data, options: options);
|
return _handleRequest('POST', path, data: data, options: options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Future<Response<T>> patch<T>(
|
Future<Response<T>> patch<T>(
|
||||||
String path, {
|
String path, {
|
||||||
dynamic data,
|
dynamic data,
|
||||||
@@ -32,6 +38,7 @@ class MockApiClient {
|
|||||||
return _handleRequest('PATCH', path, data: data, options: options);
|
return _handleRequest('PATCH', path, data: data, options: options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
Future<Response<T>> delete<T>(
|
Future<Response<T>> delete<T>(
|
||||||
String path, {
|
String path, {
|
||||||
dynamic data,
|
dynamic data,
|
||||||
@@ -70,18 +77,3 @@ class MockApiClient {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef _MockHandler = dynamic Function(dynamic data);
|
|
||||||
|
|
||||||
class MockApiClientHolder {
|
|
||||||
static MockApiClient? _instance;
|
|
||||||
|
|
||||||
static MockApiClient get instance {
|
|
||||||
_instance ??= MockApiClient();
|
|
||||||
return _instance!;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void reset() {
|
|
||||||
_instance = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import 'package:dio/dio.dart';
|
|||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
import '../api/api_client.dart';
|
import '../api/api_client.dart';
|
||||||
|
import '../api/i_api_client.dart';
|
||||||
|
import '../api/mock_api_client.dart';
|
||||||
import '../storage/token_storage.dart';
|
import '../storage/token_storage.dart';
|
||||||
import '../config/env.dart';
|
import '../config/env.dart';
|
||||||
import '../../features/auth/data/auth_api.dart';
|
import '../../features/auth/data/auth_api.dart';
|
||||||
@@ -13,20 +15,27 @@ import '../../features/calendar/ui/calendar_state_manager.dart';
|
|||||||
final sl = GetIt.instance;
|
final sl = GetIt.instance;
|
||||||
|
|
||||||
Future<void> configureDependencies() async {
|
Future<void> configureDependencies() async {
|
||||||
if (sl.isRegistered<ApiClient>()) {
|
if (sl.isRegistered<IApiClient>()) {
|
||||||
await sl.reset();
|
await sl.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
final dio = Dio(BaseOptions(baseUrl: Env.apiUrl));
|
final IApiClient apiClient;
|
||||||
final secureStorage = const FlutterSecureStorage();
|
final SecureTokenStorage tokenStorage;
|
||||||
final tokenStorage = SecureTokenStorage(secureStorage);
|
|
||||||
|
|
||||||
final apiClient = ApiClient(
|
if (Env.isMockApi) {
|
||||||
|
apiClient = MockApiClient();
|
||||||
|
tokenStorage = SecureTokenStorage(const FlutterSecureStorage());
|
||||||
|
} else {
|
||||||
|
final dio = Dio(BaseOptions(baseUrl: Env.apiUrl));
|
||||||
|
tokenStorage = SecureTokenStorage(const FlutterSecureStorage());
|
||||||
|
apiClient = ApiClient(
|
||||||
baseUrl: Env.apiUrl,
|
baseUrl: Env.apiUrl,
|
||||||
tokenStorage: tokenStorage,
|
tokenStorage: tokenStorage,
|
||||||
dio: dio,
|
dio: dio,
|
||||||
);
|
);
|
||||||
sl.registerSingleton<ApiClient>(apiClient);
|
}
|
||||||
|
|
||||||
|
sl.registerSingleton<IApiClient>(apiClient);
|
||||||
|
|
||||||
final authApi = AuthApi(apiClient);
|
final authApi = AuthApi(apiClient);
|
||||||
sl.registerSingleton<AuthApi>(authApi);
|
sl.registerSingleton<AuthApi>(authApi);
|
||||||
@@ -37,7 +46,8 @@ Future<void> configureDependencies() async {
|
|||||||
);
|
);
|
||||||
sl.registerSingleton<AuthRepository>(authRepository);
|
sl.registerSingleton<AuthRepository>(authRepository);
|
||||||
|
|
||||||
apiClient.setRefreshCallback((token) async {
|
if (!Env.isMockApi) {
|
||||||
|
(apiClient as ApiClient).setRefreshCallback((token) async {
|
||||||
try {
|
try {
|
||||||
await authRepository.refreshSession(token);
|
await authRepository.refreshSession(token);
|
||||||
return true;
|
return true;
|
||||||
@@ -45,8 +55,8 @@ Future<void> configureDependencies() async {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
sl.registerSingleton<AuthBloc>(AuthBloc(authRepository));
|
sl.registerSingleton<AuthBloc>(AuthBloc(authRepository));
|
||||||
|
|
||||||
sl.registerSingleton<CalendarStateManager>(CalendarStateManager());
|
sl.registerSingleton<CalendarStateManager>(CalendarStateManager());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import 'package:social_app/core/api/api_client.dart';
|
import 'package:social_app/core/api/i_api_client.dart';
|
||||||
import 'models/signup_request.dart';
|
import 'models/signup_request.dart';
|
||||||
import 'models/login_request.dart';
|
import 'models/login_request.dart';
|
||||||
import 'models/auth_response.dart';
|
import 'models/auth_response.dart';
|
||||||
|
|
||||||
class AuthApi {
|
class AuthApi {
|
||||||
final ApiClient _client;
|
final IApiClient _client;
|
||||||
static const _prefix = '/api/v1/auth';
|
static const _prefix = '/api/v1/auth';
|
||||||
|
|
||||||
AuthApi(this._client);
|
AuthApi(this._client);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import 'package:social_app/core/config/env.dart';
|
import 'package:social_app/core/api/i_api_client.dart';
|
||||||
import '../models/schedule_item_model.dart';
|
import '../models/schedule_item_model.dart';
|
||||||
|
|
||||||
class MockCalendarService {
|
class MockCalendarService {
|
||||||
@@ -56,54 +56,50 @@ class MockCalendarService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CalendarService {
|
class CalendarService {
|
||||||
static final CalendarService _instance = CalendarService._internal();
|
final IApiClient? _apiClient;
|
||||||
factory CalendarService() => _instance;
|
final MockCalendarService _mock = MockCalendarService();
|
||||||
CalendarService._internal();
|
|
||||||
|
|
||||||
MockCalendarService get _mock => MockCalendarService();
|
CalendarService({IApiClient? apiClient}) : _apiClient = apiClient;
|
||||||
|
|
||||||
List<ScheduleItemModel> getEventsForDay(DateTime date) {
|
List<ScheduleItemModel> getEventsForDay(DateTime date) {
|
||||||
if (Env.isMockApi) {
|
if (_apiClient != null) {
|
||||||
return _mock.getEventsForDay(date);
|
|
||||||
}
|
|
||||||
throw UnimplementedError('Real API not implemented');
|
throw UnimplementedError('Real API not implemented');
|
||||||
}
|
}
|
||||||
|
return _mock.getEventsForDay(date);
|
||||||
|
}
|
||||||
|
|
||||||
List<ScheduleItemModel> getEventsForRange(DateTime start, DateTime end) {
|
List<ScheduleItemModel> getEventsForRange(DateTime start, DateTime end) {
|
||||||
if (Env.isMockApi) {
|
if (_apiClient != null) {
|
||||||
return _mock.getEventsForRange(start, end);
|
|
||||||
}
|
|
||||||
throw UnimplementedError('Real API not implemented');
|
throw UnimplementedError('Real API not implemented');
|
||||||
}
|
}
|
||||||
|
return _mock.getEventsForRange(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
ScheduleItemModel? getEventById(String id) {
|
ScheduleItemModel? getEventById(String id) {
|
||||||
if (Env.isMockApi) {
|
if (_apiClient != null) {
|
||||||
return _mock.getEventById(id);
|
|
||||||
}
|
|
||||||
throw UnimplementedError('Real API not implemented');
|
throw UnimplementedError('Real API not implemented');
|
||||||
}
|
}
|
||||||
|
return _mock.getEventById(id);
|
||||||
|
}
|
||||||
|
|
||||||
void addEvent(ScheduleItemModel event) {
|
void addEvent(ScheduleItemModel event) {
|
||||||
if (Env.isMockApi) {
|
if (_apiClient != null) {
|
||||||
_mock.addEvent(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw UnimplementedError('Real API not implemented');
|
throw UnimplementedError('Real API not implemented');
|
||||||
}
|
}
|
||||||
|
_mock.addEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void updateEvent(ScheduleItemModel event) {
|
void updateEvent(ScheduleItemModel event) {
|
||||||
if (Env.isMockApi) {
|
if (_apiClient != null) {
|
||||||
_mock.updateEvent(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw UnimplementedError('Real API not implemented');
|
throw UnimplementedError('Real API not implemented');
|
||||||
}
|
}
|
||||||
|
_mock.updateEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void deleteEvent(String id) {
|
void deleteEvent(String id) {
|
||||||
if (Env.isMockApi) {
|
if (_apiClient != null) {
|
||||||
_mock.deleteEvent(id);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw UnimplementedError('Real API not implemented');
|
throw UnimplementedError('Real API not implemented');
|
||||||
}
|
}
|
||||||
|
_mock.deleteEvent(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ class _CalendarMonthScreenState extends State<CalendarMonthScreen> {
|
|||||||
vertical: 2,
|
vertical: 2,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: color.withOpacity(0.2),
|
color: color.withValues(alpha: 0.2),
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ class _CreateEventSheetState extends State<CreateEventSheet>
|
|||||||
Row(
|
Row(
|
||||||
children: defaultColors.map((color) {
|
children: defaultColors.map((color) {
|
||||||
final colorHex =
|
final colorHex =
|
||||||
'#${color.value.toRadixString(16).substring(2).toUpperCase()}';
|
'#${color.toARGB32().toRadixString(16).substring(2).toUpperCase()}';
|
||||||
final isSelected = _selectedColor == colorHex;
|
final isSelected = _selectedColor == colorHex;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => setState(() => _selectedColor = colorHex),
|
onTap: () => setState(() => _selectedColor = colorHex),
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ final _typeToFactory = {
|
|||||||
AgUiEventType.unknown: UnknownAgUiEvent.fromJson,
|
AgUiEventType.unknown: UnknownAgUiEvent.fromJson,
|
||||||
};
|
};
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable(createFactory: false)
|
||||||
class AgUiEvent {
|
class AgUiEvent {
|
||||||
final AgUiEventType type;
|
final AgUiEventType type;
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ class AgUiEvent {
|
|||||||
Map<String, dynamic> toJson() => _$AgUiEventToJson(this);
|
Map<String, dynamic> toJson() => _$AgUiEventToJson(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonSerializable()
|
@JsonSerializable(createFactory: false, createToJson: false)
|
||||||
class UnknownAgUiEvent extends AgUiEvent {
|
class UnknownAgUiEvent extends AgUiEvent {
|
||||||
final Map<String, dynamic> rawJson;
|
final Map<String, dynamic> rawJson;
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ part of 'ag_ui_event.dart';
|
|||||||
// JsonSerializableGenerator
|
// JsonSerializableGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
AgUiEvent _$AgUiEventFromJson(Map<String, dynamic> json) =>
|
|
||||||
AgUiEvent(type: $enumDecode(_$AgUiEventTypeEnumMap, json['type']));
|
|
||||||
|
|
||||||
Map<String, dynamic> _$AgUiEventToJson(AgUiEvent instance) => <String, dynamic>{
|
Map<String, dynamic> _$AgUiEventToJson(AgUiEvent instance) => <String, dynamic>{
|
||||||
'type': _$AgUiEventTypeEnumMap[instance.type]!,
|
'type': _$AgUiEventTypeEnumMap[instance.type]!,
|
||||||
};
|
};
|
||||||
@@ -29,12 +26,6 @@ const _$AgUiEventTypeEnumMap = {
|
|||||||
AgUiEventType.unknown: 'unknown',
|
AgUiEventType.unknown: 'unknown',
|
||||||
};
|
};
|
||||||
|
|
||||||
UnknownAgUiEvent _$UnknownAgUiEventFromJson(Map<String, dynamic> json) =>
|
|
||||||
UnknownAgUiEvent(rawJson: json['rawJson'] as Map<String, dynamic>);
|
|
||||||
|
|
||||||
Map<String, dynamic> _$UnknownAgUiEventToJson(UnknownAgUiEvent instance) =>
|
|
||||||
<String, dynamic>{'rawJson': instance.rawJson};
|
|
||||||
|
|
||||||
RunStartedEvent _$RunStartedEventFromJson(Map<String, dynamic> json) =>
|
RunStartedEvent _$RunStartedEventFromJson(Map<String, dynamic> json) =>
|
||||||
RunStartedEvent(
|
RunStartedEvent(
|
||||||
threadId: json['threadId'] as String,
|
threadId: json['threadId'] as String,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:social_app/core/config/env.dart';
|
import 'package:social_app/core/api/i_api_client.dart';
|
||||||
|
|
||||||
import '../ai/ai_decision_engine.dart';
|
import '../ai/ai_decision_engine.dart';
|
||||||
import '../models/ag_ui_event.dart';
|
import '../models/ag_ui_event.dart';
|
||||||
@@ -24,27 +24,29 @@ const _textChunkSize = 10;
|
|||||||
typedef EventCallback = void Function(AgUiEvent event);
|
typedef EventCallback = void Function(AgUiEvent event);
|
||||||
|
|
||||||
class AgUiService {
|
class AgUiService {
|
||||||
|
final IApiClient? _apiClient;
|
||||||
EventCallback onEvent;
|
EventCallback onEvent;
|
||||||
final AiDecisionEngine _decisionEngine;
|
final AiDecisionEngine _decisionEngine;
|
||||||
final MockHistoryService _historyService;
|
final MockHistoryService _historyService;
|
||||||
|
|
||||||
AgUiService({EventCallback? onEvent})
|
AgUiService({EventCallback? onEvent, IApiClient? apiClient})
|
||||||
: onEvent = onEvent ?? ((_) {}),
|
: onEvent = onEvent ?? ((_) {}),
|
||||||
|
_apiClient = apiClient,
|
||||||
_decisionEngine = AiDecisionEngine(),
|
_decisionEngine = AiDecisionEngine(),
|
||||||
_historyService = MockHistoryService();
|
_historyService = MockHistoryService();
|
||||||
|
|
||||||
Future<void> sendMessage(String content) async {
|
Future<void> sendMessage(String content) async {
|
||||||
if (Env.isMockApi) {
|
if (_apiClient != null) {
|
||||||
await _mockEventStream(content);
|
|
||||||
} else {
|
|
||||||
throw UnimplementedError('Real API not implemented');
|
throw UnimplementedError('Real API not implemented');
|
||||||
}
|
}
|
||||||
|
await _mockEventStream(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadHistory({DateTime? beforeDate}) async {
|
Future<void> loadHistory({DateTime? beforeDate}) async {
|
||||||
if (Env.isMockApi) {
|
if (_apiClient != null) {
|
||||||
await _mockLoadHistory(beforeDate: beforeDate);
|
throw UnimplementedError('Real API not implemented');
|
||||||
}
|
}
|
||||||
|
await _mockLoadHistory(beforeDate: beforeDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasEarlierHistory(DateTime fromDate) {
|
bool hasEarlierHistory(DateTime fromDate) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import 'package:social_app/core/api/api_client.dart';
|
import 'package:social_app/core/api/i_api_client.dart';
|
||||||
import 'models/user_response.dart';
|
import 'models/user_response.dart';
|
||||||
|
|
||||||
class UsersApi {
|
class UsersApi {
|
||||||
final ApiClient _client;
|
final IApiClient _client;
|
||||||
static const _prefix = '/api/v1/users';
|
static const _prefix = '/api/v1/users';
|
||||||
|
|
||||||
UsersApi(this._client);
|
UsersApi(this._client);
|
||||||
|
|||||||
Reference in New Issue
Block a user