app / de.uniks.codliners.stock_simulator.repository / QuoteRepository

QuoteRepository

class QuoteRepository

Repository for accessing and updating Quotes.

Types

State

The state of a QuoteRepository.

sealed class State

Constructors

<init>

Constructor that allows repository creation from a Context.

QuoteRepository(context: Context)

Repository for accessing and updating Quotes.

QuoteRepository(database: StockAppDatabase)

Properties

state

The current State of this repository.

val state: LiveData<State>

Functions

fetchQuote

Fetches the Quote and HistoricalPrices for the requested asset from the respective API, then stores them in the StockAppDatabase.

suspend fun fetchQuote(id: String, type: Type): Boolean

historicalPrices

Returns a LiveData containing a List of HistoricalPrices for the requested id or null if no such HistoricalPrices exists.

fun historicalPrices(id: String): LiveData<List<HistoricalPrice>>

quoteById

Returns the Quote with the requested id or null if no such Quote exists.

fun quoteById(id: String): Quote?

quoteWithId

Returns a LiveData containing the Quote with the requested id or null if no such Quote exists.

fun quoteWithId(id: String): LiveData<Quote>

resetQuotes

Deletes all quotes from the database.

suspend fun resetQuotes(): Unit