fromJson static method

LeadAction? fromJson(
  1. dynamic value
)

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

Implementation

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

    return LeadAction(
      uuid: mapValueOfType<String>(json, r'uuid')!,
      actionType: LeadActionType.fromJson(json[r'actionType'])!,
      actionDate: mapDateTime(json, r'actionDate', r'')!,
      originatorKey: mapValueOfType<String>(json, r'originatorKey'),
      demandSubAccountId: mapValueOfType<int>(json, r'demandSubAccountId')!,
      rejectReason: RejectReason.fromJson(json[r'rejectReason']),
      amount: mapValueOfType<int>(json, r'amount'),
      originationFee: mapValueOfType<int>(json, r'originationFee'),
      offerClickId: mapValueOfType<int>(json, r'offerClickId'),
      createdAt: mapDateTime(json, r'createdAt', r'')!,
      deletedAt: mapDateTime(json, r'deletedAt', r''),
    );
  }
  return null;
}