vnorderui / com.venuenext.vnorderui.myorders / MyOrdersViewModel

MyOrdersViewModel

class MyOrdersViewModel : AndroidViewModel, OrderChangedListener

The ViewModel responsible for fetching/populating the MyOrder sections and items.

Constructors

<init>

The ViewModel responsible for fetching/populating the MyOrder sections and items.

MyOrdersViewModel(application: Application)

Properties

didRequestExperienceReceipt

var didRequestExperienceReceipt: Boolean

myOrders

var myOrders: List<Order>?

Functions

acceptExperienceTransfer

suspend fun acceptExperienceTransfer(transferId: String): String?

deleteAllOrders

Deletes all orders from the Room Database.

fun deleteAllOrders(): Deferred<Unit>

deleteLineItemsForOrderUuid

Deletes all LineItems for a specific orderUUID.

fun deleteLineItemsForOrderUuid(orderUUID: String): Deferred<Deferred<Unit>>

fetchOrders

Fetches the all of the user's orders from the API and populates the Room database with Orders & LineItems.

fun fetchOrders(): Deferred<List<Order>?>

filterCurrentOrders

Returns a list of orders deemed as "Current" according to business logic. Logic diverges based on product type.

fun filterCurrentOrders(myOrders: List<Order>): List<Order>

filterPastOrders

Returns a list of orders deemed as "Past" according to business logic. Logic diverges based on product type.

fun filterPastOrders(myOrders: List<Order>): List<Order>

getOrdersAsync

fun getOrdersAsync(): Deferred<List<Order>>

insertOrders

Inserts a list of orders in the Room Database.

fun insertOrders(orders: List<Order>): Deferred<Unit>

onOrderChanged

fun onOrderChanged(orderUUID: String?): Unit