QEDAPI
public class QEDAPI
The QEDAPI
provides a wrapper class on the QED REST API.
It uses the QEDReport
and QEDFile
structs to represent reports and files for certification.
-
The handler for report related requests made to QED REST API
Declaration
Swift
public typealias ReportHandler = (QEDReport?, Error?) -> Void
Parameters
report
nil
if request failed, otherwise aQEDReport
instance updated based on API response data.error
An error object that indicates why the request failed, or
nil
if the request was successful. -
The handler for requests made to QED REST API that return a
success
boolean.Declaration
Swift
public typealias SuccessHandler = (Bool, Error?) -> Void
Parameters
success
true
if request succeeded,false
otherwise.error
An error object that indicates why the request failed, or
nil
if the request was successful.
-
Will setup the
QEDAPI
shared instance with the requiredapiKey
to make authenticated requests.Important
If you use the methods on this class without calling this setup method first, the requests will still be made but will fail on the server due to Authentication restrictions.
Declaration
Swift
public class func setup(with apiKey: String, production: Bool = true)
Parameters
apiKey
The key to make authenticated requests to the QED REST API
-
The
QEDAPI
provides upload and download content functionality for theQEDFile
‘s that happens asyncronoysly and is managed by the OS. When using theuploadContent
anddownloadContent
functionality you must set the background completion handler when received on the App’s delegateapplication(_:handleEventsForBackgroundURLSession:completionHandler:)
method callDeclaration
Swift
public class func setBackgroundCompletionHandler(_ handler : @escaping ()->Void, identifier : String)
-
Indicates if file download task is pending for a given
url
. Use this method before attempting a file download task to prevent unnecesary duplicate asynchronous download reqeusts.Declaration
Swift
public class func isFileDownloadTaskPending(for url: URL) -> Bool
-
Will issue a request to the backend (for initial submission or updates if previously reported) for a notarizing report of files represented by a given
QEDReport
instanceAfter posting a report for a
QEDReport
instance for the first time, a blockchain proof is initiated.The server will respond with the updated report including blockchain transaction details. In most cases the report status will be
QEDReport.ProofStatus.pending
when posting for the first timeDeclaration
Swift
public class func send(_ report : QEDReport, in language : String = "en", completion : @escaping ReportHandler)
Parameters
report
The
QEDReport
representing the files to be notarizedcompletion
The
ReportHandler
block to call when the request is complete. This handler is not called on the main thread -
Will get the update report data for a given
QEDReport
instance from the backend.Declaration
Swift
public class func update(_ report : QEDReport, completion : @escaping ReportHandler)
Parameters
report
The
QEDReport
representing a notarization report to be updated from backendcompletion
The
ReportHandler
block to call when the request is complete. This handler is not called on the main thread -
Will get a forced update of the certification status for a given
QEDReport
instance from the backend.A Force status update will make the backed update the certification directly from the blockchain if it is not already
confirmed
Declaration
Swift
public class func forceStatusUpdate(for report : QEDReport, completion : @escaping ReportHandler)
Parameters
report
The
QEDReport
representing a notarization report to be updated from backendcompletion
The
ReportHandler
block to call when the request is complete. This handler is not called on the main thread -
Will reqeust the generation and download of the PDF document for a given
QEDReport
instance.Note
The
report
‘sQEDReport.poofStatus
must beQEDReport.ProofStatus.certified
.Declaration
Swift
public class func generatePDF(for report : QEDReport, in language : String = "en", sourceId : String = "", completion : @escaping SuccessHandler)
Parameters
report
The
QEDReport
instance for which a PDF certificate is being requested.language
A
String
representing the languate the PDF is preferedcompletion
The
SuccessHandler
block to call when the request is complete. This handler is not called on the main thread -
Will trigger a background content upload for a
QEDFile
Declaration
Parameters
file
The
QEDFile
instance for which the content should be uploaded.report
The
QEDReport
instance to which thefile
belongssourceId
A String instance that can be used to identify a file when the upload completes by the OS and the app was previously terminated.
wifiOnly
Indicates if the file should only be uploaded over WiFi. This determines the URLSessionConfiguration parameters to use.
completion
The block to call when the request has completed. This handler is not called on the main thread
updatedFile
A
QEDFile
instance representing the updatedfile
once upload is complete.nil
if upload failed.error
nil
if upload was succesful, anError
instance otherwise. -
Will trigger a background content download for a
QEDFile
Declaration
Swift
public class func downloadContent(for file : QEDFile, sourceId : String = "", wifiOnly : Bool, completion : @escaping (_ success : Bool, _ error : Error?)->Void)
Parameters
file
The
QEDFile
instance for which the content should be downloaded.sourceId
A String instance that can be used to identify a file when the download completes by the OS and the app was previously terminated.
wifiOnly
Indicates if the file should only be downloaded over WiFi. This determines the URLSessionConfiguration parameters to use.
completion
The block to call when the request has completed. This handler is not called on the main thread
success
‘true’ if download succeded, the content has been stored on the
file
‘s 'fileURL’ specified parameter..error
nil
if download was succesful, anError
instance otherwise. -
Will trigger a create/update call for the newsletter information for an user properties object
Declaration
Swift
public class func updateNewsletters(for userProperties : QEDUserProperties, in language : String = "en", completion : @escaping (_ success : Bool, _ error : Error?)->Void)
Parameters
userProperties
The
QEDUserProperties
instance for which the properties must be updated on backend.-language
The IOS language code to use by the backend for user communications.
completion
The block to call when the request has completed. This handler is not called on the main thread
success
‘true’ if create/update succeded.
error
nil
ifsuccess == true
, anError
instance otherwise.
-
Undocumented
See moreDeclaration
Swift
public struct Notifications
-
Register a handler for background tasks completion notifications.
Declaration
Swift
public class func registerForBackgroundTasksCompletionNotifications(handler : @escaping (_ notification : Notification) -> Void)
Parameters
handler
The block to call when a background task completion notification is received.
notification
The
Notification
instance being issues. It will content auserInfo
Dictionary.