io api settings api
This commit is contained in:
@@ -1,31 +1,48 @@
|
||||
class ApiEndpoints {
|
||||
static const base = "https://tanami.betadelivery.com/";
|
||||
static const baseurl =
|
||||
"https://tanami.betadelivery.com/api/development/v1/"; //App Base url
|
||||
static const base =
|
||||
"https://admin.tanami.betadelivery.com/"; //"https://tanami.betadelivery.com/";
|
||||
static const baseurl = "https://admin.tanami.betadelivery.com/api/v1/";
|
||||
// "https://tanami.betadelivery.com/api/development/v1/"; //App Base url
|
||||
|
||||
//Country
|
||||
static const getcountryurl = "${baseurl}country/getAllCountry";
|
||||
static const getcountryurl = "${baseurl}country/";
|
||||
|
||||
//Register
|
||||
static const requestotpapi = "${baseurl}auth/public/register";
|
||||
static const registerrequestapi = "${baseurl}auth/public/email-register";
|
||||
static const requestotpapi = "${baseurl}auth/user/register-mobileNumber";
|
||||
static const registerrequestapi = "${baseurl}auth/user/registration";
|
||||
|
||||
//OTP
|
||||
static const requestresendotp = "${baseurl}auth/public/resend-otp";
|
||||
static const verifyotp = "${baseurl}auth/public/verify-otp";
|
||||
static const requestresendotp = "${baseurl}auth/user/resend-otp";
|
||||
static const verifyotp = "${baseurl}auth/user/verified-otp";
|
||||
|
||||
//Biometric
|
||||
static const biometricUpdateapi = "${baseurl}auth/public/biometric-update";
|
||||
static const biometricLoginapi = "${baseurl}auth/public/biometric-login";
|
||||
static const biometricUpdateapi = "${baseurl}auth/user/set-biometric";
|
||||
static const biometricLoginapi = "${baseurl}auth/user/login-biometric";
|
||||
|
||||
//PIN
|
||||
static const confirmpinapi = "${baseurl}auth/public/masterPin";
|
||||
static const verifypinapi = "${baseurl}auth/public/verify-materPin";
|
||||
static const confirmpinapi = "${baseurl}auth/user/set-masterPin";
|
||||
static const verifypinapi = "${baseurl}auth/user/login-masterPin";
|
||||
static const updatePinApi = "${baseurl}auth/user/update-pin";
|
||||
|
||||
//Login
|
||||
static const loginapi = "${baseurl}auth/public/login";
|
||||
static const loginapi = "${baseurl}auth/user/login-password";
|
||||
|
||||
//Forgot Password
|
||||
static const forgotPasswordApi = "${baseurl}auth/public/forgot-password";
|
||||
static const resetPasswordApi = "${baseurl}auth/public/reset-password";
|
||||
//Password
|
||||
static const forgotPasswordApi = "${baseurl}auth/user/forgot-password";
|
||||
static const resetPasswordApi = "${baseurl}auth/user/reset-password";
|
||||
static const updatePasswordApi = "${baseurl}auth/user/update-password";
|
||||
|
||||
//Notification
|
||||
static const updateNotificationApi =
|
||||
"${baseurl}auth/user/update-notification";
|
||||
|
||||
//Language
|
||||
static const updateLanguageApi = "${baseurl}auth/user/update-language";
|
||||
|
||||
//Contact Admin
|
||||
static const contactAdminApi = "${baseurl}contactDetails/user/";
|
||||
|
||||
//IO
|
||||
static const availableIOApi = "${baseurl}io/available";
|
||||
static const closedIOApi = "${baseurl}io/closed";
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
// common_api.dart
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../Api_Helper/base_manager.dart';
|
||||
import '../../core/utils/secure/secure_storage_service.dart';
|
||||
|
||||
class NetworkApiService {
|
||||
final SecureStorageService secureStorageService = SecureStorageService();
|
||||
|
||||
final Dio _dio = Dio(BaseOptions(
|
||||
validateStatus: (status) {
|
||||
return status != null &&
|
||||
@@ -16,12 +21,18 @@ class NetworkApiService {
|
||||
// Common function for GET requests
|
||||
Future<ResponseData> get(String url,
|
||||
{Map<String, dynamic>? queryParameters}) async {
|
||||
String token = await secureStorageService.read("accesstoken") ?? "";
|
||||
if (kDebugMode) {
|
||||
print("api url is >>> $url");
|
||||
}
|
||||
Response response;
|
||||
try {
|
||||
response = await _dio.get(url);
|
||||
response = await _dio.get(url,
|
||||
options: (token == "")
|
||||
? Options()
|
||||
: Options(headers: {
|
||||
"x-auth-token": token,
|
||||
}));
|
||||
if (response.statusCode == 201 || response.statusCode == 200) {
|
||||
return ResponseData<dynamic>("success", ResponseStatus.SUCCESS,
|
||||
data: response.data);
|
||||
@@ -52,41 +63,30 @@ class NetworkApiService {
|
||||
|
||||
// Common function for POST requests
|
||||
Future<ResponseData> post(String url, dynamic data) async {
|
||||
String token = await secureStorageService.read("accesstoken") ?? "";
|
||||
log(token);
|
||||
if (kDebugMode) {
|
||||
print("data >>> $data");
|
||||
print("api url is >>> $url");
|
||||
}
|
||||
try {
|
||||
var response = await _dio.post(
|
||||
url,
|
||||
data: data,
|
||||
);
|
||||
var response = await _dio.post(url,
|
||||
data: data,
|
||||
options: (token == "")
|
||||
? Options()
|
||||
: Options(headers: {
|
||||
"x-auth-token": token,
|
||||
}));
|
||||
if (response.statusCode == 201 || response.statusCode == 200) {
|
||||
return ResponseData<dynamic>("success", ResponseStatus.SUCCESS,
|
||||
data: response.data);
|
||||
} 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);
|
||||
}
|
||||
return ResponseData<dynamic>(
|
||||
response.data['message'], ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else if (response.statusCode == 401) {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['error']['message'], ResponseStatus.PRIVATE,
|
||||
response.data['message'], ResponseStatus.PRIVATE,
|
||||
data: response.data);
|
||||
} else if (response.statusCode == 500) {
|
||||
return ResponseData<dynamic>(
|
||||
@@ -95,8 +95,7 @@ class NetworkApiService {
|
||||
} else {
|
||||
try {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['error']['message'].toString(),
|
||||
ResponseStatus.FAILED);
|
||||
response.data['message'].toString(), ResponseStatus.FAILED);
|
||||
} catch (_) {
|
||||
return ResponseData<dynamic>(
|
||||
data: response.data,
|
||||
|
||||
Reference in New Issue
Block a user