risk profile api
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -11,7 +12,9 @@ import 'base_api_services.dart';
|
||||
|
||||
class NetworkApiServices extends BaseApiServices {
|
||||
Dio dio = Dio();
|
||||
|
||||
String basicAuth = 'Basic ' +
|
||||
base64.encode(
|
||||
utf8.encode('traderCircuitUser:71%@L%es^bUX94`J9XT*@bh,._WWM{'));
|
||||
@override
|
||||
Future<ResponseData> getApi(String url, {bool isAuth = false}) async {
|
||||
if (kDebugMode) {
|
||||
@@ -19,13 +22,20 @@ class NetworkApiServices extends BaseApiServices {
|
||||
}
|
||||
Response response;
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token').toString();
|
||||
String? token = prefs.getString('accessToken').toString();
|
||||
log(token);
|
||||
try {
|
||||
response = await dio.get(url,
|
||||
options: Options(headers: {
|
||||
isAuth ? 'authorization' : "Bearer $token": "",
|
||||
}));
|
||||
options: (token == null || token == "")
|
||||
? Options(
|
||||
headers: {
|
||||
"Authorization": basicAuth,
|
||||
},
|
||||
)
|
||||
: Options(headers: {
|
||||
"Authorization": basicAuth,
|
||||
'access-token': token,
|
||||
}));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return ResponseData<dynamic>(
|
||||
@@ -62,13 +72,20 @@ class NetworkApiServices extends BaseApiServices {
|
||||
Response response;
|
||||
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token');
|
||||
String? token = prefs.getString('accessToken');
|
||||
try {
|
||||
response = await dio.post(url,
|
||||
data: data,
|
||||
options: Options(headers: {
|
||||
isAuth ? 'authorization' : "Bearer $token": "",
|
||||
}));
|
||||
options: (token == null || token == "")
|
||||
? Options(
|
||||
headers: {
|
||||
"Authorization": basicAuth,
|
||||
},
|
||||
)
|
||||
: Options(headers: {
|
||||
"Authorization": basicAuth,
|
||||
'access-token': token,
|
||||
}));
|
||||
} on Exception catch (e) {
|
||||
if (e is DioException) {
|
||||
log(e.response.toString());
|
||||
@@ -109,7 +126,7 @@ class NetworkApiServices extends BaseApiServices {
|
||||
}
|
||||
Response response;
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
String? token = prefs.getString('token').toString();
|
||||
String? token = prefs.getString('accessToken').toString();
|
||||
log(token);
|
||||
try {
|
||||
response = await dio.delete(url,
|
||||
|
||||
Reference in New Issue
Block a user