TF-1204 Add firebase object and capability
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import 'package:fcm/model/device_client_id.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
class DeviceClientIdNullableConverter implements JsonConverter<DeviceClientId?, String?> {
|
||||
const DeviceClientIdNullableConverter();
|
||||
|
||||
@override
|
||||
DeviceClientId? fromJson(String? json) => json != null ? DeviceClientId(json) : null;
|
||||
|
||||
@override
|
||||
String? toJson(DeviceClientId? object) => object?.value;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:fcm/model/firebase_expired_time.dart';
|
||||
import 'package:jmap_dart_client/http/converter/utc_date_converter.dart';
|
||||
import 'package:jmap_dart_client/http/converter/utc_date_nullable_converter.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
class FirebaseExpiredTimeNullableConverter implements JsonConverter<FirebaseExpiredTime?, String?> {
|
||||
const FirebaseExpiredTimeNullableConverter();
|
||||
|
||||
@override
|
||||
FirebaseExpiredTime? fromJson(String? json) {
|
||||
if (json != null) {
|
||||
return FirebaseExpiredTime(const UTCDateConverter().fromJson(json));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String? toJson(FirebaseExpiredTime? object) => const UTCDateNullableConverter().toJson(object?.value);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:fcm/model/firebase_registration_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
class FirebaseRegistrationIdNullableConverter implements JsonConverter<FirebaseRegistrationId?, String?> {
|
||||
const FirebaseRegistrationIdNullableConverter();
|
||||
|
||||
@override
|
||||
FirebaseRegistrationId? fromJson(String? json) => json != null ? FirebaseRegistrationId(Id(json)) : null;
|
||||
|
||||
@override
|
||||
String? toJson(FirebaseRegistrationId? object) => object?.id.value;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:fcm/model/firebase_token.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
class FirebaseTokenNullableConverter implements JsonConverter<FirebaseToken?, String?> {
|
||||
const FirebaseTokenNullableConverter();
|
||||
|
||||
@override
|
||||
FirebaseToken? fromJson(String? json) => json != null ? FirebaseToken(json) : null;
|
||||
|
||||
@override
|
||||
String? toJson(FirebaseToken? object) => object?.value;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
class TypeNameConverter implements JsonConverter<TypeName, String> {
|
||||
const TypeNameConverter();
|
||||
|
||||
@override
|
||||
TypeName fromJson(String json) => TypeName(json);
|
||||
|
||||
@override
|
||||
String toJson(TypeName object) => object.value;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class DeviceClientId with EquatableMixin {
|
||||
|
||||
final String value;
|
||||
|
||||
DeviceClientId(this.value);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [value];
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/utc_date.dart';
|
||||
|
||||
class FirebaseExpiredTime with EquatableMixin {
|
||||
|
||||
final UTCDate value;
|
||||
|
||||
FirebaseExpiredTime(this.value);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [value];
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:fcm/converter/device_client_id_nullable_converter.dart';
|
||||
import 'package:fcm/converter/firebase_expired_time_nullable_converter.dart';
|
||||
import 'package:fcm/converter/firebase_registration_id_nullable_converter.dart';
|
||||
import 'package:fcm/converter/firebase_token_nullable_converter.dart';
|
||||
import 'package:fcm/converter/type_name_converter.dart';
|
||||
import 'package:fcm/model/device_client_id.dart';
|
||||
import 'package:fcm/model/firebase_expired_time.dart';
|
||||
import 'package:fcm/model/firebase_registration_id.dart';
|
||||
import 'package:fcm/model/firebase_token.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'firebase_registration.g.dart';
|
||||
|
||||
@DeviceClientIdNullableConverter()
|
||||
@FirebaseRegistrationIdNullableConverter()
|
||||
@FirebaseTokenNullableConverter()
|
||||
@FirebaseExpiredTimeNullableConverter()
|
||||
@TypeNameConverter()
|
||||
@JsonSerializable(explicitToJson: true, includeIfNull: false)
|
||||
class FirebaseRegistration with EquatableMixin {
|
||||
|
||||
final FirebaseRegistrationId? id;
|
||||
final FirebaseToken? token;
|
||||
final DeviceClientId? deviceClientId;
|
||||
final FirebaseExpiredTime? expires;
|
||||
final List<TypeName>? types;
|
||||
|
||||
FirebaseRegistration({
|
||||
this.id,
|
||||
this.token,
|
||||
this.deviceClientId,
|
||||
this.expires,
|
||||
this.types
|
||||
});
|
||||
|
||||
factory FirebaseRegistration.fromJson(Map<String, dynamic> json) => _$FirebaseRegistrationFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$FirebaseRegistrationToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, token, deviceClientId, expires, types];
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||
|
||||
class FirebaseRegistrationId with EquatableMixin {
|
||||
|
||||
final Id id;
|
||||
|
||||
FirebaseRegistrationId(this.id);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id];
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class FirebaseToken with EquatableMixin {
|
||||
|
||||
final String value;
|
||||
|
||||
FirebaseToken(this.value);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [value];
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
class TypeName with EquatableMixin {
|
||||
|
||||
final String value;
|
||||
|
||||
TypeName(this.value);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [value];
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
||||
|
||||
class FCMUtils {
|
||||
static final capabilityFCM = CapabilityIdentifier(Uri.parse('com:linagora:params:jmap:firebase:push'));
|
||||
}
|
||||
Reference in New Issue
Block a user