#import "ContextAwareAdinCubeRewardedDelegate.h"

#import "AdinCubeBannerImpl.h"

#define REWARDED_EVENT_PREFIX @"AIC-Rewarded-"

@implementation ContextAwareAdinCubeRewardedDelegate

- (void)didCompleteRewarded {
	[self dispatchJavascriptEvent:REWARDED_EVENT_PREFIX @"onAdCompleted"];
}

- (void)didFetchRewarded {
	[self dispatchJavascriptEvent:REWARDED_EVENT_PREFIX @"onAdFetched"];
}

- (void)didFailToFetchRewarded:(NSString *)errorCode {
	[[AdinCubeBannerImpl sharedBanner] onFullscreenAdHidden:self.cdvPlugin.viewController];
	[self dispatchJavascriptEvent:REWARDED_EVENT_PREFIX @"onFetchError" content:errorCode];
}

- (void)didShowRewarded {
	[[AdinCubeBannerImpl sharedBanner] onFullscreenAdShown:self.cdvPlugin.viewController];
	[self dispatchJavascriptEvent:REWARDED_EVENT_PREFIX @"onAdShown"];
}

- (void)didFailToShowRewarded:(NSString *)errorCode {
	[[AdinCubeBannerImpl sharedBanner] onFullscreenAdHidden:self.cdvPlugin.viewController];
	[self dispatchJavascriptEvent:REWARDED_EVENT_PREFIX @"onError" content:errorCode];
}

- (void)didClickOnRewarded {
	[self dispatchJavascriptEvent:REWARDED_EVENT_PREFIX @"onAdClicked"];
}

- (void)didHideRewarded {
	[[AdinCubeBannerImpl sharedBanner] onFullscreenAdHidden:self.cdvPlugin.viewController];
	[self dispatchJavascriptEvent:REWARDED_EVENT_PREFIX @"onAdHidden"];
}

@end