import { Request } from '../Request'; import type { IEventRequest } from './types'; export class EventRequest extends Request { protected itemId?: string; protected timestamp: number; protected eventType: string; protected eventValue?: string; protected from?: string; protected url?: string; protected ref?: string; protected recommendationId?: string; protected userProperties?: Record; protected eventProperties?: Record; constructor({ itemId, timestamp, eventType, eventValue, from, url, ref, recommendationId, userProperties, eventProperties, }: IEventRequest) { super('POST', '/events'); this.itemId = itemId; this.timestamp = timestamp; this.eventType = eventType; this.eventValue = eventValue; this.from = from; this.url = url; this.ref = ref; this.recommendationId = recommendationId; this.userProperties = userProperties; this.eventProperties = eventProperties; } getTimestamp(): number { return this.timestamp; } getPayload(): object { return { item_id: this.itemId, timestamp: this.timestamp, event_type: this.eventType, event_value: this.eventValue, from: this.from, url: this.url, ref: this.ref, recommendation_id: this.recommendationId, user_properties: this.userProperties, event_properties: this.eventProperties, }; } }