fromJson static method

ResolveSipAuthRequest? fromJson(
  1. dynamic value
)

Returns a new ResolveSipAuthRequest instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static ResolveSipAuthRequest? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      assert(json.containsKey(r'sip_caller_number'),
          'Required key "ResolveSipAuthRequest[sip_caller_number]" is missing from JSON.');
      assert(json[r'sip_caller_number'] != null,
          'Required key "ResolveSipAuthRequest[sip_caller_number]" has a null value in JSON.');
      assert(json.containsKey(r'sip_trunk_number'),
          'Required key "ResolveSipAuthRequest[sip_trunk_number]" is missing from JSON.');
      assert(json[r'sip_trunk_number'] != null,
          'Required key "ResolveSipAuthRequest[sip_trunk_number]" has a null value in JSON.');
      return true;
    }());

    return ResolveSipAuthRequest(
      fromHost: mapValueOfType<String>(json, r'from_host'),
      sipCallerNumber: mapValueOfType<String>(json, r'sip_caller_number')!,
      sipTrunkNumber: mapValueOfType<String>(json, r'sip_trunk_number')!,
      sourceIp: mapValueOfType<String>(json, r'source_ip'),
    );
  }
  return null;
}