mirror of
https://github.com/cyberbread-ru/notepad.git
synced 2026-07-14 12:51:01 +03:00
28 lines
731 B
Dart
28 lines
731 B
Dart
import 'package:dio/dio.dart';
|
|
|
|
class ApiClient {
|
|
late final Dio _dio;
|
|
|
|
ApiClient({required String baseUrl, required String apiKey}) {
|
|
_dio = Dio(
|
|
BaseOptions(
|
|
baseUrl: baseUrl,
|
|
headers: {'X-API-Key': apiKey},
|
|
contentType: 'application/json',
|
|
connectTimeout: const Duration(seconds: 10),
|
|
receiveTimeout: const Duration(seconds: 10),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<Response> get(String path) => _dio.get(path);
|
|
|
|
Future<Response> post(String path, Map<String, dynamic> body) =>
|
|
_dio.post(path, data: body);
|
|
|
|
Future<Response> put(String path, Map<String, dynamic> body) =>
|
|
_dio.put(path, data: body);
|
|
|
|
Future<Response> delete(String path) => _dio.delete(path);
|
|
}
|