Files
numstation-flutter/lib/backend/api_requests/api_calls.dart
2023-12-27 16:10:09 +08:00

1160 lines
30 KiB
Dart

import 'dart:convert';
import 'dart:typed_data';
import '/flutterlib/flutter_util.dart';
import 'api_manager.dart';
export 'api_manager.dart' show ApiCallResponse;
const _kPrivateApiFunctionName = 'ffPrivateApiCall';
/// Start Numstation Group Code
class NumstationGroup {
static String baseUrl = 'https://numstation.bepto.io';
static Map<String, String> headers = {};
static LoginCall loginCall = LoginCall();
static RefreshTokenCall refreshTokenCall = RefreshTokenCall();
static SendOTPCall sendOTPCall = SendOTPCall();
static SubmitOTPCall submitOTPCall = SubmitOTPCall();
static ResetPasswordCall resetPasswordCall = ResetPasswordCall();
static RegisterCall registerCall = RegisterCall();
static GetRolesCall getRolesCall = GetRolesCall();
static PrivacyPolicyCall privacyPolicyCall = PrivacyPolicyCall();
static TermsAndConditionsCall termsAndConditionsCall =
TermsAndConditionsCall();
static ChangePasswordCall changePasswordCall = ChangePasswordCall();
static LogoutCall logoutCall = LogoutCall();
static ToggleNotifiactionStatusCall toggleNotifiactionStatusCall =
ToggleNotifiactionStatusCall();
static GetNotificationsSettingsCall getNotificationsSettingsCall =
GetNotificationsSettingsCall();
static UserListCall userListCall = UserListCall();
static GetUserDetailsCall getUserDetailsCall = GetUserDetailsCall();
static CreateUserCall createUserCall = CreateUserCall();
static UpdateUserCall updateUserCall = UpdateUserCall();
static RoleListCall roleListCall = RoleListCall();
static DeleteUserCall deleteUserCall = DeleteUserCall();
static AccessLogsCall accessLogsCall = AccessLogsCall();
static GroupPermissionsCall groupPermissionsCall = GroupPermissionsCall();
static GetPermissionOfRoleCall getPermissionOfRoleCall =
GetPermissionOfRoleCall();
static AddPermissionToRoleCall addPermissionToRoleCall =
AddPermissionToRoleCall();
static RemovePermissionToRoleCall removePermissionToRoleCall =
RemovePermissionToRoleCall();
static CheckRoleHasPermissionCall checkRoleHasPermissionCall =
CheckRoleHasPermissionCall();
static GetCompanyDetailsCall getCompanyDetailsCall = GetCompanyDetailsCall();
static DeleteMemberDocumentCall deleteMemberDocumentCall =
DeleteMemberDocumentCall();
static SaveOrUpdateMemberCall saveOrUpdateMemberCall =
SaveOrUpdateMemberCall();
static UpdateCompanyDetailsCall updateCompanyDetailsCall =
UpdateCompanyDetailsCall();
static DocumentListCall documentListCall = DocumentListCall();
static DocumentCategoriesCall documentCategoriesCall =
DocumentCategoriesCall();
static ViewDocumentCall viewDocumentCall = ViewDocumentCall();
static AddDocumentCall addDocumentCall = AddDocumentCall();
static DocumentLibrarySearchCall documentLibrarySearchCall =
DocumentLibrarySearchCall();
}
class LoginCall {
Future<ApiCallResponse> call({
String? email = '',
String? password = '',
}) async {
final ffApiRequestBody = '''
{
"email": "${email}",
"password": "${password}"
}''';
return ApiManager.instance.makeApiCall(
callName: 'login',
apiUrl: '${NumstationGroup.baseUrl}/api/login',
callType: ApiCallType.POST,
headers: {
'Content-Type': 'application/json',
},
params: {},
body: ffApiRequestBody,
bodyType: BodyType.JSON,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
String? token(dynamic response) => castToType<String>(getJsonField(
response,
r'''$.access_token''',
));
}
class RefreshTokenCall {
Future<ApiCallResponse> call({
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'refreshToken',
apiUrl: '${NumstationGroup.baseUrl}/api/refresh',
callType: ApiCallType.POST,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${token}',
},
params: {},
bodyType: BodyType.JSON,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class SendOTPCall {
Future<ApiCallResponse> call({
String? email = '',
String? token = '',
}) async {
final ffApiRequestBody = '''
{
"email": "${email}"
}''';
return ApiManager.instance.makeApiCall(
callName: 'sendOTP',
apiUrl: '${NumstationGroup.baseUrl}/api/forgot-password/send-otp',
callType: ApiCallType.POST,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${token}',
},
params: {},
body: ffApiRequestBody,
bodyType: BodyType.JSON,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
String? sentOTPmessage(dynamic response) => castToType<String>(getJsonField(
response,
r'''$.message''',
));
}
class SubmitOTPCall {
Future<ApiCallResponse> call({
int? otp,
String? token = '',
}) async {
final ffApiRequestBody = '''
{
"otp": "${otp}",
"token": "${token}"
}''';
return ApiManager.instance.makeApiCall(
callName: 'submitOTP',
apiUrl: '${NumstationGroup.baseUrl}/api/forgot-password/submit-otp',
callType: ApiCallType.POST,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${token}',
},
params: {},
body: ffApiRequestBody,
bodyType: BodyType.JSON,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
dynamic useridRP(dynamic response) => getJsonField(
response,
r'''$.user_id''',
);
dynamic submitOTPmessage(dynamic response) => getJsonField(
response,
r'''$.message''',
);
}
class ResetPasswordCall {
Future<ApiCallResponse> call({
int? userId,
String? password = '',
String? passwordConfirmation = '',
String? token = '',
}) async {
final ffApiRequestBody = '''
{
"user_id": ${userId},
"password": "${password}",
"password_confirmation": "${passwordConfirmation}",
"token": "${token}"
}''';
return ApiManager.instance.makeApiCall(
callName: 'resetPassword',
apiUrl: '${NumstationGroup.baseUrl}/api/forgot-password/reset-password',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
body: ffApiRequestBody,
bodyType: BodyType.JSON,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class RegisterCall {
Future<ApiCallResponse> call({
String? firstName = '',
String? lastName = '',
String? email = '',
int? phone,
String? password = '',
String? passwordConfirmation = '',
int? roleId,
}) async {
final ffApiRequestBody = '''
{
"first_name": "${firstName}",
"last_name": "${lastName}",
"email": "${email}",
"phone": "${phone}",
"password": "${password}",
"password_confirmation": "${passwordConfirmation}",
"role_id": "${roleId}"
}''';
return ApiManager.instance.makeApiCall(
callName: 'register',
apiUrl: '${NumstationGroup.baseUrl}/api/register',
callType: ApiCallType.POST,
headers: {
'Content-Type': 'application/json',
},
params: {},
body: ffApiRequestBody,
bodyType: BodyType.JSON,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class GetRolesCall {
Future<ApiCallResponse> call() async {
return ApiManager.instance.makeApiCall(
callName: 'getRoles',
apiUrl: '${NumstationGroup.baseUrl}/api/register/get-roles',
callType: ApiCallType.POST,
headers: {
'Content-Type': 'application/json',
},
params: {},
bodyType: BodyType.JSON,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
List<int>? rolesID(dynamic response) => (getJsonField(
response,
r'''$.roles[:].id''',
true,
) as List?)
?.withoutNulls
.map((x) => castToType<int>(x))
.withoutNulls
.toList();
List? roles(dynamic response) => getJsonField(
response,
r'''$.roles''',
true,
) as List?;
List? rolesName(dynamic response) => getJsonField(
response,
r'''$.roles[:].display_name''',
true,
) as List?;
}
class PrivacyPolicyCall {
Future<ApiCallResponse> call() async {
return ApiManager.instance.makeApiCall(
callName: 'Privacy Policy',
apiUrl: '${NumstationGroup.baseUrl}/api/get-privacy-policy',
callType: ApiCallType.GET,
headers: {},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class TermsAndConditionsCall {
Future<ApiCallResponse> call() async {
return ApiManager.instance.makeApiCall(
callName: 'Terms and Conditions',
apiUrl: '${NumstationGroup.baseUrl}/api/get-terms-and-conditions',
callType: ApiCallType.GET,
headers: {},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class ChangePasswordCall {
Future<ApiCallResponse> call({
String? password = '',
String? newPassword = '',
String? newPasswordConfirmation = '',
String? token = '',
}) async {
final ffApiRequestBody = '''
{
"password": "${password}",
"new_password": "${newPassword}",
"new_password_confirmation": "${newPasswordConfirmation}"
}''';
return ApiManager.instance.makeApiCall(
callName: 'change password',
apiUrl: '${NumstationGroup.baseUrl}/api/settings/change-password',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
body: ffApiRequestBody,
bodyType: BodyType.JSON,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class LogoutCall {
Future<ApiCallResponse> call({
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'logout',
apiUrl: '${NumstationGroup.baseUrl}/api/logout',
callType: ApiCallType.POST,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${token}',
},
params: {},
bodyType: BodyType.JSON,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class ToggleNotifiactionStatusCall {
Future<ApiCallResponse> call({
String? token = '',
bool? notification,
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Toggle Notifiaction Status',
apiUrl:
'${NumstationGroup.baseUrl}/api/settings/toggle-notification-status',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'notification': "user_push_notification",
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class GetNotificationsSettingsCall {
Future<ApiCallResponse> call({
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Get Notifications Settings',
apiUrl:
'${NumstationGroup.baseUrl}/api/settings/get-notification-settings',
callType: ApiCallType.GET,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class UserListCall {
Future<ApiCallResponse> call({
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'User List',
apiUrl: '${NumstationGroup.baseUrl}/api/users/list',
callType: ApiCallType.GET,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
List? username(dynamic response) => getJsonField(
response,
r'''$.company_users[:].name''',
true,
) as List?;
List? role(dynamic response) => getJsonField(
response,
r'''$.company_users[:].user_role.display_name''',
true,
) as List?;
List? email(dynamic response) => getJsonField(
response,
r'''$.company_users[:].email''',
true,
) as List?;
List? status(dynamic response) => getJsonField(
response,
r'''$.company_users[:].user_role.status''',
true,
) as List?;
}
class GetUserDetailsCall {
Future<ApiCallResponse> call({
String? token = '',
int? id,
}) async {
return ApiManager.instance.makeApiCall(
callName: 'getUserDetails',
apiUrl: '${NumstationGroup.baseUrl}/api/users/data/${id}',
callType: ApiCallType.GET,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class CreateUserCall {
Future<ApiCallResponse> call({
String? email = '',
String? firstName = '',
String? lastName = '',
String? password = '',
int? phone,
String? roleId = '',
String? status = '',
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'create user',
apiUrl: '${NumstationGroup.baseUrl}/api/users/create',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'email': email,
'first_name': firstName,
'last_name': lastName,
'password': password,
'phone': phone,
'role_id': roleId,
'status': status,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class UpdateUserCall {
Future<ApiCallResponse> call({
String? token = '',
String? email = '',
String? firstName = '',
String? lastName = '',
int? phone,
String? roleId = '',
String? status = '',
int? userId,
}) async {
return ApiManager.instance.makeApiCall(
callName: 'update user',
apiUrl: '${NumstationGroup.baseUrl}/api/users/update',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'email': email,
'first_name': firstName,
'last_name': lastName,
'phone': phone,
'role_id': roleId,
'status': status,
'user_id': userId,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class RoleListCall {
Future<ApiCallResponse> call({
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Role List',
apiUrl: '${NumstationGroup.baseUrl}/api/users/role/list',
callType: ApiCallType.GET,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
List? rolesID(dynamic response) => getJsonField(
response,
r'''$.roles[:].id''',
true,
) as List?;
List? rolesAccessLevel(dynamic response) => getJsonField(
response,
r'''$.roles[:].access_level''',
true,
) as List?;
List? rolesStatus(dynamic response) => getJsonField(
response,
r'''$.roles[:].status''',
true,
) as List?;
List? rolesDisplayName(dynamic response) => getJsonField(
response,
r'''$.roles[:].display_name''',
true,
) as List?;
}
class DeleteUserCall {
Future<ApiCallResponse> call({
String? token = '',
int? userId,
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Delete User',
apiUrl: '${NumstationGroup.baseUrl}/api/users/delete',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'user_id': userId,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class AccessLogsCall {
Future<ApiCallResponse> call({
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Access logs',
apiUrl: '${NumstationGroup.baseUrl}/api/users/access/logs',
callType: ApiCallType.GET,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class GroupPermissionsCall {
Future<ApiCallResponse> call({
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Group Permissions',
apiUrl: '${NumstationGroup.baseUrl}/api/users/permission/group',
callType: ApiCallType.GET,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
bool? access(dynamic response) => castToType<bool>(getJsonField(
response,
r'''$.status''',
));
List<int>? roleID(dynamic response) => (getJsonField(
response,
r'''$.group[:].id''',
true,
) as List?)
?.withoutNulls
.map((x) => castToType<int>(x))
.withoutNulls
.toList();
List<int>? permissionID(dynamic response) => (getJsonField(
response,
r'''$.group[:].permissions[:].id''',
true,
) as List?)
?.withoutNulls
.map((x) => castToType<int>(x))
.withoutNulls
.toList();
List<String>? permissionName(dynamic response) => (getJsonField(
response,
r'''$.group[:].permissions[:].display_name''',
true,
) as List?)
?.withoutNulls
.map((x) => castToType<String>(x))
.withoutNulls
.toList();
List<String>? roleName(dynamic response) => (getJsonField(
response,
r'''$.group[:].name''',
true,
) as List?)
?.withoutNulls
.map((x) => castToType<String>(x))
.withoutNulls
.toList();
List? permissionList(dynamic response) => getJsonField(
response,
r'''$.group''',
true,
) as List?;
}
class GetPermissionOfRoleCall {
Future<ApiCallResponse> call({
String? token = '',
String? roleId = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Get Permission of Role',
apiUrl: '${NumstationGroup.baseUrl}/api/users/role/permission/${roleId}',
callType: ApiCallType.GET,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'role_id': roleId,
},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
List<int>? getPermissionsID(dynamic response) => (getJsonField(
response,
r'''$.permission[:].permission_id''',
true,
) as List?)
?.withoutNulls
.map((x) => castToType<int>(x))
.withoutNulls
.toList();
}
class AddPermissionToRoleCall {
Future<ApiCallResponse> call({
String? token = '',
String? roleId = '',
String? permissionId = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Add permission to role',
apiUrl: '${NumstationGroup.baseUrl}/api/users/role/add/permission',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'role_id': roleId,
'permission_id': permissionId,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class RemovePermissionToRoleCall {
Future<ApiCallResponse> call({
String? token = '',
String? roleId = '',
String? permissionId = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Remove Permission to role',
apiUrl: '${NumstationGroup.baseUrl}/api/users/role/remove/permission',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'role_id': roleId,
'permission_id': permissionId,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class CheckRoleHasPermissionCall {
Future<ApiCallResponse> call({
String? token = '',
String? roleId = '',
int? permissionId,
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Check role has permission',
apiUrl: '${NumstationGroup.baseUrl}/api/users/role/has/permission',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'role_id': roleId,
'permission_id': permissionId,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class GetCompanyDetailsCall {
Future<ApiCallResponse> call({
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Get Company Details',
apiUrl: '${NumstationGroup.baseUrl}/api/company/details',
callType: ApiCallType.GET,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class DeleteMemberDocumentCall {
Future<ApiCallResponse> call({
String? token = '',
int? id,
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Delete Member Document',
apiUrl: '${NumstationGroup.baseUrl}/api/company/delete/member/file',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'id': id,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class SaveOrUpdateMemberCall {
Future<ApiCallResponse> call({
String? token = '',
int? companyId,
String? position = '',
String? title = '',
String? nameEnglish = '',
String? nameChinese = '',
String? email = '',
int? phone,
String? documentType = '',
String? country = '',
String? addressEnglish = '',
String? addressChinese = '',
String? yearDate = '',
String? monthDate = '',
String? dayDate = '',
String? documentNumber = '',
int? memberId,
String? city = '',
FFUploadedFile? documentFile,
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Save or Update Member',
apiUrl: '${NumstationGroup.baseUrl}/api/company/save/member',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'company_id': companyId,
'position': position,
'title': title,
'name_english': nameEnglish,
'name_chinese': nameChinese,
'phone': phone,
'email': email,
'document_type': documentType,
'country': country,
'address_english': addressEnglish,
'address_chinese': addressChinese,
'year_date': yearDate,
'month_date': monthDate,
'day_date': dayDate,
'document_number': documentNumber,
'member_id': memberId,
'document_file': documentFile,
'city': city,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class UpdateCompanyDetailsCall {
Future<ApiCallResponse> call({
String? token = '',
String? nameEnglish = '',
String? nameChinese = '',
String? registeredOfficeAddressEnglish = '',
String? registeredOfficeAddressChinese = '',
int? brNumber,
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Update Company Details',
apiUrl: '${NumstationGroup.baseUrl}/api/company/save/details',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'name_english': nameEnglish,
'name_chinese': nameChinese,
'registered_office_address_english': registeredOfficeAddressEnglish,
'registered_office_address_chinese': registeredOfficeAddressChinese,
'br_number': brNumber,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class DocumentListCall {
Future<ApiCallResponse> call({
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Document List',
apiUrl: '${NumstationGroup.baseUrl}/api/bookkeeping/document/list',
callType: ApiCallType.GET,
headers: {
'Authorization': 'BEarer ${token}',
},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
List? docList(dynamic response) => getJsonField(
response,
r'''$.documents''',
true,
) as List?;
}
class DocumentCategoriesCall {
Future<ApiCallResponse> call({
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Document Categories',
apiUrl: '${NumstationGroup.baseUrl}/api/bookkeeping/document/categories',
callType: ApiCallType.GET,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class ViewDocumentCall {
Future<ApiCallResponse> call({
String? token = '',
String? id = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'View Document',
apiUrl: '${NumstationGroup.baseUrl}/api/bookkeeping/document/${id}',
callType: ApiCallType.GET,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {},
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class AddDocumentCall {
Future<ApiCallResponse> call({
FFUploadedFile? document,
String? name = '',
String? description = '',
String? bookkeepingDocumentCategoryId = '',
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Add Document',
apiUrl: '${NumstationGroup.baseUrl}/api/bookkeeping/add/document',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
'document': document,
'name': name,
'description': description,
'bookkeeping_document_category_id': bookkeepingDocumentCategoryId,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
class DocumentLibrarySearchCall {
Future<ApiCallResponse> call({
String? s = '',
String? status = '',
String? categoryId = '',
String? fixDate = '',
String? dateFrom = '',
String? dateTo = '',
String? token = '',
}) async {
return ApiManager.instance.makeApiCall(
callName: 'Document Library Search',
apiUrl: '${NumstationGroup.baseUrl}/api/bookkeeping/document/library',
callType: ApiCallType.POST,
headers: {
'Authorization': 'Bearer ${token}',
},
params: {
's': s,
'status': status,
'category_id': categoryId,
'fix_date': fixDate,
'date_from': dateFrom,
'date_to': dateTo,
},
bodyType: BodyType.MULTIPART,
returnBody: true,
encodeBodyUtf8: false,
decodeUtf8: false,
cache: false,
alwaysAllowBody: false,
);
}
}
/// End Numstation Group Code
class ApiPagingParams {
int nextPageNumber = 0;
int numItems = 0;
dynamic lastResponse;
ApiPagingParams({
required this.nextPageNumber,
required this.numItems,
required this.lastResponse,
});
@override
String toString() =>
'PagingParams(nextPageNumber: $nextPageNumber, numItems: $numItems, lastResponse: $lastResponse,)';
}
String _serializeList(List? list) {
list ??= <String>[];
try {
return json.encode(list);
} catch (_) {
return '[]';
}
}
String _serializeJson(dynamic jsonVar, [bool isList = false]) {
jsonVar ??= (isList ? [] : {});
try {
return json.encode(jsonVar);
} catch (_) {
return isList ? '[]' : '{}';
}
}