<?php
/**
 * Created by PhpStorm.
 * User: devweb
 * Date: 15/02/21
 * Time: 15:37
 */

final class SendWhatsapp
{

    public $registry;
    private $config;
    private $user;
    private $load;

    private $whatsapp;

    public function __construct($registry)
    {
        $this->registry = $registry;
        $this->config = $registry->get('config');
        $this->user = $registry->get('user');
        $this->load = $registry->get('load');
    }

    protected function getInstance($typewhats)
    {
        $className = Type_WhatsQueue::getNickFromValue($typewhats);
        $this->whatsapp[$typewhats] = new $className($this->registry);
    }

    public function sendWhats($typewhats, $data_value, $attribute_value)
    {
        try {
            $this->getInstance($typewhats);
            return $this->whatsapp[$typewhats]->sendWhats($typewhats, $data_value, $attribute_value);
        } catch (Exception $e) {
            throw $e;
        }
    }

}