mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-05-20 12:15:17 +00:00
COVIDSafe code from version 2.6
This commit is contained in:
parent
195798ddd5
commit
f7bfce7eb6
43 changed files with 910 additions and 144 deletions
|
@ -11,7 +11,7 @@ import Alamofire
|
|||
class PhoneValidationAPI {
|
||||
|
||||
static func verifyPhoneNumber(regInfo: RegistrationRequest,
|
||||
completion: @escaping (String?, Swift.Error?) -> Void) {
|
||||
completion: @escaping (String?, CovidSafeAPIError?) -> Void) {
|
||||
|
||||
guard let apiHost = PlistHelper.getvalueFromInfoPlist(withKey: "API_Host", plistName: "CovidSafe-config") else {
|
||||
return
|
||||
|
@ -33,8 +33,22 @@ class PhoneValidationAPI {
|
|||
case .success:
|
||||
guard let authResponse = response.value else { return }
|
||||
completion(authResponse.session, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
case .failure(_):
|
||||
var apiError = CovidSafeAPIError.RequestError
|
||||
|
||||
if let respData = response.data {
|
||||
do {
|
||||
let errorResponse = try JSONDecoder().decode(CovidSafeErrorResponse.self, from: respData)
|
||||
if errorResponse.message == "MaxRegistrationsReached" {
|
||||
apiError = .MaxRegistrationError
|
||||
}
|
||||
} catch {
|
||||
// unable to parse response
|
||||
apiError = .ResponseError
|
||||
}
|
||||
}
|
||||
completion(nil, apiError)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue