//
//  BWFCallCenterProtocol.h
//  BWFCallCenterFramework
//
//  Copyright © 2019 Beowulf. All rights reserved.
//

#ifndef BWFCallCenterProtocol_h
#define BWFCallCenterProtocol_h

#import "BWFCallCenter.h"
#import "BWFCallCenterEnumDefine.h"

@class BWFRequestEntity;
@class BWFCallCenterError;
@protocol BWFCallCenterProtocol <NSObject>

@optional

/*!
 @abstract Start framework successfully
 */
- (void)bwfCallCenterDidStartAsRequesterWithIdentifier:(NSString * _Nullable)identifier;
/*!
 @abstract Stop framework successfully
 */
- (void)bwfCallCenterDidStop;

/*!
 @abstract Returned errors of framework
 @param error : returned error
 @discussion This method will be invoked if any error occurs within the framework
 @see For more detail, check
         + File 'BWFErrorDefine.h'
         + Class 'BWFError'
 */
- (void)bwfCallCenterFailedWithError:(BWFCallCenterError * _Nonnull)error;


/*!
 @abstract Current active call changes to state Connected
 @discussion This method is for CALLER and CALLEE roles
 State 'Connected' is a state that CALLER and CALLEE are connected and they can talk together.
 CALLER and CALLEE are allowed to request video by calling following method
 + requestVideoPreviewAndVideoRemoteView:
 */
- (void)bwfCallCenterCallDidChangeToStateConnectedWith:(NSString * _Nullable)identifier
                                           isVideoCall:(BOOL)isVideoCall;


/*!
 @abstract Current active call changes to state End
 @discussion This method is for CALLER and CALLEE roles
 State 'End' is a state that call is disconnected between CALLER and CALLEE
 */
- (void)bwfCallCenterCallDidChangeToStateEnd:(NSTimeInterval)totalDuration;

/*!
 @abstract Result for preparation a call from Caller
 @param identifier : the identify of user who will be connected with
 isVideoCall : call is voice only or video
 @discussion This method is for CALLER role
 This method will be invoked if the call from caller is ready to start after Caller called one of these following methods:
 + voiceCallTo:
 + videoCallTo:
 */
- (void)bwfCallCenterFinishCallPreparationTo:(NSString * _Nonnull)identifier
                                 isVideoCall:(BOOL)isVideoCall;


/*!
 @abstract Current active call changes to state Outgoing
 @discussion This method is for CALLER role
 State 'Outgoing' is a state that call is established on CALLER side and delivers signals to CALLEE side and CALLEE doesn't accept or deny the call.
 */
- (void)bwfCallCenterCallDidChangeToStateOutgoingTo:(NSString * _Nullable)identifier
                                        isVideoCall:(BOOL)isVideoCall;



/*!
 @abstract CALLEE receives incoming call signal
 @param identifier : an identify of user who sends call signal to CALLEE
 isVideoCall : call is voice only or video
 @discussion This method is for CALLEE role
 */
- (void)bwfCallCenterCallDidChangeToStateReceivedIncomingCallFrom:(NSString * _Nullable)identifier
                                                      isVideoCall:(BOOL)isVideoCall
                                                        extraInfo:(NSDictionary * _Nullable)extraInfo;



/*!
 @abstract Receive message
 @param text : the text message
 messageId: an unique identifier of the message
 identifier: an unique id to identify an user on your platform. In this case, it's an identifier of SEND whom sends message to
 date: a date when receives the message
 @discussion Notify that there's an incoming text message.
 @see For more detail, check
 + File 'BWFErrorDefine.h'
 + Class 'BWFError'
 */
- (void)bwfCallCenterReceiveTextMessage:(NSString * _Nonnull)text
                         conversationId:(NSString * _Nullable)convId
                              messageId:(NSString * _Nonnull)messageId
                                   from:(NSString * _Nonnull)identifier
                                   date:(NSDate * _Nullable)date;

- (void)bwfCallCenterReceiveImageMessage:(NSString * _Nonnull)url
                          conversationId:(NSString * _Nullable)convId
                               messageId:(NSString * _Nonnull)messageId
                                    from:(NSString * _Nonnull)identifier
                                    date:(NSDate * _Nullable)date;

/*!
 @abstract Receive status of message
 @param status : status of a message
 messageId: an unique identifier of the message
 @discussion Notify that there's an incoming message's status.
 @see For more detail, check
 + File 'BWFErrorDefine.h'
 + Class 'BWFError
 */
- (void)bwfCallCenterReceiveStatus:(EnumBWFCallCenterMessageStatus)status
                      forMessageId:(NSString * _Nonnull)msgId
                              from:(NSString * _Nonnull)identifier;



@end


@protocol BWFCallCenterForRequesterProtocol <NSObject>

@optional
- (void)bwfCallCenterDidFindSupporterViaRequest:(BWFRequestEntity * _Nonnull)request;


- (void)bwfCallCenterDidTimeoutFindingSupporters;

/*!
 @abstract Notify when to show rating GUI
 @param completionHandler : a block that do rating
 @discussion + Show rating GUI once this method is invoked
             + Call the 'RatingCompletionHandler' to do the rating logic.
             + Showcase: Show a rating view GUI inside this method. Add a button named 'Rate' on this view. When user click the button, collect data that user entered (level of satisfaction, comment from user), call the 'RatingCompletionHandler' to rate
 */
- (void)bwfCallCenterShouldRateForLastSupport:(RatingCompletionHandler _Nonnull)completionHandler;

@end


@protocol BWFCallCenterForSupporterProtocol <NSObject>

@optional
- (void)bwfCallCenterDidDropRequest:(BWFRequestEntity * _Nonnull)request;

@end

#endif /* BWFCallCenterProtocol_h */
