bookgmt_api_package 0.1.2
bookgmt_api_package: ^0.1.2 copied to clipboard
A booking app API (Application Programming Interface) is a set of rules and protocols that defines how two or more systems can interact with each other.
example/main.dart
// import 'package:bookgmt_api_package/api/service/handler/index.dart';
import 'package:bookgmt_api_package/src/models/index.dart';
import 'package:bookgmt_api_package/src/request_handler/index.dart';
// create main function
// void main() async{
// // create a user instance
// final user = User.instance;
// // set the user data
// user.userData =
// UserModel(
// id: '5f9f1c1c1c9d440000f1b1b1',
// name: NameModel(
// first: 'John',
// last: 'Doe',
// ),
// email: ' ser@gmail.com',
// phone: '1234567890',
// provider: AuthProvider.google,
// avatar: 'https://www.gravatar.com/avatar/205e460b479e2e5b48aec07710c08d50',
// status: StatusModel(
// hasBusiness: false,
// ),
// role: RoleModel(
// isAdmin: false,
// ),
// socialIdentityId: null,
// otp: OTPModel(
// code: '123456',
// expiresAt: DateTime.now().add(const Duration(minutes: 5)),
// ),
// );
// // print the user data
// print(user.userData.toJson());
// final user2 = User.instance;
// print(user2.userData.name?.first);
//
// // create a service instance
// final service = Services.instance;
// // set the service data
// service.services = <ServiceModel>[ServiceModel(
// id: '5f9f1c1c1c9d440000f1b1b1',
// duration: 60,
// businessId: '5f9f1c1c1c9d440000f1b1b1',
// categoryId: '5f9f1c1c1c9d440000f1b1b1',
// customStyle: [
// CustomStyleModel(
// styleCategory: StyleType.color,
// name: StyleNames.colored,
// price: 100,
// ),
// ],
// description: 'description',
// name: 'African Braids',
// price: 100,
// hasCustomStyle: true,
// subServices: [
// SubServiceModel(
// id: '5f9f1c1c1c9d440000f1b1b1',
// name: 'name',
// price: 100,
// hasCustomStyle: true,
// categoryId: '5f9f1c1c1c9d440000f1b1b1',
// businessId: '5f9f1c1c1c9d440000f1b1b1',
// customStyle: [
// CustomStyleModel(
// styleCategory: StyleType.color,
// name: StyleNames.colored,
// price: 100,
// ),
// CustomStyleModel(
// styleCategory: StyleType.size,
// name: StyleNames.jumbo,
// price: 100,
// ),
// ],
// ), SubServiceModel(
// id: '5f9f1c1c1c9d440000f1db1b1',
// name: 'name',
// price: 100,
// description: 'description',
// discount: [
// DiscountModel(
// name: 'discount',
// price: 30,
// percentage:0.5,
// businessId: '5f9f1c1c1c9d440000f1b1b1',
// endDate: DateTime.now().add(const Duration(days: 5)),
// ),
// ],
// hasCustomStyle: true,
// categoryId: '5f9f1c1c1c9d440d000f1b1b1',
// businessId: '5f9f1c1c1c9d440w000f1b1b1',
// customStyle: [
// CustomStyleModel(
// styleCategory: StyleType.length,
// name: StyleNames.shoulder,
// price: 200,
// ),
// ],
// ),
// ],
//
// )
// ];
// // print the service data
// // print(service.services?[0].toString());
// final service2 = Services.instance;
// // print(service2.services?[0].subServices?[0].toString());
// service.selectedService = service.services?[0];
// final service3 = Services.instance;
// print('selected service: ${service3.selectedService?.toString()}');
//
// final result = await makeRequest(
// method: HttpMethod.GET,
// endPoint: 'https://jsonplaceholder.typicode.com/todos/1',
// );
// print(result);
// }
void main() async {
final user = User.instance;
final response = await user.loginWithEmail('alwisestudio@gmail.com', 'sena1234#');
// /// print type of response header property
// print(response.headers.runtimeType);
// printghh('response: ${response.data}');
// writeCookie(response.headers['set-cookie']);
// ///read file
// final file = readCookie();
//
// print('file: $file');
final business = Business.instance;
final response2 = await business.getBusinessByOwnerId('d131932b-85b6-4769-80ed-2ab4da2f65b9');
print('response: $response2');
// user.userData = UserModel.fromJson({'createdAt': '2023-01-05T00:43:08.880Z', 'updatedAt':' 2023-01-05T00:43:08.880Z', 'id': '10473cc0-ce08-406d-87ee-9410efa01156', 'email': 'sena9@gmail.com', 'phone': null, 'provider': 'email', 'avatar': null, 'status': {'isBlocked': false, 'isDeleted': false, 'isVerified': true, 'hasBusiness': false, 'isSocialLogin': false, 'isEmailVerified': true, 'isPhoneVerified': false}, 'socialIdentityId': null, 'otp': null, 'deletedAt': null});
// 'name': {'last': 'Alwise', 'first': 'Sena', 'display': 'Sena' 'Alwise'},
//'role': {'isAdmin': false, 'isClient': true, 'isBusiness': false},
// print(user.userData.toJson());
}