import 'package:json_annotation/json_annotation.dart';

import '../../../api_response.dart';

part 'get_participants_response.g.dart';

@JsonSerializable(explicitToJson: true)
class GetParticipantsResponse extends ApiResponse {
  Set<GetParticipantsResponseObject> data;

  GetParticipantsResponse(this.data);

  factory GetParticipantsResponse.fromJson(Map<String, dynamic> json) =>
      _$GetParticipantsResponseFromJson(json);
  Map<String, dynamic> toJson() => _$GetParticipantsResponseToJson(this);
}

@JsonSerializable(explicitToJson: true)
class GetParticipantsResponseObject {
  int attendeeId;
  String actorType;
  String actorId;
  String displayName;
  GetParticipantsResponseObjectParticipantType participantType;
  int lastPing;
  GetParticipantsResponseObjectParticipantsInCallFlags inCall;
  int permissions;
  int attendeePermissions;
  String? sessionId;
  List<String> sessionIds;
  String? status;
  String? statusIcon;
  String? statusMessage;
  String? roomToken;

  GetParticipantsResponseObject(
    this.attendeeId,
    this.actorType,
    this.actorId,
    this.displayName,
    this.participantType,
    this.lastPing,
    this.inCall,
    this.permissions,
    this.attendeePermissions,
    this.sessionId,
    this.sessionIds,
    this.status,
    this.statusIcon,
    this.statusMessage,
    this.roomToken,
  );

  factory GetParticipantsResponseObject.fromJson(Map<String, dynamic> json) =>
      _$GetParticipantsResponseObjectFromJson(json);
  Map<String, dynamic> toJson() => _$GetParticipantsResponseObjectToJson(this);
}

enum GetParticipantsResponseObjectParticipantType {
  @JsonValue(1)
  owner('Besitzer'),
  @JsonValue(2)
  moderator('Moderator'),
  @JsonValue(3)
  user('Teilnehmer'),
  @JsonValue(4)
  guest('Gast'),
  @JsonValue(5)
  userFollowingPublicLink('Teilnehmer über Link'),
  @JsonValue(6)
  guestWithModeratorPermissions('Gast Moderator');

  const GetParticipantsResponseObjectParticipantType(this.prettyName);
  final String prettyName;
}

enum GetParticipantsResponseObjectParticipantsInCallFlags {
  @JsonValue(0)
  disconnected,
  @JsonValue(1)
  inCall,
  @JsonValue(2)
  providesAudio,
  @JsonValue(3)
  providesVideo,
  @JsonValue(4)
  usesSipDialIn,
}
