fromJson static method

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

Implementation

// ignore: prefer_constructors_over_static_methods
static GetCommentsResponseWithPresencePublicComment? 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'status'), 'Required key "GetCommentsResponseWithPresencePublicComment[status]" is missing from JSON.');
      assert(json[r'status'] != null, 'Required key "GetCommentsResponseWithPresencePublicComment[status]" has a null value in JSON.');
      assert(json.containsKey(r'comments'), 'Required key "GetCommentsResponseWithPresencePublicComment[comments]" is missing from JSON.');
      assert(json[r'comments'] != null, 'Required key "GetCommentsResponseWithPresencePublicComment[comments]" has a null value in JSON.');
      assert(json.containsKey(r'user'), 'Required key "GetCommentsResponseWithPresencePublicComment[user]" is missing from JSON.');
      assert(json.containsKey(r'pageNumber'), 'Required key "GetCommentsResponseWithPresencePublicComment[pageNumber]" is missing from JSON.');
      assert(json[r'pageNumber'] != null, 'Required key "GetCommentsResponseWithPresencePublicComment[pageNumber]" has a null value in JSON.');
      return true;
    }());

    return GetCommentsResponseWithPresencePublicComment(
      statusCode: mapValueOfType<int>(json, r'statusCode'),
      status: mapValueOfType<String>(json, r'status')!,
      code: mapValueOfType<String>(json, r'code'),
      reason: mapValueOfType<String>(json, r'reason'),
      translatedWarning: mapValueOfType<String>(json, r'translatedWarning'),
      comments: PublicComment.listFromJson(json[r'comments']),
      user: UserSessionInfo.fromJson(json[r'user']),
      urlIdClean: mapValueOfType<String>(json, r'urlIdClean'),
      lastGenDate: mapValueOfType<int>(json, r'lastGenDate'),
      includesPastPages: mapValueOfType<bool>(json, r'includesPastPages'),
      isDemo: mapValueOfType<bool>(json, r'isDemo'),
      commentCount: mapValueOfType<int>(json, r'commentCount'),
      isSiteAdmin: mapValueOfType<bool>(json, r'isSiteAdmin'),
      hasBillingIssue: mapValueOfType<bool>(json, r'hasBillingIssue'),
      moduleData: mapCastOfType<String, Object>(json, r'moduleData') ?? const {},
      pageNumber: mapValueOfType<int>(json, r'pageNumber')!,
      isWhiteLabeled: mapValueOfType<bool>(json, r'isWhiteLabeled'),
      isProd: mapValueOfType<bool>(json, r'isProd'),
      isCrawler: mapValueOfType<bool>(json, r'isCrawler'),
      notificationCount: mapValueOfType<int>(json, r'notificationCount'),
      hasMore: mapValueOfType<bool>(json, r'hasMore'),
      isClosed: mapValueOfType<bool>(json, r'isClosed'),
      presencePollState: mapValueOfType<int>(json, r'presencePollState'),
      customConfig: CustomConfigParameters.fromJson(json[r'customConfig']),
      urlIdWS: mapValueOfType<String>(json, r'urlIdWS'),
      userIdWS: mapValueOfType<String>(json, r'userIdWS'),
      tenantIdWS: mapValueOfType<String>(json, r'tenantIdWS'),
    );
  }
  return null;
}