<commit_before>import { EnumRequestType, ErrorCode, HandleRequest, JovoError, Plugin, Util } from 'jovo-core';

import { GoogleBusinessBot } from '../core/GoogleBusinessBot';
import { GoogleBusinessRequest } from '../core/GoogleBusinessRequest';
import { GoogleBusinessResponse } from '../core/GoogleBusinessResponse';
import { GoogleBusinessUser } from '../core/GoogleBusinessUser';
import { GoogleBusiness } from '../GoogleBusiness';
import { TextResponse } from '../Interfaces';

export class GoogleBusinessCore implements Plugin {
  install(googleBusiness: GoogleBusiness) {
    googleBusiness.middleware('$init')!.use(this.init.bind(this));
    googleBusiness.middleware('$request')!.use(this.request.bind(this));
    googleBusiness.middleware('$type')!.use(this.type.bind(this));
    googleBusiness.middleware('$output')!.use(this.output.bind(this));
  }

  async init(handleRequest: HandleRequest) {
    const requestObject: GoogleBusinessRequest = handleRequest.host.getRequestObject();
    if (
      requestObject.agent &&
      requestObject.conversationId &&
      requestObject.customAgentId &&
      requestObject.requestId
    ) {
      handleRequest.jovo = new GoogleBusinessBot(
        handleRequest.app,
        handleRequest.host,
        handleRequest,
      );
    }
  }

  async request(googleBusinessBot: GoogleBusinessBot) {
    if (!googleBusinessBot.$host) {
      throw new JovoError(
        "Couldn't access $host object",
        ErrorCode.ERR_PLUGIN,<commit_msg>:art: Format<commit_after>import { EnumRequestType, ErrorCode, HandleRequest, JovoError, Plugin, Util } from 'jovo-core';

import { GoogleBusinessBot } from '../core/GoogleBusinessBot';
import { GoogleBusinessRequest } from '../core/GoogleBusinessRequest';
import { GoogleBusinessResponse } from '../core/GoogleBusinessResponse';
import { GoogleBusinessUser } from '../core/GoogleBusinessUser';
import { GoogleBusiness } from '../GoogleBusiness';
import { TextResponse } from '../Interfaces';

export class GoogleBusinessCore implements Plugin {
  install(googleBusiness: GoogleBusiness) {
    googleBusiness.middleware('$init')!.use(this.init.bind(this));
    googleBusiness.middleware('$request')!.use(this.request.bind(this));
    googleBusiness.middleware('$type')!.use(this.type.bind(this));
    googleBusiness.middleware('$output')!.use(this.output.bind(this));
  }

  async init(handleRequest: HandleRequest) {
    const requestObject: GoogleBusinessRequest = handleRequest.host.getRequestObject();
    if (
      requestObject.agent &&
      requestObject.conversationId &&
      requestObject.customAgentId &&
      requestObject.requestId
    ) {
      handleRequest.jovo = new GoogleBusinessBot(
        handleRequest.app,
        handleRequest.host,
        handleRequest,
      );
    }
  }

  async request(googleBusinessBot: GoogleBusinessBot) {
    if (!googleBusinessBot.$host) {
      throw new JovoError(
        `Couldn't access $host object`,
        ErrorCode.ERR_PLUGIN,
{'fraction_non_alphanumeric': 0.12520924004017409, 'fraction_numerical': 0.0, 'mean_word_length': 4.1875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2772446', 'n_tokens_mistral': 859, 'n_tokens_neox': 796, 'n_words': 150}