Skip to content

Commit

Permalink
feat(api-service): addition of patch method in api-service helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhisheksainii committed Dec 7, 2023
1 parent 7087c67 commit 279fe33
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
9 changes: 5 additions & 4 deletions example2/lib/di/injector.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:example2/interceptor/auth_interceptor.dart';
import 'package:example2/interceptor/logging_interceptor.dart';
import 'package:example2/interceptor/network/network_info.dart';
import 'package:example2/interceptor/network_interceptor.dart';
import 'package:fa_flutter_api_client/fa_flutter_api_client.dart';
import 'package:get_it/get_it.dart';
import 'package:internet_connection_checker/internet_connection_checker.dart';

import '../interceptor/auth_interceptor.dart';
import '../interceptor/logging_interceptor.dart';
import '../interceptor/network/network_info.dart';
import '../interceptor/network_interceptor.dart';

const _debugBaseUrl = 'https://fa-maapins-debug.fieldassist.io/api/';

final locator = GetIt.instance;
Expand Down
15 changes: 15 additions & 0 deletions lib/src/api_service_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ class ApiServiceImpl implements ApiService {
));
}

@override
Future<Response<T>> patch<T>({
String? endpoint,
String? body,
ApiOptions? options,
}) async {
return _dio!.patch<T>('$baseUrl$endpoint',
data: body,
options: Options(
headers: _formatHeaders(options),
receiveTimeout: options?.receiveTimeout,
sendTimeout: options?.sendTimeout,
));
}

@override
Future<Response<T>> postFile<T>({
String? endpoint,
Expand Down
6 changes: 6 additions & 0 deletions lib/src/base/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ abstract class ApiService {
ApiOptions? options,
});

Future<Response<T>> patch<T>({
String? endpoint,
String? body,
ApiOptions? options,
});

Future<Response<T>> postFile<T>({
String? endpoint,
String? keyName,
Expand Down

0 comments on commit 279fe33

Please sign in to comment.