api integration
This commit is contained in:
@@ -3,13 +3,28 @@ class ApiEndpoints {
|
||||
static const baseurl =
|
||||
"https://tanami.betadelivery.com/api/development/v1/"; //App Base url
|
||||
|
||||
//Country
|
||||
static const getcountryurl = "${baseurl}country/getAllCountry";
|
||||
|
||||
//Register
|
||||
static const requestotpapi = "${baseurl}auth/public/register";
|
||||
static const registerrequestapi = "${baseurl}auth/public/email-register";
|
||||
|
||||
//OTP
|
||||
static const requestresendotp = "${baseurl}auth/public/resend-otp";
|
||||
static const verifyotp = "${baseurl}auth/public/verify-otp";
|
||||
static const registerrequestapi = "${baseurl}auth/public/email-register";
|
||||
|
||||
//Biometric
|
||||
static const biometricUpdateapi = "${baseurl}auth/public/biometric-update";
|
||||
static const confirmpinapi="${baseurl}auth/public/masterPin";
|
||||
static const loginapi="${baseurl}auth/public/login";
|
||||
static const verifypinapi="${baseurl}auth/public/verify-materPin";
|
||||
|
||||
//PIN
|
||||
static const confirmpinapi = "${baseurl}auth/public/masterPin";
|
||||
static const verifypinapi = "${baseurl}auth/public/verify-materPin";
|
||||
|
||||
//Login
|
||||
static const loginapi = "${baseurl}auth/public/login";
|
||||
|
||||
//Forgot Password
|
||||
static const forgotPasswordApi = "${baseurl}auth/public/forgot-password";
|
||||
static const resetPasswordApi = "${baseurl}auth/public/reset-password";
|
||||
}
|
||||
|
||||
@@ -6,17 +6,22 @@ import 'package:flutter/foundation.dart';
|
||||
import '../../Api_Helper/base_manager.dart';
|
||||
|
||||
class NetworkApiService {
|
||||
final Dio _dio = Dio();
|
||||
final Dio _dio = Dio(BaseOptions(
|
||||
validateStatus: (status) {
|
||||
return status != null &&
|
||||
status < 500; // Allow any status code less than 500
|
||||
},
|
||||
));
|
||||
|
||||
// Common function for GET requests
|
||||
Future<ResponseData> get(String url,
|
||||
{Map<String, dynamic>? queryParameters}) async {
|
||||
if (kDebugMode) {
|
||||
if (kDebugMode) {
|
||||
print("api url is >>> $url");
|
||||
}
|
||||
Response response;
|
||||
try {
|
||||
response = await _dio.get(url);
|
||||
response = await _dio.get(url);
|
||||
if (response.statusCode == 201 || response.statusCode == 200) {
|
||||
return ResponseData<dynamic>("success", ResponseStatus.SUCCESS,
|
||||
data: response.data);
|
||||
@@ -29,10 +34,11 @@ class NetworkApiService {
|
||||
data: response.data,
|
||||
response.statusMessage!,
|
||||
ResponseStatus.FAILED);
|
||||
}}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
return ResponseData<dynamic>(
|
||||
"Something went wrong", ResponseStatus.FAILED);
|
||||
"Something went wrong", ResponseStatus.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,24 +49,48 @@ class NetworkApiService {
|
||||
print("api url is >>> $url");
|
||||
}
|
||||
try {
|
||||
var response= await _dio.post(url, data: data);
|
||||
if (response.statusCode == 201 || response.statusCode == 200) {
|
||||
return ResponseData<dynamic>("success", ResponseStatus.SUCCESS,
|
||||
var response = await _dio.post(
|
||||
url,
|
||||
data: data,
|
||||
);
|
||||
if (response.statusCode == 201 || response.statusCode == 200) {
|
||||
return ResponseData<dynamic>("success", ResponseStatus.SUCCESS,
|
||||
data: response.data);
|
||||
}else {
|
||||
} else if (response.statusCode == 400) {
|
||||
if (response.data['message'] == "Master Pin is not created") {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['message'], ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else if (response.data['error']['message'] ==
|
||||
"MASTER PIN NOT MATCH") {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['error']['message'], ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else if (response.data['error']['message'] ==
|
||||
"Account already exists. Please Login instead.") {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['error']['message'], ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['error']['message'], ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['message'].toString(), ResponseStatus.FAILED);
|
||||
response.data['error']['message'].toString(),
|
||||
ResponseStatus.FAILED);
|
||||
} catch (_) {
|
||||
return ResponseData<dynamic>(
|
||||
data: response.data,
|
||||
response.statusMessage!,
|
||||
ResponseStatus.FAILED);
|
||||
}}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
return ResponseData<dynamic>(
|
||||
"Oops something went wrong",
|
||||
ResponseStatus.FAILED);
|
||||
"Oops something went wrong", ResponseStatus.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user