GatewayHandoffEvent.fromJson constructor

GatewayHandoffEvent.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory GatewayHandoffEvent.fromJson(Map<String, dynamic> json) {
  final t = GatewayHandoffEventType.fromWire(json['type'] as String?);
  if (t == null) {
    throw ArgumentError.value(
      json['type'],
      'GatewayHandoffEvent.fromJson type',
      'unknown gateway handoff event type',
    );
  }
  return GatewayHandoffEvent(
    type: t,
    idempotencyKey: json['idempotencyKey'] as String,
    timestamp: json['timestamp'] is String
        ? DateTime.parse(json['timestamp'] as String).toUtc()
        : null,
    attempt: (json['attempt'] as num?)?.toInt(),
    response: json['response'] is Map
        ? GatewayHandoffResponse.fromJson(
            (json['response'] as Map).cast<String, dynamic>(),
          )
        : null,
    error: json['error'] is Map
        ? GatewayError.fromJson(
            (json['error'] as Map).cast<String, dynamic>(),
          )
        : null,
  );
}