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

set pin and timeout for 10seconds

parent 462b1b21
......@@ -30,7 +30,6 @@ class Api {
return ApiResponse(error: true, msg: Strings.cantConnectToServer);
} else {
if (jsonObject['status'] == "ok") {
print(jsonObject);
List<BranchModel> branchList = [];
List<dynamic> branchs = jsonObject['data']['branch_list'];
......@@ -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";
try {
......@@ -116,6 +116,7 @@ class Api {
"branch_id": branchId,
"nik": nik,
"brand_code": brandCode,
"pin": pin,
};
String bodies = jsonEncode(data);
dynamic jsonObject =
......@@ -124,7 +125,6 @@ class Api {
return ApiResponse(error: true, msg: Strings.cantConnectToServer);
} else {
if (jsonObject['status'] == "ok") {
print(jsonObject);
Map<String, dynamic> user = jsonObject['data']['user'];
return ApiResponse(
error: false,
......@@ -250,15 +250,18 @@ int typePost = 2;
Future<dynamic> httpRequest(int typeRequest, String apiUrl, String namaFungsi,
{String? bodies = ''}) async {
int timeOut = 10;
dynamic apiResult;
if (typeRequest == typePost) {
apiResult = await http.post(Uri.parse(apiUrl),
headers: {"Content-Type": "application/json"}, body: bodies);
apiResult = await http
.post(Uri.parse(apiUrl),
headers: {"Content-Type": "application/json"}, body: bodies)
.timeout(Duration(seconds: timeOut));
} else if (typeRequest == typeGet) {
apiResult = await http.get(
Uri.parse(apiUrl),
headers: {"Content-Type": "application/json"},
);
).timeout(Duration(seconds: timeOut));
} else {
if (debug) {
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