Commit 40acdcbf authored by Dio Maulana's avatar Dio Maulana

set pin and timeout for 10seconds

parent 462b1b21
...@@ -30,7 +30,6 @@ class Api { ...@@ -30,7 +30,6 @@ class Api {
return ApiResponse(error: true, msg: Strings.cantConnectToServer); return ApiResponse(error: true, msg: Strings.cantConnectToServer);
} else { } else {
if (jsonObject['status'] == "ok") { if (jsonObject['status'] == "ok") {
print(jsonObject);
List<BranchModel> branchList = []; List<BranchModel> branchList = [];
List<dynamic> branchs = jsonObject['data']['branch_list']; List<dynamic> branchs = jsonObject['data']['branch_list'];
...@@ -108,7 +107,8 @@ class Api { ...@@ -108,7 +107,8 @@ class Api {
} }
} }
static Future<ApiResponse> getUserProfile(String branchId, String nik) async { static Future<ApiResponse> getUserProfile(
String branchId, String nik, String pin) async {
String apiUrl = "$baseUrl${endPoint}profile_user"; String apiUrl = "$baseUrl${endPoint}profile_user";
try { try {
...@@ -116,6 +116,7 @@ class Api { ...@@ -116,6 +116,7 @@ class Api {
"branch_id": branchId, "branch_id": branchId,
"nik": nik, "nik": nik,
"brand_code": brandCode, "brand_code": brandCode,
"pin": pin,
}; };
String bodies = jsonEncode(data); String bodies = jsonEncode(data);
dynamic jsonObject = dynamic jsonObject =
...@@ -124,7 +125,6 @@ class Api { ...@@ -124,7 +125,6 @@ class Api {
return ApiResponse(error: true, msg: Strings.cantConnectToServer); return ApiResponse(error: true, msg: Strings.cantConnectToServer);
} else { } else {
if (jsonObject['status'] == "ok") { if (jsonObject['status'] == "ok") {
print(jsonObject);
Map<String, dynamic> user = jsonObject['data']['user']; Map<String, dynamic> user = jsonObject['data']['user'];
return ApiResponse( return ApiResponse(
error: false, error: false,
...@@ -250,15 +250,18 @@ int typePost = 2; ...@@ -250,15 +250,18 @@ int typePost = 2;
Future<dynamic> httpRequest(int typeRequest, String apiUrl, String namaFungsi, Future<dynamic> httpRequest(int typeRequest, String apiUrl, String namaFungsi,
{String? bodies = ''}) async { {String? bodies = ''}) async {
int timeOut = 10;
dynamic apiResult; dynamic apiResult;
if (typeRequest == typePost) { if (typeRequest == typePost) {
apiResult = await http.post(Uri.parse(apiUrl), apiResult = await http
headers: {"Content-Type": "application/json"}, body: bodies); .post(Uri.parse(apiUrl),
headers: {"Content-Type": "application/json"}, body: bodies)
.timeout(Duration(seconds: timeOut));
} else if (typeRequest == typeGet) { } else if (typeRequest == typeGet) {
apiResult = await http.get( apiResult = await http.get(
Uri.parse(apiUrl), Uri.parse(apiUrl),
headers: {"Content-Type": "application/json"}, headers: {"Content-Type": "application/json"},
); ).timeout(Duration(seconds: timeOut));
} else { } else {
if (debug) { if (debug) {
logd('HTTP REQUEST', 'TIPE REQUEST TIDAK VALID'); logd('HTTP REQUEST', 'TIPE REQUEST TIDAK VALID');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment