WebRedirect.fromJson constructor

WebRedirect.fromJson(
  1. dynamic jsonObject
)

Implementation

WebRedirect.fromJson(dynamic jsonObject) {
  Map<String, dynamic> json = credentialToMap(jsonObject);
  if (json.containsKey('status')) {
    String s = json['status'];
    switch (s) {
      case 'FAIL':
        status = AcknowledgeStatus.fail;
        break;
      case 'OK':
        status = AcknowledgeStatus.ok;
        break;
      case 'PENDING':
        status = AcknowledgeStatus.pending;
        break;
      default:
        throw Exception('Unknown Status');
    }
  } else {
    throw Exception('status attribute is needed');
  }

  if (json.containsKey('redirectUrl')) {
    redirectUrl = json['redirectUrl'];
  } else {
    throw Exception('redirectUrl is needed');
  }
}