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?) -> VoidParameters
reportnilif request failed, otherwise aQEDReportinstance updated based on API response data.errorAn error object that indicates why the request failed, or
nilif the request was successful. -
The handler for requests made to QED REST API that return a
successboolean.Declaration
Swift
public typealias SuccessHandler = (Bool, Error?) -> VoidParameters
successtrueif request succeeded,falseotherwise.errorAn error object that indicates why the request failed, or
nilif the request was successful.
-
Will setup the
QEDAPIshared instance with the requiredapiKeyto 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
apiKeyThe key to make authenticated requests to the QED REST API
-
The
QEDAPIprovides upload and download content functionality for theQEDFile‘s that happens asyncronoysly and is managed by the OS. When using theuploadContentanddownloadContentfunctionality 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
QEDReportinstanceAfter posting a report for a
QEDReportinstance 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.pendingwhen posting for the first timeDeclaration
Swift
public class func send(_ report : QEDReport, in language : String = "en", completion : @escaping ReportHandler)Parameters
reportThe
QEDReportrepresenting the files to be notarizedcompletionThe
ReportHandlerblock 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
QEDReportinstance from the backend.Declaration
Swift
public class func update(_ report : QEDReport, completion : @escaping ReportHandler)Parameters
reportThe
QEDReportrepresenting a notarization report to be updated from backendcompletionThe
ReportHandlerblock 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
QEDReportinstance from the backend.A Force status update will make the backed update the certification directly from the blockchain if it is not already
confirmedDeclaration
Swift
public class func forceStatusUpdate(for report : QEDReport, completion : @escaping ReportHandler)Parameters
reportThe
QEDReportrepresenting a notarization report to be updated from backendcompletionThe
ReportHandlerblock 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
QEDReportinstance.Note
The
report‘sQEDReport.poofStatusmust beQEDReport.ProofStatus.certified.Declaration
Swift
public class func generatePDF(for report : QEDReport, in language : String = "en", sourceId : String = "", completion : @escaping SuccessHandler)Parameters
reportThe
QEDReportinstance for which a PDF certificate is being requested.languageA
Stringrepresenting the languate the PDF is preferedcompletionThe
SuccessHandlerblock to call when the request is complete. This handler is not called on the main thread -
Will trigger a background content upload for a
QEDFileDeclaration
Parameters
fileThe
QEDFileinstance for which the content should be uploaded.reportThe
QEDReportinstance to which thefilebelongssourceIdA String instance that can be used to identify a file when the upload completes by the OS and the app was previously terminated.
wifiOnlyIndicates if the file should only be uploaded over WiFi. This determines the URLSessionConfiguration parameters to use.
completionThe block to call when the request has completed. This handler is not called on the main thread
updatedFileA
QEDFileinstance representing the updatedfileonce upload is complete.nilif upload failed.errornilif upload was succesful, anErrorinstance otherwise. -
Will trigger a background content download for a
QEDFileDeclaration
Swift
public class func downloadContent(for file : QEDFile, sourceId : String = "", wifiOnly : Bool, completion : @escaping (_ success : Bool, _ error : Error?)->Void)Parameters
fileThe
QEDFileinstance for which the content should be downloaded.sourceIdA String instance that can be used to identify a file when the download completes by the OS and the app was previously terminated.
wifiOnlyIndicates if the file should only be downloaded over WiFi. This determines the URLSessionConfiguration parameters to use.
completionThe 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..errornilif download was succesful, anErrorinstance 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
userPropertiesThe
QEDUserPropertiesinstance for which the properties must be updated on backend.-languageThe IOS language code to use by the backend for user communications.
completionThe block to call when the request has completed. This handler is not called on the main thread
success‘true’ if create/update succeded.
errornilifsuccess == true, anErrorinstance 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
handlerThe block to call when a background task completion notification is received.
notificationThe
Notificationinstance being issues. It will content auserInfoDictionary.
QEDAPI Class Reference