ApiService class
A singleton service for making API requests to the backend.
It handles authentication tokens, constructs request headers, and provides methods for various API endpoints.
Constructors
- ApiService.new()
-
Factory constructor to return the singleton instance.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createBlock(
int hospitalId, Map< String, dynamic> blockData) → Future<Map< String, dynamic> > - Creates a new block within a hospital.
-
createRole(
int hospitalId, Map< String, dynamic> roleData) → Future<Map< String, dynamic> > - Creates a new role within a hospital.
-
createShift(
int hospitalId, Map< String, dynamic> shiftData) → Future<Map< String, dynamic> > - Creates a new shift within a hospital.
-
createUser(
int hospitalId, Map< String, dynamic> userData) → Future<Map< String, dynamic> > - Creates a new user within a hospital.
-
deleteBlock(
int hospitalId, int blockId) → Future< void> - Deletes a block from a hospital.
-
deleteRole(
int hospitalId, int roleId) → Future< void> - Deletes a role from a hospital.
-
deleteShift(
int hospitalId, int shiftId) → Future< void> - Deletes a shift from a hospital.
-
deleteUser(
int hospitalId, int userId) → Future< void> - Deletes a user from a hospital.
-
getBlocks(
int hospitalId) → Future< List> - Retrieves a list of blocks for a specific hospital.
-
getHospital(
int hospitalId) → Future< Map< String, dynamic> > - Retrieves details for a specific hospital.
-
getMemos(
int hospitalId) → Future< List> - Retrieves a list of memos for a specific hospital.
-
getRoles(
int hospitalId) → Future< Map< String, dynamic> > - Retrieves a list of roles for a specific hospital.
-
getShifts(
int hospitalId) → Future< Map< String, dynamic> > - Retrieves a list of shifts for a specific hospital.
-
getUser(
int hospitalId, int userId) → Future< Map< String, dynamic> > - Retrieves data for a specific user within a hospital.
-
getUsers(
int hospitalId) → Future< Map< String, dynamic> > - Retrieves a list of users for a specific hospital.
-
getWards(
int hospitalId, {int? block, int? floor}) → Future< List> - Retrieves a list of wards for a specific hospital, optionally filtered by block and floor.
-
login(
String phoneNumber, String password) → Future< Map< String, dynamic> > - Authenticates a user with a phone number and password.
-
logout(
) → Future< void> - Logs out the current user.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refreshUser(
) → Future< Map< String, dynamic> > - Refreshes the current user's data.
-
setPassword(
String phoneNumber, String password) → Future< Map< String, dynamic> > - Sets or updates a user's password.
-
switchBlock(
int newBlockId) → Future< bool> - Switches the current block for the authenticated user.
-
switchWard(
int newWardId) → Future< bool> -
Switches the current ward for the authenticated user.
newWardId
The ID of the ward to switch to. Returns aFuture<bool>
which istrue
if the switch was successful,false
otherwise. -
toString(
) → String -
A string representation of this object.
inherited
-
updateBlock(
int hospitalId, int blockId, Map< String, dynamic> blockData) → Future<Map< String, dynamic> > - Updates an existing block's data within a hospital.
-
updateFCMToken(
String fcmToken, int? blockId) → Future< Map< String, dynamic> > - Updates the Firebase Cloud Messaging (FCM) token for the current user.
-
updateRole(
int hospitalId, int roleId, Map< String, dynamic> roleData) → Future<Map< String, dynamic> > - Updates an existing role's data within a hospital.
-
updateShift(
int hospitalId, int shiftId, Map< String, dynamic> shiftData) → Future<Map< String, dynamic> > - Updates an existing shift's data within a hospital.
-
updateUser(
int hospitalId, int userId, Map< String, dynamic> userData) → Future<Map< String, dynamic> > - Updates an existing user's data within a hospital.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Static Methods
-
initializeBaseURL(
) → Future< void> -
Initializes the baseURL from the
RemoteConfigService
.