fromJson static method

OAuthApplication? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static OAuthApplication? 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(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key),
            'Required key "OAuthApplication[$key]" is missing from JSON.');
        assert(json[key] != null,
            'Required key "OAuthApplication[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return OAuthApplication(
      object: OAuthApplicationObjectEnum.fromJson(json[r'object'])!,
      id: mapValueOfType<String>(json, r'id')!,
      instanceId: mapValueOfType<String>(json, r'instance_id')!,
      name: mapValueOfType<String>(json, r'name')!,
      clientId: mapValueOfType<String>(json, r'client_id')!,
      public: mapValueOfType<bool>(json, r'public')!,
      scopes: mapValueOfType<String>(json, r'scopes')!,
      redirectUris: json[r'redirect_uris'] is Iterable
          ? (json[r'redirect_uris'] as Iterable)
              .cast<String>()
              .toList(growable: false)
          : const [],
      callbackUrl: mapValueOfType<String>(json, r'callback_url')!,
      authorizeUrl: mapValueOfType<String>(json, r'authorize_url')!,
      tokenFetchUrl: mapValueOfType<String>(json, r'token_fetch_url')!,
      userInfoUrl: mapValueOfType<String>(json, r'user_info_url')!,
      discoveryUrl: mapValueOfType<String>(json, r'discovery_url')!,
      tokenIntrospectionUrl:
          mapValueOfType<String>(json, r'token_introspection_url')!,
      createdAt: mapValueOfType<int>(json, r'created_at')!,
      updatedAt: mapValueOfType<int>(json, r'updated_at')!,
    );
  }
  return null;
}