Untitled
unknown
plain_text
2 years ago
4.0 kB
1
Indexable
Never
import 'dart:convert'; import 'dart:developer'; import 'package:QanatiApp/Utilities/Constant/APIs.dart'; import 'package:http/http.dart' as http; class ResponseStatus { String abuHejleh = "5d39d6c6-d5c2-4764-861d-ce7ce4c3ce58"; String alHyari = "e6de64ee-4375-45e3-915a-0ae7ae8f7160"; String abuHejlehAuth1 = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9zaWQiOiI1ZDM5ZDZjNi1kNWMyLTQ3NjQtODYxZC1jZTdjZTRjM2NlNTgiLCJ1bmlxdWVfbmFtZSI6ImFoaWpsZWhAaXRzb2x1dGlvbnMtbm93LmNvbSIsIm5hbWVpZCI6ImFoaWpsZWhAaXRzb2x1dGlvbnMtbm93LmNvbSIsImVtYWlsIjoiYWhpamxlaEBpdHNvbHV0aW9ucy1ub3cuY29tIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvbW9iaWxlcGhvbmUiOiIwMTU5MDg3MDQyMjIiLCJnaXZlbl9uYW1lIjoiYWhpamxlaEBpdHNvbHV0aW9ucy1ub3cuY29tIiwiaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvd3MvMjAwNS8wNS9pZGVudGl0eS9jbGFpbXMvYXV0aG9yaXphdGlvbmRlY2lzaW9uIjoiUHJvdmlkZXIiLCJyb2xlIjoicHJvdmlkZXIiLCJuYmYiOjE2NTYzMDcyMzMsImV4cCI6MTY1OTMwNzIzMywiaWF0IjoxNjU2MzA3MjMzLCJpc3MiOiJodHRwOi8vTEItUm95YS0xOTI0NTAzMTYzLnVzLWVhc3QtMi5lbGIuYW1hem9uYXdzLmNvbToyMzAvIiwiYXVkIjoiaHR0cDovL0xCLVJveWEtMTkyNDUwMzE2My51cy1lYXN0L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Is Future<http.Response> post( {required var body, required String subUrl}) async { http.Response response = await http.post(Uri.parse(baseUrl + subUrl), body: json.encode(body), headers: { 'Content-Type': 'application/json', "Authorization": abuHejlehAuth1 }); return response; } //* SHARED Get FOR ALL APIs Future<dynamic> get({required String subUrl, String? customUrl}) async { try { var link = Uri.parse((customUrl ?? baseUrl) + subUrl); http.Response response = await http.get(link, headers: { 'Content-Type': 'application/json', "Authorization": abuHejlehAuth1 }); if (response.statusCode == 200) { return json.decode(response.body); } else { throw Exception("Get - $subUrl" + response.statusCode.toString()); } } catch (e) { log(e.toString()); } } //* SHARED Delete FOR ALL APIs Future<http.Response> delete({required String subUrl}) async { http.Response response = await http.delete(Uri.parse(baseUrl + subUrl), headers: { 'Content-Type': 'application/json', "Authorization": abuHejlehAuth1 }); log("delete message :: response ${response.statusCode}"); return response; } //* SHARED Put FOR ALL APIs Future<http.Response> put({var body, required String subUrl}) async { http.Response response = await http.put(Uri.parse(baseUrl + subUrl), body: body != null ? json.encode(body) : null, headers: { 'Content-Type': 'application/json', "Authorization": abuHejlehAuth1 }); return response; } }