TestSessionManager
public class TestSessionManager
The TestSessionManager
class is responsible for keeping track of a test session’s state and provides an inteface to
the necessary Wing API endpoints to perform a lung function test.
-
The Wing client used to interface with the Wing REST API.
Declaration
Swift
public fileprivate(set) var client: Client!
-
The state of the test session.
Declaration
Swift
public fileprivate(set) var state: TestSessionState = .noTest
-
The active test session.
Declaration
Swift
public fileprivate(set) var testSession: TestSession
-
The number of tests that are allowed to fail processing before the test session is considered invalid.
Declaration
Swift
public let failedTestsThreshold = 2
-
The number of tests that are allowed to fail due to local failure reasons before the test session is considered invalid.s
Declaration
Swift
public let localTestFailureThreshold = 2
-
The interval at which the server will be pinged to check if processing is complete.
Declaration
Swift
public let processingPollingInterval: Double = 0.8
-
The threshold that represents the number of times the app should attempt to refresh the test session.
Declaration
Swift
public let processingTimeoutThreshold = 10
-
The number of attempts the test session has been refreshed in effort to determine the processing state.
Declaration
Swift
public fileprivate(set) var numberOfProcessingAttempts = 0
-
Initializes the
TestSessionManager
with the test session passed in as an argument.Declaration
Swift
public init(client: Client, testSession: TestSession)
-
Retrieves and applies the updated details of the associated test session.
Throws
ClientError.unauthorized
if thetoken
hasn’t been set on the client.TestSessionManagerError.processingTimeout
if number of processing attempts exceeds the timeout threshold.TestSessionManagerError.retrieveTestSessionFailed
if the response doesn’t contain the test session.NetworkError.unacceptableStatusCode
if an failure status code is received in the response.
Declaration
Swift
public func processTestSession(completion: @escaping (Swift.Error?) -> Void)
-
Uploads the recording at the specified filepath to Amazon S3 to initiate processing.
Throws
Throws:
ClientError.unauthorized
if thetoken
hasn’t been set on the client.NetworkError.unacceptableStatusCode
if an failure status code is received in the response.TestSessionManagerError.uploadTargetCreationFailed
if the request to create a upload target failed.TestSessionmanagerError.testUploadFailed
if uploading the test recording failed.
Declaration
Swift
public func uploadRecording(atFilepath filepath: String, completion: @escaping (_ error: Swift.Error?) -> Void)
Parameters
filepath
The filepath for the lung function test recording file.
completion
A callback closure that gets invoked after receiving the response from the upload request.
- error: The error that occurred while uploading the recording (Optional).