<?php

namespace Yuvayana\Acadlix\Common\Feedback;

defined('ABSPATH') || exit();

class Feedback
{
  protected $_slug;
  public function __construct()
  {
    $this->setup_feedback();
  }

  protected function get_slug()
  {
    if (!$this->_slug) {
      $this->_slug = acadlix()->pro ? 'acadlix-pro' : 'acadlix';
    }
    return $this->_slug;
  }

  public function setup_feedback()
  {
    if (!class_exists('\IgniteKit\WP\DeactivateFeedbackClient\Main')) {
      return;
    }
    try {
      new \IgniteKit\WP\DeactivateFeedbackClient\Main([
        'name' => ACADLIX_PLUGIN_NAME,
        'slug' => $this->get_slug(),
        'version' => ACADLIX_VERSION,
        'prefix' => 'acadlix_',
        'public_path' => str_replace('/', DIRECTORY_SEPARATOR, dirname(ACADLIX_PLUGIN_FILE) . '/vendor/ignitekit/wp-deactivate-feedback-client/public/'),
        'public_url' => rtrim(plugin_dir_url(ACADLIX_PLUGIN_FILE), '/') . '/vendor/ignitekit/wp-deactivate-feedback-client/public/',
        'api_url' => "https://acadlix.in/wp-json/deactivate-feedback/v1/send",
        'data' => ['website', 'system', 'contact'],
      ]);
    } catch (\Exception $e) {
    }
  }
}