StudyPlanetRepositoryImpl

class StudyPlanetRepositoryImpl @Inject constructor(api: StudyPlanetApi, userDao: UserDao, planetDao: PlanetDao) : StudyPlanetRepository

Implementation of the StudyPlanetRepository interface that communicates with both local and remote data sources. Application of facade pattern to abstract away the implementation details of the data sources.

Parameters

api

The StudyPlanetApi instance for making remote API calls.

userDao

The UserDao for local user-related database operations.

planetDao

The PlanetDao for local planet-related database operations.

Constructors

Link copied to clipboard
@Inject
constructor(api: StudyPlanetApi, userDao: UserDao, planetDao: PlanetDao)

Functions

Link copied to clipboard
open suspend override fun authenticate(token: String): AuthenticatedUserDto

Authenticates the current user remotely and performs local database operations to store the user and associated planets.

Link copied to clipboard
open override fun getActiveUser(): Flow<User>
Link copied to clipboard
open override fun getDiscoveredPlanets(): Flow<List<Planet>>
Link copied to clipboard
open suspend override fun getHealth(): HealthDto

Retrieves the health information of the Study Planet server.

Link copied to clipboard
open suspend override fun getUserByRemoteId(remoteId: Int): UserRoomEntity

Retrieves a user from the local database based on their remote ID.

Link copied to clipboard
open suspend override fun insertPlanet(planet: PlanetRoomEntity)

Inserts a single planet into the local database.

Link copied to clipboard
open suspend override fun insertPlanets(planets: List<PlanetRoomEntity>)

Inserts a list of planets into the local database.

Link copied to clipboard
open suspend override fun insertUser(user: UserRoomEntity)
Link copied to clipboard
open suspend override fun login(body: LoginDto): AuthenticatedUserDto

Logs in a user remotely and performs local database operations to store the user and associated planets.

Link copied to clipboard
open suspend override fun refreshDiscoveredPlanetsOnline(): Flow<Resource<Unit>>
Link copied to clipboard
open suspend override fun register(body: RegisterDto): AuthenticatedUserDto

Registers a new user remotely and performs local database operations to store the user and associated planets.

Link copied to clipboard
open suspend override fun startDiscovering(body: DiscoverActionDto): Response<Unit>

Initiates the process of discovering a new planet remotely.

Link copied to clipboard
open suspend override fun startExploring(body: ExploreActionDto): Response<Unit>

Initiates the process of exploring a planet remotely.

Link copied to clipboard
open suspend override fun stopDiscovering(body: DiscoverActionDto): ActionResponse

Stops the process of discovering a planet remotely and performs local database operations if successful.

Link copied to clipboard
open suspend override fun stopExploring(body: ExploreActionDto): Int