@causalfoundry/js-sdk
Version:
Causal Foundry WEB SDK (JS/TS)
78 lines (64 loc) • 1.62 kB
text/typescript
import {NudgeScreenType} from "../../commonTypes";
export enum CTAType {
None = '',
Redirect = 'redirect',
AddToCart = 'add_to_cart'
}
export enum NudgeDefinitionType {
message = 'message',
inAppComponent = 'in_app_component'
}
export enum NudgeRenderMethodType {
push_notification = 'push_notification',
inAppMessage = 'in_app_message',
inAppComponent = 'in_app_component'
}
export interface CTA {
type: CTAType,
cta_resource: CTAResource,
}
export interface CTAResource {
type: string,
id: string
}
export interface Nudge {
internalId: number
ref: string,
nd: NudgeDefinition,
time: string,
expire_at?: string,
extra: NudgeExtraObject
}
export interface NudgeDefinition {
type: NudgeRenderMethodType,
render_method: NudgeDefinitionType,
cta: string,
message: NudgeMessageObject
}
export interface NudgeTemplateObject {
tmpl_type: string,
item_pair_cfg: NudgeTemplateItemPairObject
traits: Array<string>
}
export interface NudgeTemplateItemPairObject {
item_type: string
}
export interface NudgeMessageObject {
title: string,
body: string,
tmpl_cfg?: NudgeTemplateObject
tags: string[]
}
export interface NudgeExtraObject {
item_pair: NudgeExtraItemPairObject,
traits: any,
}
export interface NudgeExtraItemPairObject {
ids: string[],
names: string[]
}
export interface INudgesRepository {
getNudges(userId: string, nudgeScreenType: NudgeScreenType): Promise<Nudge[]>
markNudgeAsShown(nudgeId: string): void
haveBeenAlreadyShown(nudgeId: string): boolean
}