1 package expo.modules.updates.statemachine
2 
3 import org.json.JSONObject
4 import java.util.Date
5 
6 /**
7 Structure representing an event that can be sent to the machine.
8  */
9 sealed class UpdatesStateEvent(val type: UpdatesStateEventType) {
10   class Check : UpdatesStateEvent(UpdatesStateEventType.Check)
11   class Download : UpdatesStateEvent(UpdatesStateEventType.Download)
12   class CheckError(private val errorMessage: String) : UpdatesStateEvent(UpdatesStateEventType.CheckError) {
13     val error: UpdatesStateError
14       get() {
15         return UpdatesStateError(errorMessage)
16       }
17   }
18   class DownloadError(private val errorMessage: String) : UpdatesStateEvent(UpdatesStateEventType.DownloadError) {
19     val error: UpdatesStateError
20       get() {
21         return UpdatesStateError(errorMessage)
22       }
23   }
24   class CheckCompleteUnavailable() : UpdatesStateEvent(UpdatesStateEventType.CheckCompleteUnavailable)
25   class CheckCompleteWithUpdate(val manifest: JSONObject) : UpdatesStateEvent(UpdatesStateEventType.CheckCompleteAvailable)
26   class CheckCompleteWithRollback(val commitTime: Date) : UpdatesStateEvent(UpdatesStateEventType.CheckCompleteAvailable)
27   class DownloadComplete : UpdatesStateEvent(UpdatesStateEventType.DownloadComplete)
28   class DownloadCompleteWithUpdate(val manifest: JSONObject) : UpdatesStateEvent(UpdatesStateEventType.DownloadComplete)
29   class DownloadCompleteWithRollback : UpdatesStateEvent(UpdatesStateEventType.DownloadComplete)
30   class Restart : UpdatesStateEvent(UpdatesStateEventType.Restart)
31 }
32