-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathLocationEvent.swift
62 lines (50 loc) · 2.16 KB
/
LocationEvent.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// LocationEvent.swift
// IFTTTConnectSDK
//
// Created by Siddharth Sathyam on 10/25/21.
//
import Foundation
/// Descibes a closure that is invoked whenever the SDK generates a `[LocationEvent]`
public typealias LocationEventsClosure = ([LocationEvent]) -> Void
/// Describes the kinds of region events that can be reported.
public enum RegionEventKind: String {
/// The user entered the region.
case entry = "entry"
/// The user exited the region.
case exit = "exit"
}
/// Describes the reasons why an event was not uploaded.
public enum EventUploadError: Error {
/// The total number of events to be uploaded exceeds a sanity threshold.
case crossedSanityThreshold
/// A network error ocurred in uploading the event.
case networkError
}
/// Describes all of the possible events in the Location monitoring flow.
public enum LocationEvent: Equatable {
/// The location event was recorded by the SDK.
///
/// - Parameters:
/// - `region`: The details of the region that was recorded.
case reported(region: RegionEvent)
/// The SDK attempted to upload a region event.
///
/// - Parameters:
/// - `region`: The details of the region that was attempted to be uploaded.
/// - `delay`: The time in seconds between reporting the event and an attempted upload.
case uploadAttempted(region: RegionEvent, delay: TimeInterval)
/// The SDK successfully uploaded the region event.
///
/// - Parameters:
/// - `region`: The details of the region that was successfully uploaded.
/// - `delay`: The time in seconds between reporting the event and a successful upload.
case uploadSuccessful(region: RegionEvent, delay: TimeInterval)
/// The SDK failed to upload the region event.
///
/// - Parameters:
/// - `region`: The details of the region that was successfully uploaded.
/// - `error`: The `EventUploadError` that occurred.
/// - `delay`: The time in seconds between attempting the event upload and error in completing the upload.
case uploadFailed(region: RegionEvent, error: EventUploadError, delay: TimeInterval)
}