Client
public class Client
The Client class acts as the interface for the Wing REST API. All Wing API Requests are routed through this class
to apply the necessary authentication to the requests.
-
The OAuth credentials assigned to your application to access the Wing API. Used to authenticate with the Wing API in order to receive a token to use for subsequent authorized requests.
Declaration
Swift
public var oauth: OAuthCredentials? = nil -
The authorization token used to make authorized requests.
Declaration
Swift
public var token: String?
-
Initializes an instance of the
Clientclass.Declaration
Swift
public init()
-
Authenticates the client with the Wing API using the configured OAuth Client ID and Client Secret.
Throws
Throws:
ClientError.unauthorizedif the OAuth Client ID and Client Secret aren’t configured.NetworkError.invalidResponseif the token could not be parsed from the response.NetworkError.unacceptableStatusCodeif an failure status code is received in the response.
Declaration
Swift
public func authenticate(completion: @escaping (_ token: String?, _ error: Error?) -> Void)Parameters
completionThe callback closure that will be invoked upon receiving the response of the network request.
tokenOptional. The token that is used to authenticate with the Wing API when performing authorized requests.
errorOptional. The error that occurred while performing the network request.
-
Creates a test session for a person with the specified patient data.
Note: Requires token authentication to be configured.
Throws
Throws:
ClientError.unauthorizedif thetokenhasn’t been set on the client.NetworkError.invalidResponseif an invalid response was recieved.NetworkError.unacceptableStatusCodeif an failure status code is received in the response.DecodingError.decodingFailedif the response json could not be decoded.
Declaration
Swift
public func createTestSession(with patientData: PatientData, completion: @escaping (_ testSession: TestSession?, _ error: Error?) -> Void)Parameters
patientDataThe data for the patient that the test session is being created for.
completionThe callback closure that will get invoked upon the request finishing.
testSessionThe test session object that represents the created test session. (Optional)
errorThe error that occurred while performing the network request. (Optional)
-
Retrieves the details of the test session with the specified ID.
Note: Requires token authentication to be configured.
Throws
Throws:
ClientError.unauthorizedif thetokenhasn’t been set on the client.NetworkError.invalidResponseif an invalid response was recieved.NetworkError.unacceptableStatusCodeif an failure status code is received in the response.DecodingError.decodingFailedif the response json could not be decoded.
Declaration
Swift
public func retrieveTestSession(withId id: String, completion: @escaping (_ testSession: TestSession?, _ error: Error?) -> Void)Parameters
idThe identifier for the test session.
completionThe callback closure that will get invoked upon the request finishing.
testSessionThe test session object that represents the retrieved test session. (Optional)
errorThe error that occurred while performing the network request. (Optional)
View on GitHub
Client Class Reference