Skip to main content

Cancel Consultation

Cancel Consultation Example

When the consultation is created the status of it will be new. It can be canceled from the user side by using cancelConsultation with providing the id.

Check the example:

import AltibbiTelehealth

let consultationId = 123
ApiService.cancelConsultation(id: consultationId, completion: {cancelledConsultation, failure, error in
// Handle cancelledConsultation as a CancelledConsultation object
if let error = error {
print("Data Error: \(String(describing: error))")
} else if let failure = failure {
// Handle failure
} else {
if let cancelled = cancelledConsultation {
print("Consultation \(String(describing: cancelled.consultationId)) is now \(String(describing: cancelled.status))")
}
}
})

The cancelConsultation will return an object decoded to CancelledConsultation struct

CancelledConsultation struct

struct CancelledConsultation {
var status: String?
var consultationId: Int?
}

Responses

Status 200

Success

{
"consultation_id": 123,
"status": "cancelled"
}

Status 401

UnauthorizedHttpException represents an Unauthorized HTTP exception with status code 401

{
"name": "Unauthorized",
"message": "Your request was made with invalid credentials",
"code": "0",
"status": "401",
"type": "yii\\web\\UnauthorizedHttpException"
}

Status 403

Current user cant access this page

{
"name": "Forbidden",
"message": "Current user cant access this page",
"code": "0",
"status": "403",
"type": "yii\\web\\ForbiddenHttpException"
}

Status 404

Consultation id invalid or deleted

{
"name": "Not Found",
"message": "Object not found: {id}",
"code": "0",
"status": "404",
"type": "yii\\web\\NotFoundHttpException"
}