From d2b985a7ed724786b4eb28fecd9755bd34711690 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Thu, 12 Sep 2024 13:32:48 -0300 Subject: [PATCH] remove test api-service --- lib/backend/api_requests/api_service.dart | 69 ----------------------- 1 file changed, 69 deletions(-) delete mode 100644 lib/backend/api_requests/api_service.dart diff --git a/lib/backend/api_requests/api_service.dart b/lib/backend/api_requests/api_service.dart deleted file mode 100644 index f0d6d54e..00000000 --- a/lib/backend/api_requests/api_service.dart +++ /dev/null @@ -1,69 +0,0 @@ -import 'dart:convert'; -import 'dart:typed_data'; - -import 'package:dio/dio.dart'; -import 'package:flutter/foundation.dart'; - -class ApiService { - static const _baseUrl = 'https://freaccess.com.br/freaccess'; - - static final Dio _dio = Dio(BaseOptions( - baseUrl: _baseUrl, - // headers: {'Authorization': 'Bearer $_apiKey'}, - )); - - static Future makeApiCall({ - required String endpoint, - required Map body, - bool isMultipart = false, - Uint8List? file, - Uint8List? blob, - }) async { - try { - Response response; - if (isMultipart && file != null) { - FormData formData = FormData.fromMap(body); - formData.files.add(MapEntry('file', MultipartFile.fromBytes(file))); - response = await _dio.post(endpoint, data: formData); - } else if (blob != null) { - // Convert the blob to base64 string - String base64Image = base64Encode(blob); - - // Set the request headers - Map headers = { - 'Content-Type': 'application/json', - }; - - // Create the request body as JSON - Map requestBody = { - 'image': base64Image, - }; - - response = await _dio.post( - endpoint, - data: jsonEncode(requestBody), - options: Options(headers: headers), - ); - } else { - // Set the request headers - Map headers = { - 'Content-Type': 'application/json', - }; - - response = await _dio.post( - endpoint, - data: jsonEncode(body), - options: Options(headers: headers), - ); - } - debugPrint('API call to $endpoint successful'); - debugPrint('Api call body: $body'); - debugPrint('Response: ${response.data}'); - debugPrint('Response headers: ${response.headers}'); - debugPrint('Response status: ${response.statusCode}'); - return response; - } catch (e) { - rethrow; - } - } -}