app / com.ocean.ishareeconomy_android.repositories / UserRepository

UserRepository

class UserRepository

Part of login.

Repository responsible for managing all the domain related network requests. UserRepository is the only domain related repository because the User object is the central access point of the domain

Types

Companion

ReusableRepositorySingleton enables Singleton Pattern with params

companion object Companion : ReusableRepositorySingleton<UserRepository, RepositoryParams>

Properties

lending

the list LendingObject the logged in user is sharing

val lending: LiveData<List<LendingObject>>

selectedLendObject

val selectedLendObject: MutableLiveData<LendingObject>

users

all the users from the database

val users: LiveData<List<User>>

using

the list LendingObject the logged in user is using

val using: LiveData<List<LendingObject>>

Functions

addLendObject

Method that makes a network call to POST a new LendingObject to the user's lending list and on success stores it in the DB

suspend fun addLendObject(id: String, auth: String, name: String, description: String, type: String): Unit

refreshUsers

Method that makes a network GET call to fetch the total list of User, starting with the logged in, User, ordered by User.distance and store it in the DB

suspend fun refreshUsers(id: String, auth: String): Unit

removeLendObject

Method that makes a network call to DELETE an existing LendingObject from the user's lending list and on success stores remove it from the DB

suspend fun removeLendObject(userId: String, objectId: String, auth: String): Unit

resetData

suspend fun resetData(): Unit