Reports
1. Create reports
Asleep.createReports()
var config: Asleep.Config?
var reports: Asleep.Reports?
if let config {
reports = Asleep.createReports(config: config)
}
Property Name | Type | Description |
---|---|---|
config | Asleep.Config | Enter Asleep.Config instance |
2. Get a single report
Asleep.Reports.report()
var reports: Asleep.Reports?
let sessionId: String
// Closure
reports?.report(sessionId: sessionId, completionBlock: { (report: Asleep.Report?, error: Asleep.AsleepError?) in
if let error {
print(error)
return
}
if let report {
}
})
// Async
Task {
do {
let report = try await reports?.report(sessionId: sessionId)
} catch {
print(error)
}
}
Property Name | Type | Description |
---|---|---|
sessionId | String | sessionId that can be received when stopping tracking |
completionBlock | Asleep.Model.Report? | If nil, an error occurs. |
Asleep.AsleepError? | Error Codes |
3. Get multiple reports
Asleep.Reports.reports()
var reports: Asleep.Reports?
let fromDate: String = "2023-05-01"
let toDate: String = "2023-05-07"
// Closure
reports?.reports(fromDate: fromDate, toDate: toDate, completionBlock: { (reportSessions: [Asleep.Model.SleepSession]?, error: Asleep.AsleepError?) in
if let error {
print(error)
return
}
if let reportSessions {
}
})
// Async
Task {
do {
let reportSessions = try await reports?.reports(fromDate: fromDate, toDate: toDate)
} catch {
print(error)
}
}
Property Name | Type | Description |
---|---|---|
fromDate | String (YYYY-MM-DD ) | View date start |
toDate | String (YYYY-MM-DD ) | View date end |
orderBy - default value: .descending | Asleep.Model.OrderBy [.ascending, .descending] | DESC : Descending prderASC : Ascending order |
offset - default value: 0 | Int | Number of reports to skip |
limit - default value: 20 | Int | Maximum number of report |
completionBlock | Array<Asleep.Model.SleepSession>? | If nil, an error occurs. |
Asleep.AsleepError? | Error Codes |
4. Delete report
When session data is deleted from the Asleep server upon a request, it becomes difficult to provide specific evidence for the deleted sessions during subsequent billing usage analysis.
Asleep.Reports.deleteReport()
var reports: Asleep.Reports?
let sessionId: String
// Closure
reports?.deleteReport(sessionId: sessionId, completionBlock: { (error: Asleep.AsleepError?) in
if let error {
print(error)
return
}
})
// Async
Task {
do {
try await deleteReport?.deleteReport(sessionId: sessionId)
} catch {
print(error)
}
}
Property Name | Type | Description |
---|---|---|
sessionId | String | sessionId to be deleted |
completionBlock | Asleep.AsleepError? | Error Codes |
5. Data Type
Asleep.Model.Report
struct Report {
let timezone: String
let validity: Validity
let session: Session
let stat: Stat?
}
enum Validity {
case inProgress
case invalidSleepStage
case invalidOsaStage
case VALID
}
Property name | Type | Description |
---|---|---|
timezone | String | The adjusted time zone of the analysis result e.g. UTC , Asia/Seoul |
validity | Asleep.Model.Validity | Whether the analysis of that sleep session is valid If some of the uploaded audio files are invalid, or if the percentage lost is more than a certain number, the analysis is inaccurate and displays a field IN_PROGRESS : If session is OPENINVALID:TOO_MANDY_DEFECTS_IN_SLEEP_STAGES : Sleep stage analysis result is not enoughINVALID:TOO_MANY_DEFECTS_IN_OSA_STAGES : Sleep apnea stage analysis result is not enoughVALID : Analysis is valid |
session | Asleep.Model.Session | Session analysis information |
stat | Asleep.Model.Stat | Analysis statistical information |
Asleep.Model.Session
struct Session {
let id: String
let state: State
let startTime: Date
let endTime: Date?
let sleepStages: [SleepStage]
let osaStages: [OSAStage]
}
enum State {
case open
case closed
case complete
}
enum SleepStage {
case error
case wake
case light
case deep
case rem
}
enum OSAStage {
case stable
case unstable
}
Property name | Type | Description |
---|---|---|
id | String | Session Id |
state | Asleep.Model.State | Sleep session state (OPEN , CLOSED , or COMPLETE ) |
startTime | Date | Session start time |
endTime | Date? | Session end time |
sleepStages | Array<Asleep.Model.SleepStage> | Sleep stages |
osaStages | Array<Asleep.Model.OSAStage> | Sleep apnea stages |
Asleep.Model.Stat
struct Stat {
let sleepEfficiency: Float
let sleepLatency: Int?
let sleepTime: Date?
let wakeupLatency: Int?
let wakeTime: Date?
let timeInWake: Int
let timeInSleepPeriod: Int
let timeInSleep: Int
let timeInBed: Int
let timeInRem: Int
let timeInLight: Int
let timeInDeep: Int
let timeInStableBreath: Int
let timeInUnstableBreath: Int
let wakeRatio: Float?
let sleepRatio: Float?
let remRatio: Float?
let lightRatio: Float?
let deepRatio: Float?
let stableBreathRatio: Float?
let unstableBreathRatio: Float?
let breathingPattern: BreathingPattern?
let estimatedAhi: Float?
}
enum BreathingPattern {
case veryStable
case stable
case unstable
}
Property name | Type | Description |
---|---|---|
sleepEfficiency | Float | The percentage of time you actually slept during sleep measurement |
sleepLatency | Int? | time it took to fall asleep |
sleepTime | Date? | The time it takes to fall asleep after the start of sleep measurement |
wakeupLatency | Int? | The time it takes to wake up and end your sleep measurement |
wakeTime | Date? | wake up time |
timeInWake | Int | wake during sleep |
timeInSleepPeriod | Int | During sleep measurement time, excluding the time it took from the start of the sleep measurement to fall asleep and the time it took from the wake to the end of the sleep measurement |
timeInSleep | Int | During sleep measurement time, the time you were actually sleeping Classified into three stages: deep, light, rem |
timeInBed | Int | The time from the start of the sleep measurement to the end of the sleep measurement |
timeInRem | Int | Total time the sleep phase progressed to rem |
timeInLight | Int | Total time the sleep phase progressed to light |
timeInDeep | Int | Total time the sleep phase progressed to deep |
timeInStableBreath | Int | Total time in the breathing stable section |
timeInUnstableBreath | Int | Total time in the breathing unstable section |
wakeRatio | Float? | Rate of waking time in the middle during sleep stage |
sleepRatio | Float? | The percentage of time you sleep without waking during the sleep phase |
remRatio | Float? | Rate of REM sleep during sleep stage |
lightRatio | Float? | Rate of light sleep during sleep stage |
deepRatio | Float? | Rate of deep sleep during sleep stage |
stableBreathRatio | Float? | The percentage of time that was a breathing stable section during the sleep stage |
unstableBreathRatio | Float? | The percentage of time that was a breathing unstable section during the sleep stage |
breathingPattern | Asleep.Model.BreathingPattern? | Breathing stability stageVERY_STABLE : Very StableSTABLE : StableUNSTABLE : Unstable |
estimatedAhi | Float? | Values for determining respiratory instability levels |
Asleep.Model.SleepSession
struct SleepSession {
let sessionId: String
let state: State
let sessionStartTime: Date
let sessionEndTime: Date?
let lastReceivedSeqNum: Int
let timeInBed: Int
}
enum State {
case open
case closed
case complete
}
Property name | Type | Description |
---|---|---|
sessionId | String | Sleep session ID |
state | Asleep.Model.State | Status of Session 'OPEN': An in-progress session, with audio uploads available 'CLOSED': The session terminated by sending an end session request. Unable to upload audio files. Analysis of uploaded sleep audio is still in progress 'COMPLETE': All sleep analysis completed after the end of the session |
sessionStartTime | Date | Session start time |
sessionEndTime | Date? | Session end time |
lastReceivedSeqNum | Int | The sequence number of the last uploaded audio file |
timeInBed | Int | The time from the start of the sleep measurement to the end of the sleep measurement |
Updated 11 months ago