set up business
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:mzansi_innovation_hub/mih_env/env.dart';
|
||||
@@ -7,6 +8,47 @@ import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
class MihBusinessDetailsApi {
|
||||
Future<Response> createBusinessDetails(
|
||||
String appId,
|
||||
String busineName,
|
||||
String businessType,
|
||||
String businessRegistrationNo,
|
||||
String businessPracticeNo,
|
||||
String businessVatNo,
|
||||
String businessEmail,
|
||||
String businessPhoneNumber,
|
||||
String businessLocation,
|
||||
String businessLogoFilename,
|
||||
BuildContext context,
|
||||
) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
var response = await http.post(
|
||||
Uri.parse("${AppEnviroment.baseApiUrl}/business/insert/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"Name": busineName,
|
||||
"type": businessType,
|
||||
"registration_no": businessRegistrationNo,
|
||||
"logo_name": businessLogoFilename,
|
||||
"logo_path": "$appId/business_files/$businessLogoFilename",
|
||||
"contact_no": businessPhoneNumber,
|
||||
"bus_email": businessEmail,
|
||||
"gps_location": businessLocation,
|
||||
"practice_no": businessPracticeNo,
|
||||
"vat_no": businessVatNo,
|
||||
}),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<int> updateBusinessDetails(
|
||||
String business_id,
|
||||
String business_name,
|
||||
|
||||
@@ -42,10 +42,13 @@ class MihFileApi {
|
||||
var decodedData = jsonDecode(response.body);
|
||||
fileUrl = decodedData['minioURL'];
|
||||
} else {
|
||||
internetConnectionPopUp(context);
|
||||
// internetConnectionPopUp(context);
|
||||
print("Error: ${response.statusCode}");
|
||||
print("Error: ${response.body}");
|
||||
}
|
||||
} catch (e) {
|
||||
internetConnectionPopUp(context);
|
||||
// internetConnectionPopUp(context);
|
||||
print("Error getting url");
|
||||
} finally {
|
||||
// Navigator.of(context).pop(); // Always pop loading dialog
|
||||
}
|
||||
|
||||
@@ -7,8 +7,45 @@ import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||
import 'package:supertokens_flutter/http.dart' as http;
|
||||
|
||||
class MihMyBusinessUserApi {
|
||||
Future<int> createBusinessUser(
|
||||
String business_id,
|
||||
String app_id,
|
||||
String signatureFilename,
|
||||
String title,
|
||||
String access,
|
||||
BuildContext context,
|
||||
) async {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return const Mihloadingcircle();
|
||||
},
|
||||
);
|
||||
var response = await http.post(
|
||||
Uri.parse("${AppEnviroment.baseApiUrl}/business-user/insert/"),
|
||||
headers: <String, String>{
|
||||
"Content-Type": "application/json; charset=UTF-8"
|
||||
},
|
||||
body: jsonEncode(<String, dynamic>{
|
||||
"business_id": business_id,
|
||||
"app_id": app_id,
|
||||
"signature": signatureFilename,
|
||||
"sig_path": "$business_id/business_files/$signatureFilename",
|
||||
"title": title,
|
||||
"access": access,
|
||||
}),
|
||||
);
|
||||
Navigator.of(context).pop();
|
||||
if (response.statusCode == 201) {
|
||||
return 201;
|
||||
} else {
|
||||
internetConnectionPopUp(context);
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
|
||||
/// This function updates the business user details.
|
||||
Future<int> updateBusinessDetails(
|
||||
Future<int> updateBusinessUser(
|
||||
String app_id,
|
||||
String business_id,
|
||||
String bUserTitle,
|
||||
|
||||
Reference in New Issue
Block a user