//
//  AirbridgeModuleExtern.m
//  AirbridgeReactNative
//
//  Created by WOF on 13/08/2019.
//  Copyright © 2019 ab180. All rights reserved.
//

#import <React/RCTEventEmitter.h>
#import <React/RCTBridgeModule.h>

// Attribution
@interface RCT_EXTERN_MODULE(AttributionInteractor, RCTEventEmitter)

RCT_EXTERN_METHOD(listen)

@end

// Deeplink
@interface RCT_EXTERN_MODULE(DeeplinkInteractor, RCTEventEmitter)

RCT_EXTERN_METHOD(listen)

@end

// Event
@interface RCT_EXTERN_MODULE(EventInteractor, NSObject)

RCT_EXTERN_METHOD(trackEvent:(nonnull NSString*)category
                  semanticAttributes:(nullable NSDictionary*)semanticAttributes
                  customAttributes:(nullable NSDictionary*)customAttributes)

@end

// Fetch
@interface RCT_EXTERN_MODULE(FetchInteractor, NSObject)

RCT_EXTERN_METHOD(fetchDeviceUUID:(nonnull NSString*)promiseID
                  onSuccess:(RCTResponseSenderBlock)onSuccess
                  onFailure:(RCTResponseSenderBlock)onFailure)

RCT_EXTERN_METHOD(fetchAirbridgeGeneratedUUID:(nonnull NSString*)promiseID
                  onSuccess:(RCTResponseSenderBlock)onSuccess
                  onFailure:(RCTResponseSenderBlock)onFailure)

@end

// Placement
@interface RCT_EXTERN_MODULE(PlacementInteractor, NSObject)

RCT_EXTERN_METHOD(click:(nonnull NSString*)promiseID
                  trackingLink:(nonnull NSString*)trackingLink
                  onSuccess:(RCTResponseSenderBlock)onSuccess
                  onFailure:(RCTResponseSenderBlock)onFailure)

RCT_EXTERN_METHOD(impression:(nonnull NSString*)promiseID
                  trackingLink:(nonnull NSString*)trackingLink
                  onSuccess:(RCTResponseSenderBlock)onSuccess
                  onFailure:(RCTResponseSenderBlock)onFailure)

RCT_EXTERN_METHOD(createTrackingLink:(nonnull NSString*)channel
                  option:(nonnull NSDictionary*)option
                  onSuccess:(RCTResponseSenderBlock)onSuccess
                  onFailure:(RCTResponseSenderBlock)onFailure)

@end

// Register
@interface RCT_EXTERN_MODULE(RegisterInteractor, NSObject)

RCT_EXTERN_METHOD(setUserID:(nonnull NSString*)id)

RCT_EXTERN_METHOD(clearUserID)

RCT_EXTERN_METHOD(setUserEmail:(nonnull NSString*)email)

RCT_EXTERN_METHOD(clearUserEmail)

RCT_EXTERN_METHOD(setUserPhone:(nonnull NSString*)phone)

RCT_EXTERN_METHOD(clearUserPhone)

RCT_EXTERN_METHOD(setUserAttribute:(nonnull NSDictionary*)option)

RCT_EXTERN_METHOD(removeUserAttribute:(nonnull NSString*)key)

RCT_EXTERN_METHOD(clearUserAttributes)

RCT_EXTERN_METHOD(setUserAlias:(nonnull NSString*)key
                  value:(nonnull NSString*)value)

RCT_EXTERN_METHOD(removeUserAlias:(nonnull NSString*)key)

RCT_EXTERN_METHOD(clearUserAlias)

RCT_EXTERN_METHOD(clearUser)

RCT_EXTERN_METHOD(setDeviceAlias:(nonnull NSString*)key
                  value:(nonnull NSString*)value)

RCT_EXTERN_METHOD(removeDeviceAlias:(nonnull NSString*)key)

RCT_EXTERN_METHOD(clearDeviceAlias)

RCT_EXTERN_METHOD(registerPushToken:(nonnull NSString*)token)

@end

// Switch
@interface RCT_EXTERN_MODULE(SwitchInteractor, NSObject)

RCT_EXTERN_METHOD(enableSDK)

RCT_EXTERN_METHOD(disableSDK)

RCT_EXTERN_METHOD(isSDKEnabled:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(startTracking)

RCT_EXTERN_METHOD(stopTracking)

RCT_EXTERN_METHOD(isTrackingEnabled:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(startInAppPurchaseTracking)

RCT_EXTERN_METHOD(stopInAppPurchaseTracking)

RCT_EXTERN_METHOD(isInAppPurchaseTrackingEnabled:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject)

@end

// WebInterface
@interface RCT_EXTERN_MODULE(WebInterfaceInteractor, NSObject)

RCT_EXTERN_METHOD(createWebInterfaceScript:(nonnull NSString*)webToken
                  postMessageScript:(nonnull NSString*)postMessageScript
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(handleWebInterfaceCommand:(nonnull NSString*)command)

@end
