Class

ApiService

ApiService()

ApiService class for making API requests to the backend. Handles authentication tokens and provides methods for various endpoints.

Constructor

# new ApiService()

View Source services/api.js, line 7

Methods

# async createBlock()

Retrieves the list of blocks within a specific hospital.

View Source services/api.js, line 217

# async createRole()

Creates a new role within a specific hospital.

View Source services/api.js, line 181

# async createShift()

Creates a new shift within a specific hospital.

View Source services/api.js, line 250

# async createUser()

Creates a new user within a specific hospital.

View Source services/api.js, line 147

# async deleteUser()

Deletes a user from a specific hospital.

View Source services/api.js, line 167

# async deleteWard()

Updates an existing ward's details within a specific hospital.

View Source services/api.js, line 442

# async getDashboardMemos()

Retrieves memos for the dashboard view, optionally filtered by query parameters.

View Source services/api.js, line 468

# async getHospital(hospitalId) → {Promise.<object>}

Retrieves details for a specific hospital by its ID. Typically called after a user logs in to get details about their assigned hospital.

Parameters:
Name Type Description
hospitalId string | number

The ID of the hospital.

View Source services/api.js, line 129

  • The hospital details.
Promise.<object>

# async getUsers(hospitalId) → {Promise.<Array.<object>>}

Retrieves the list of users belonging to a specific hospital.

Parameters:
Name Type Description
hospitalId string | number

The ID of the hospital.

View Source services/api.js, line 140

  • An array of user objects.
Promise.<Array.<object>>

# async login(phoneNumber, password, fcmTokenopt) → {Promise.<object>}

Authenticates a user and retrieves an authentication token.

Parameters:
Name Type Attributes Default Description
phoneNumber string

The user's phone number.

password string

The user's password.

fcmToken string | null <optional>
null

The FCM token for push notifications.

View Source services/api.js, line 65

  • The authentication data, including the token.
Promise.<object>

# async logout() → {Promise.<null>}

Logs out the current user.

View Source services/api.js, line 101

  • A promise that resolves when the logout request is successful.
Promise.<null>

# async rejectMemo()

Rejects a memo for a specific hospital.

View Source services/api.js, line 359

# async request(endpoint, optionsopt) → {Promise.<(object|null)>}

General request method to interact with the API. Automatically adds Authorization header if a token exists in localStorage.

Parameters:
Name Type Attributes Default Description
endpoint string

The API endpoint path.

options object <optional>
{}

Fetch API options (method, headers, body, etc.).

View Source services/api.js, line 25

  • If the HTTP response status is not OK or if the fetch fails.
Error
  • The parsed JSON response or null for 204 No Content.
Promise.<(object|null)>

# async updateBlock()

Updates an existing block's details within a specific hospital.

View Source services/api.js, line 227

# async updateUser()

Updates an existing user's details within a specific hospital.

View Source services/api.js, line 157

# async updateWard()

Creates a new ward within a specific hospital.

View Source services/api.js, line 432