APIManager
Scantrust iOS SDK provides APIManager
to perform network requests to Scantrust's backend server. It is a singleton class which is using URLSession
for network requests.
Basic Usage
- Swift
- Objective-C
let data = SerializableAuthenticationRequestData.init(authenticationScanCandidate: candidate, comesFromUnreadableFlow: false)
APIManager.sharedInstance()?.authenticateAuthenticationRequestData(data, withAuthToken: nil, completion: { [weak self] response, error in
// handle error and response
}
SerializableAuthenticationRequestData* requestData = [[SerializableAuthenticationRequestData alloc] initWithAuthenticationScanCandidate:bestCandidate comesFromUnreadableFlow:NO];
[[APIManager sharedInstance] authenticateAuthenticationRequestData:requestData withAuthToken:nil completion:^(STAuthResponse *response, NSError *error){
// handle error and response
}];
APIManager
has two kind of requests to contact the backend.
authenticateAuthenticationRequestData
- to authenticate secure code with backendsendScanQueryWithParsedContent
- to send a scan query with backend. Mainly used for unsupported phones and non auth codes
Model Objects
To make it easy to create and consume data with Scantrust backend, SDK provides varies model objects. Each has it's own responsibilities.
SerializableAuthenticationRequestData
: to create authentication request forAPIManager
BasicScanCandidate
: to create scan query request forAPIManager
STAuthResponse
: response object for authenticate and scan querySTBrand
: class to represents the brand details and to represent the details about brand which was associated to the scanned QR codeSTProduct
: class which represents the product details and to represent the details about product which was associated to the scanned QR code