У меня следующий вызов API:
func updateSheetVals() {
let args = ["id": viewModel.id]
let measurements = UpdateRequest.Measurements(
departure: Double(sheet.postRefuelQuantity.field.currentValue),
discrepancy: Double(sheet.discrepancy.field.currentValue),
discrepancyPercentage: Double(sheet.discrepancyPercent.field.currentValue),
preTotal: Double(dheet.preTotal.field.currentValue),
targetTotal: Double(fuelSheet.requiredTotal.field.currentValue)
)
let body = UpdateRequest(measurement: measurements)
API.client.post(.updateFuelSheetVals, with: args, using: .put, posting: body, expecting: MessageResponse.self) { (success, response) in
switch success {
case .failure:
print("Check network connection")
case .success:
DispatchQueue.asyncMain {
self.present(WarningViewController.finished(), animated: true)
}
}
}
}
}
И все же, несмотря на то, что я получаю ответ 200 и API вызывается правильно, мой контроллер представления никогда не отображается. Рад предоставить больше контекстного кода, если это необходимо, но сначала подумал, не упускаю ли я что-то очевидное в этом блоке ...
РЕДАКТИРОВАТЬ:
Вызов API вызывается в следующем коде:
func acceptButtonPressed(_ button: Button) {
var confirmation: UIViewController & ConfirmationAction
guard let level = viewModel.getSelectedSheet().order.levelDouble else { return }
if self.viewModel.requiresSignature {
if level < 3 {
confirmation = SignatureViewController(hasDiscrepancy: viewModel.hasDiscrepancy, discrepancyPrompt: viewModel.discrepancyPrompt, sl: level)
} else {
confirmation = SignatureViewController(hasDiscrepancy: viewModel.hasDiscrepancy,
discrepancyPrompt: viewModel.discrepancyPrompt, sl: level)
}
} else {
if let userInputAllowed = sheet.userInputAllowed, level < 3, !userInputAllowed {
confirmation = OrderAcceptAlertViewController.alert()
} else if level < 3 {
confirmation = DiscrepancyAlertViewController.alertWithDiscrepancy(hasDiscrepancy: viewModel.hasDiscrepancy,
discrepancyPrompt: viewModel.discrepancyFromManualInput(discrepancyValue: fuelSheet.percentageDiscrepancy.field.currentValue))
} else {
confirmation = DiscrepancyAlertViewController.alertWithDiscrepancy(hasDiscrepancy: viewModel.hasDiscrepancy,
discrepancyPrompt: viewModel.discrepancyPrompt)
}
}
confirmation.confirmationAction = { [weak confirmation, weak self] response in
guard let self = self else {
return
}
var completedSignature: SignatureParameter?
switch response {
case let .signature(signature):
completedSignature = signature
case .discrepancy:
break
}
let args = ["id": self.viewModel.id]
let params = AcceptParameter(
employee: self.viewModel.employee,
signature: completedSignature,
base64FuelSheet: self.sheet.ticket?.base64
)
if let confirm = confirmation {
confirm.setLoading(true)
API.client.post(.accept, with: args, using: .put, posting: params, expecting: Nothing.self, completion: { [weak self] (success, _) in
DispatchQueue.asyncMain {
guard let self = self else {
return
}
confirm.setLoading(false)
self.navigationController?.popViewController(animated: true)
}
}
})
self.updateSheetVals()
}
}
present(confirmation, animated: true, completion: nil)
}