export enum NudgeDefinitionType {
    message = 'message',
    UIComponent = 'ui_component',
}

export enum NudgeRenderMethodType {
    push_notification = 'push_notification',
    inAppMessage = 'in_app_message',
    inAppComponent = 'in_app_component',
}

export interface CTAResource {
    type: string;
    id: string;
}

export interface MessageInternal {
    inv_id: number;
    ref_time: string;
    action_id: number;
    expired_at: string;
    model_class: string;
    model_id: number;
    followup_of: number;
    followup_of_ref: string;
}

export enum NudgeAction {
    Shown = 'shown',
    Error = 'error',
    Block = 'block',
    Discard = 'discard',
    Open = 'open',
    Expired = 'expired',
}

export enum NudgeType {
    Push = 'push_notification',
    InApp = 'in_app_message',
}

export interface NudgeResponseProperties {
    response: string;
    details?: string;
    internal: any;
}

export interface Nudge {
    type: string;
    render_method: string;
    delivery_mode: string;
    content: Record<string, any>;
    attr: Record<string, any>;
    internal: any;
    tags?: any;
}

export interface NudgeResponseItem {
    payload: Nudge;
    error?: string | null;
}

export interface INudgesRepository {
    getNudges(
        userId: string,
        nudgeScreenType: string
    ): Promise<NudgeResponseItem[]>;

    markNudgeAsShown(nudgeId: string): void;

    haveBeenAlreadyShown(nudgeId: string): boolean;
}

export interface ActionAPIResponse {
    data?: NudgeResponseItem[];
}

export type NudgeCallBack = {
    cta: 'redirect' | 'add_to_cart';
    id?: string;
};

// Legacy support
export interface CTA {
    type: CTAType,
    cta_resource: CTAResource,
}

export enum CTAType {
    None = '',
    Redirect = 'redirect',
    AddToCart = 'add_to_cart'
}

export interface CTAResource {
    type: string,
    id: string
}
