import 'package:json_annotation/json_annotation.dart';

part 'response.g.dart';


@JsonSerializable()
class VerificationResponse {
  @JsonKey(name: 'ttl_seconds', defaultValue: 0)
  final int ttlSeconds;
  @JsonKey(name: 'cooldown_seconds', defaultValue: 0)
  final int cooldownSeconds;
  @JsonKey(defaultValue: '')
  final String target;
  final String idempotencyKey;

  const VerificationResponse({
    required this.ttlSeconds,
    required this.cooldownSeconds,
    required this.target,
    required this.idempotencyKey,
  });

  Duration get cooldownDuration => Duration(seconds: cooldownSeconds);
  Duration get ttlDuration => Duration(seconds: ttlSeconds);

  factory VerificationResponse.fromJson(Map<String, dynamic> json) => _$VerificationResponseFromJson(json);

  Map<String, dynamic> toJson() => _$VerificationResponseToJson(this);
}
