//
//  ConferenceParticipant+DictRepresentation.m
//  react-native-rainbow-module
//
//  Created by Doha Tubaileh on 17/8/2021.
//

#import "ConferenceParticipant+DictRepresentation.h"
#import "Contact+DictRepresentation.h"

@implementation ConferenceParticipant (DictRepresentation)

-(NSDictionary*) conferenceParticipantDictionaryRepresentation {

    NSMutableDictionary *participantDic = [self.getContact contactDictionaryRepresentation].mutableCopy;
    RainbowContact *participant = (RainbowContact*)self.getContact;

    [participantDic setValue: participant.rainbowID forKey:@"participantId"];
    [participantDic setValue: [self participantRoleToString] forKey:@"role"];
    [participantDic setValue: [NSNumber numberWithBool:self.muted] forKey:@"isMuted"];
    [participantDic setValue: [NSNumber numberWithBool:self.isTalking] forKey:@"isTalking"];
    [participantDic setValue: [self participantStateToString] forKey:@"state"];
    [participantDic setValue: [NSNumber numberWithDouble:self.talkingTime] forKey:@"talkingTime"];
    [participantDic setValue: [NSNumber numberWithBool:self.delegateCapability] forKey:@"canBeConferenceDelegate"];
    [participantDic setValue:[NSNumber numberWithBool:self.isSharingVideo] forKey:@"isVideoSubscribed"];
    return participantDic;

}

-(NSString *) participantRoleToString {
    switch (self.role) {
        case ParticipantRoleModerator:
            return @"Moderator";
        case ParticipantRoleMember:
            return @"Member";
        case ParticipantRoleGuest:
            return @"Guest";
            break;
    }
}

-(NSString *) participantStateToString {
    switch (self.state) {
        case ParticipantStateRinging:
            return @"Ringing";
        case ParticipantStateConnected:
            return @"Connected";
        case ParticipantStateDisconnected:
            return @"Disconnected";
            break;
    }
}


@end
