update
This commit is contained in:
@@ -50,6 +50,9 @@ class Api {
|
||||
static String lockTest = BaseUrlBuilding + "api/V2/Authentication/LockUnlock";
|
||||
static String otp = "https://otp.thaibulksms.com/v2/otp/request";
|
||||
static String verify = "https://otp.thaibulksms.com/v2/otp/verify";
|
||||
static String otpEmail = BaseUrlCathay+"common/user_login/otp/";
|
||||
static String menuIcons = BaseUrlCathay+"common/icon";
|
||||
|
||||
static String banner = BaseUrlCathay + "common/banner/";
|
||||
static String promotion = BaseUrlCathay + "common/promotion/";
|
||||
static String getTokenAdmin = BaseUrlBuilding + "api/v3/User/Login";
|
||||
@@ -58,11 +61,11 @@ class Api {
|
||||
static String c2bConfirm = BaseUrlBuilding + "api/v2/Payment/transaction/confirmC2B";
|
||||
static String getTransaction = BaseUrlBuilding + "api/v2/Payment/getTransactionWeb";
|
||||
|
||||
static String BaseUrlBuildingCathay = "https://sathorn.cathay-pay.com/";
|
||||
static String payPromptPayInitial = BaseUrlBuildingCathay + "api/v2/EPaymentBBL/TransferedPromptPayIDInitial";
|
||||
static String payPromptPayConfirm = BaseUrlBuildingCathay + "api/v2/EPaymentBBL/TransferedPromptPayIDConfirm";
|
||||
static String payThaiInitial = BaseUrlBuildingCathay + "api/v2/EPaymentBBL/TransferedPromptPayQRInitial";
|
||||
static String payThaiConfirm = BaseUrlBuildingCathay + "api/v2/EPaymentBBL/TransferedPromptPayQRConfirm";
|
||||
// static String BaseUrlBuildingCathay = "https://sathorn.cathay-pay.com/";
|
||||
static String payPromptPayInitial = BaseUrlBuilding + "api/v2/EPaymentBBL/TransferedPromptPayIDInitial";
|
||||
static String payPromptPayConfirm = BaseUrlBuilding + "api/v2/EPaymentBBL/TransferedPromptPayIDConfirm";
|
||||
static String payThaiInitial = BaseUrlBuilding + "api/v2/EPaymentBBL/TransferedPromptPayQRInitial";
|
||||
static String payThaiConfirm = BaseUrlBuilding + "api/v2/EPaymentBBL/TransferedPromptPayQRConfirm";
|
||||
|
||||
static String user = BaseUrlBuilding + "api/v1/User";
|
||||
|
||||
@@ -192,6 +195,48 @@ class Api {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<dynamic> getRaw(BuildContext context, String url) async {
|
||||
try {
|
||||
http.Response response;
|
||||
|
||||
if (tokenModel != null) {
|
||||
printLongString("start api " + url + "\ntoken = " + tokenModel!.token!);
|
||||
Map<String, String> requestHeaders = {HttpHeaders.contentTypeHeader: "application/json", "Authorization": "Bearer ${tokenModel!.token!}"};
|
||||
print(requestHeaders.toString());
|
||||
response = await http.get(Uri.parse(url), headers: requestHeaders);
|
||||
} else {
|
||||
Map<String, String> requestHeaders = {HttpHeaders.contentTypeHeader: "application/json"};
|
||||
response = await http.get(Uri.parse(url), headers: requestHeaders);
|
||||
}
|
||||
printApiStatus(response);
|
||||
|
||||
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||
// final jsonResponse = json.decode(response.body);
|
||||
printLongString("response api ${response.body}");
|
||||
return response.body;
|
||||
} else if (response.statusCode == 401) {
|
||||
var value = await refreshToken(context);
|
||||
if (value != null) {
|
||||
var value = await get(context, url);
|
||||
return value;
|
||||
}
|
||||
} else {
|
||||
showAlertDialog(context, "กรุณาตรวจสอบ Internet ของท่าน");
|
||||
// showAlertDialog(context, response.body);
|
||||
try {
|
||||
// final jsonResponse = json.decode(response.body);
|
||||
print(response.body);
|
||||
return response.body;
|
||||
} catch (a) {
|
||||
print(a);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print(e);
|
||||
// showAlertDialog(context, e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
static Future<dynamic> postLogin(BuildContext context, String url, String jsonParam) async {
|
||||
printLongString(jsonParam);
|
||||
try {
|
||||
@@ -371,7 +416,7 @@ class Api {
|
||||
printLongString(jsonParam);
|
||||
try {
|
||||
var response;
|
||||
if (tokenModel != null) {
|
||||
if (tokenAdmin != null) {
|
||||
Map<String, String> requestHeaders = {HttpHeaders.contentTypeHeader: "application/json", "Authorization": "Bearer $tokenAdmin"};
|
||||
response = await http.post(Uri.parse(url), body: jsonParam, headers: requestHeaders);
|
||||
} else {
|
||||
@@ -379,7 +424,7 @@ class Api {
|
||||
response = await http.post(Uri.parse(url), body: jsonParam, headers: requestHeaders);
|
||||
}
|
||||
|
||||
// printApiStatus(response);
|
||||
printApiStatus(response);
|
||||
|
||||
if (response.statusCode == 200 || response.statusCode == 201 || response.statusCode == 204) {
|
||||
final jsonResponse = json.decode(response.body);
|
||||
|
||||
Reference in New Issue
Block a user