diff --git a/recipients_app/lib/core/helpers/document_reference_converter.dart b/recipients_app/lib/core/helpers/document_reference_converter.dart index 2e50af527..607790337 100644 --- a/recipients_app/lib/core/helpers/document_reference_converter.dart +++ b/recipients_app/lib/core/helpers/document_reference_converter.dart @@ -2,12 +2,12 @@ import "package:cloud_firestore/cloud_firestore.dart"; import "package:json_annotation/json_annotation.dart"; class DocumentReferenceConverter - implements JsonConverter { + implements JsonConverter { const DocumentReferenceConverter(); @override DocumentReference fromJson(dynamic json) => json as DocumentReference; @override - dynamic toJson(DocumentReference documentReference) => documentReference; + Object toJson(DocumentReference documentReference) => documentReference; } diff --git a/recipients_app/lib/core/helpers/timestamp_converter.dart b/recipients_app/lib/core/helpers/timestamp_converter.dart index 18b0e036a..81bce885d 100644 --- a/recipients_app/lib/core/helpers/timestamp_converter.dart +++ b/recipients_app/lib/core/helpers/timestamp_converter.dart @@ -1,16 +1,16 @@ import "package:cloud_firestore/cloud_firestore.dart"; import "package:json_annotation/json_annotation.dart"; -class TimestampConverter implements JsonConverter { +class TimestampConverter implements JsonConverter { const TimestampConverter(); @override - Timestamp? fromJson(dynamic json) { - return json as Timestamp?; + Timestamp fromJson(dynamic json) { + return json as Timestamp; } @override - dynamic toJson(Timestamp? object) { + Object toJson(Timestamp object) { return object; } } diff --git a/recipients_app/lib/data/models/payment/social_income_payment.g.dart b/recipients_app/lib/data/models/payment/social_income_payment.g.dart index 09a674f95..7c016f6e0 100644 --- a/recipients_app/lib/data/models/payment/social_income_payment.g.dart +++ b/recipients_app/lib/data/models/payment/social_income_payment.g.dart @@ -10,12 +10,14 @@ SocialIncomePayment _$SocialIncomePaymentFromJson(Map json) => SocialIncomePayment( id: json['id'] as String? ?? '', amount: json['amount'] as int?, - paymentAt: const TimestampConverter().fromJson(json['payment_at']), + paymentAt: _$JsonConverterFromJson( + json['payment_at'], const TimestampConverter().fromJson), currency: json['currency'] as String?, status: $enumDecodeNullable(_$PaymentStatusEnumMap, json['status']), comments: json['comments'] as String?, updatedBy: json['last_updated_by'] as String?, - updatedAt: const TimestampConverter().fromJson(json['last_updated_at']), + updatedAt: _$JsonConverterFromJson( + json['last_updated_at'], const TimestampConverter().fromJson), ); Map _$SocialIncomePaymentToJson( @@ -23,14 +25,22 @@ Map _$SocialIncomePaymentToJson( { 'id': instance.id, 'amount': instance.amount, - 'payment_at': const TimestampConverter().toJson(instance.paymentAt), + 'payment_at': _$JsonConverterToJson( + instance.paymentAt, const TimestampConverter().toJson), 'currency': instance.currency, 'status': _$PaymentStatusEnumMap[instance.status], 'comments': instance.comments, 'last_updated_by': instance.updatedBy, - 'last_updated_at': const TimestampConverter().toJson(instance.updatedAt), + 'last_updated_at': _$JsonConverterToJson( + instance.updatedAt, const TimestampConverter().toJson), }; +Value? _$JsonConverterFromJson( + Object? json, + Value? Function(Json json) fromJson, +) => + json == null ? null : fromJson(json as Json); + const _$PaymentStatusEnumMap = { PaymentStatus.created: 'created', PaymentStatus.paid: 'paid', @@ -39,3 +49,9 @@ const _$PaymentStatusEnumMap = { PaymentStatus.failed: 'failed', PaymentStatus.other: 'other', }; + +Json? _$JsonConverterToJson( + Value? value, + Json? Function(Value value) toJson, +) => + value == null ? null : toJson(value); diff --git a/recipients_app/lib/data/models/recipient.g.dart b/recipients_app/lib/data/models/recipient.g.dart index 2421c2061..4eab738ea 100644 --- a/recipients_app/lib/data/models/recipient.g.dart +++ b/recipients_app/lib/data/models/recipient.g.dart @@ -17,7 +17,8 @@ Recipient _$RecipientFromJson(Map json) => Recipient( : Phone.fromJson(json['mobile_money_phone'] as Map), firstName: json['first_name'] as String?, lastName: json['last_name'] as String?, - birthDate: const TimestampConverter().fromJson(json['birth_date']), + birthDate: _$JsonConverterFromJson( + json['birth_date'], const TimestampConverter().fromJson), email: json['email'] as String?, country: json['country'] as String?, preferredName: json['preferred_name'] as String?, @@ -30,9 +31,12 @@ Recipient _$RecipientFromJson(Map json) => Recipient( json['recipient_since'], const DateTimeConverter().fromJson), imLinkInitial: json['im_link_initial'] as String?, imLinkRegular: json['im_link_regular'] as String?, - nextSurvey: const TimestampConverter().fromJson(json['next_survey']), + nextSurvey: _$JsonConverterFromJson( + json['next_survey'], const TimestampConverter().fromJson), organizationRef: - const DocumentReferenceConverter().fromJson(json['organisation']), + _$JsonConverterFromJson>( + json['organisation'], + const DocumentReferenceConverter().fromJson), updatedBy: json['last_updated_by'] as String?, ); @@ -43,23 +47,23 @@ Map _$RecipientToJson(Recipient instance) => { 'paymentProvider': instance.paymentProvider, 'first_name': instance.firstName, 'last_name': instance.lastName, - 'birth_date': const TimestampConverter().toJson(instance.birthDate), + 'birth_date': _$JsonConverterToJson( + instance.birthDate, const TimestampConverter().toJson), 'email': instance.email, 'country': instance.country, 'preferred_name': instance.preferredName, 'calling_name': instance.callingName, 'gender': instance.gender, 'main_language': instance.selectedLanguage, - 'organisation': - _$JsonConverterToJson>( - instance.organizationRef, - const DocumentReferenceConverter().toJson), + 'organisation': _$JsonConverterToJson>( + instance.organizationRef, const DocumentReferenceConverter().toJson), 'terms_accepted': instance.termsAccepted, 'recipient_since': _$JsonConverterToJson( instance.recipientSince, const DateTimeConverter().toJson), 'im_link_initial': instance.imLinkInitial, 'im_link_regular': instance.imLinkRegular, - 'next_survey': const TimestampConverter().toJson(instance.nextSurvey), + 'next_survey': _$JsonConverterToJson( + instance.nextSurvey, const TimestampConverter().toJson), 'last_updated_by': instance.updatedBy, }; diff --git a/recipients_app/lib/data/models/survey/survey.g.dart b/recipients_app/lib/data/models/survey/survey.g.dart index 1a55c04a5..c28cf90d9 100644 --- a/recipients_app/lib/data/models/survey/survey.g.dart +++ b/recipients_app/lib/data/models/survey/survey.g.dart @@ -9,8 +9,10 @@ part of 'survey.dart'; Survey _$SurveyFromJson(Map json) => Survey( id: json['id'] as String? ?? '', status: $enumDecodeNullable(_$SurveyServerStatusEnumMap, json['status']), - dueDateAt: const TimestampConverter().fromJson(json['due_date_at']), - completedAt: const TimestampConverter().fromJson(json['completed_at']), + dueDateAt: _$JsonConverterFromJson( + json['due_date_at'], const TimestampConverter().fromJson), + completedAt: _$JsonConverterFromJson( + json['completed_at'], const TimestampConverter().fromJson), accessEmail: json['access_email'] as String?, accessPassword: json['access_pw'] as String?, ); @@ -18,8 +20,10 @@ Survey _$SurveyFromJson(Map json) => Survey( Map _$SurveyToJson(Survey instance) => { 'id': instance.id, 'status': _$SurveyServerStatusEnumMap[instance.status], - 'due_date_at': const TimestampConverter().toJson(instance.dueDateAt), - 'completed_at': const TimestampConverter().toJson(instance.completedAt), + 'due_date_at': _$JsonConverterToJson( + instance.dueDateAt, const TimestampConverter().toJson), + 'completed_at': _$JsonConverterToJson( + instance.completedAt, const TimestampConverter().toJson), 'access_email': instance.accessEmail, 'access_pw': instance.accessPassword, }; @@ -32,3 +36,15 @@ const _$SurveyServerStatusEnumMap = { SurveyServerStatus.completed: 'completed', SurveyServerStatus.missed: 'missed', }; + +Value? _$JsonConverterFromJson( + Object? json, + Value? Function(Json json) fromJson, +) => + json == null ? null : fromJson(json as Json); + +Json? _$JsonConverterToJson( + Value? value, + Json? Function(Value value) toJson, +) => + value == null ? null : toJson(value); diff --git a/recipients_app/pubspec.yaml b/recipients_app/pubspec.yaml index 84166cb0c..88e1ba982 100644 --- a/recipients_app/pubspec.yaml +++ b/recipients_app/pubspec.yaml @@ -2,7 +2,7 @@ name: app description: Social Income App publish_to: "none" -version: 1.1.8+22 +version: 1.1.8+23 environment: sdk: ">=3.1.0 <4.0.0"