UNPKG

@inworld/web-core

Version:
39 lines (38 loc) 1.36 kB
import { Feedback } from '../../entities/feedback.entity.js'; import { FeedbackService as PbService } from '../pb/feedback.service.js'; export class FeedbackService { constructor(connection) { this.service = new PbService(); this.connection = connection; } async like(props) { return this.send(Object.assign(Object.assign({}, props), { isLike: true })); } async dislike(props) { return this.send(Object.assign(Object.assign({}, props), { isLike: false })); } async undo(name) { const session = await this.connection.ensureSessionToken(); return this.service.deleteInteractionFeedback({ config: this.connection.getConfig(), name, session, }); } async send(props) { const session = await this.connection.ensureSessionToken(); const interactionFeedback = new Feedback({ isLike: props.isLike, types: props.types, comment: props.comment, }).toProto(); return this.service.createInteractionFeedback({ scene: this.connection.getSceneName(), config: this.connection.getConfig(), correlationId: props.correlationId, interactionFeedback, interactionId: props.interactionId, session, }); } }