UNPKG

@causalfoundry/js-sdk

Version:

Causal Foundry WEB SDK (JS/TS)

57 lines (50 loc) 1.97 kB
import { NetworkProxy } from "../../../drivers/network/typings" import {INudgesRepository, Nudge, NudgeResponseItem} from "./typings" import {NudgeScreenType} from "../../commonTypes"; export default class NudgesRepository implements INudgesRepository { private apiURL private networkDriver public constructor(url: string, bsNetwork: NetworkProxy) { this.apiURL = url this.networkDriver = bsNetwork } public getNudges = async (userId: string, nudgeScreenType : NudgeScreenType): Promise<NudgeResponseItem[]> => { const now = new Date() const expiryTime = new Date() const seconds = now.getSeconds() now.setSeconds(seconds + 5) // Date already takes into account changes in minutes ou hours expiryTime.setSeconds(seconds + 15) // Date already takes into account changes in minutes ou hours return [ { "payload": { "type": "message", "render_method": "in_app_message", "content": { "body": "Hello World of Kenkai", "title": "Hello World" }, "attr": { "render_page": "home" }, "internal": { "inv_id": 9, "ref_time": "2025-09-02T16:43:00Z", "action_id": 2, "expired_at": "2025-09-04T16:43:00Z", "model_class": "", "model_id": 0, "followup_of": 0, "followup_of_ref": "0001-01-01T00:00:00Z" } }, "error": null } ] } public markNudgeAsShown = (nudgeId: string) => { return } public haveBeenAlreadyShown = (nudgeId: string) => { return false } }