fromJson static method

MemberTokenSubscriptionResponseDataSchema? fromJson(
  1. dynamic value
)

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

Implementation

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

    return MemberTokenSubscriptionResponseDataSchema(
      member: mapValueOfType<bool>(json, r'member')!,
      memberExpiration: mapDateTime(json, r'member_expiration', r'')!,
      memberToken: mapValueOfType<int>(json, r'member_token')!,
    );
  }
  return null;
}