fromJson static method

GemShopSubscriptionResponseDataSchema? fromJson(
  1. dynamic value
)

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

Implementation

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

    return GemShopSubscriptionResponseDataSchema(
      member: mapValueOfType<bool>(json, r'member')!,
      memberExpiration: mapDateTime(json, r'member_expiration', r'')!,
      gems: mapValueOfType<int>(json, r'gems')!,
      cost: mapValueOfType<int>(json, r'cost')!,
    );
  }
  return null;
}