/**
 * Copyright © 2022 Anagog Ltd. All rights reserved.
 */

import { NativeModules } from "react-native";
import type { JEMAUserInteractionEventTriggerType } from "./../types/JEMAUserInteractionEventTriggerType";
import { AnagogLogger } from "./../AnagogLogger";
const { JedAIModule } = NativeModules;

export class JEMAUserInteractionEvent {

  public readonly campaignIdentifier: string;
  public readonly triggerType: JEMAUserInteractionEventTriggerType;

  constructor(campaignIdentifier: string, triggerType: JEMAUserInteractionEventTriggerType) {
    this.campaignIdentifier = campaignIdentifier;
    this.triggerType = triggerType;
  }

	/**
	 * Report user interaction event to JedAI.
	 */
  public send(): Promise<void> {
    AnagogLogger.info('Send UserInteractionEvent: ' + this.triggerType + ', ' + this.campaignIdentifier);
    return JedAIModule.sendUserInteractionEvent(this.campaignIdentifier, this.triggerType);
  }

}