import { NetworkProxy } from "../../../drivers/network/typings"
import {CTAType, INudgesRepository, Nudge, NudgeScreenType} from "./typings"

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<Nudge[]> => {
        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 [
            {
                "ref": "inv_3",
                "time": "2023-07-21T15:13:00+02:00",
                "nd": {
                    "type": "message",
                    "cta":"redirect",
                    "message": {
                        "title": "hello",
                        "tmpl_cfg": {
                            "tmpl_type": "item_pair",
                            "item_pair_cfg":{
                                "item_type":"drug"
                            }
                        },
                        "body": "{{ primary }} , world, {{ secondary }}",
                        "tags": []
                    },
                    "render_method": "push_notification"
                },
                "expire_at": now.toISOString(),
                "extra": {
                    "item_pair":{
                        "ids":["12", "13"],
                        "names":["Panadol", "Bruffin"]
                    }
                }
            }
        ]
    }

    public markNudgeAsShown = (nudgeId: string) => {
        return
    }

    public haveBeenAlreadyShown = (nudgeId: string) => {
        return false
    }
}
