Example #1
0
    /**
     * Wysyla SMS w postaci szablonu
     *
     * @throws Exception
     * @return mixed
     */
    protected function _sendTemplate()
    {
        if (!isset($this->_content['name']) || empty($this->_content['name'])) {
            throw new Exception('Nie zarejestrowano nazwy szablonu', 3);
        }
        if (!isset($this->_content['content']) || empty($this->_content['content'])) {
            throw new Exception('Nie zarejestrowano tresci szablonu', 3);
        }
        if (!isset($this->_content['params']) || empty($this->_content['params']) || !is_array($this->_content['params'])) {
            throw new Exception('Nie zarejestrowano listy parametrow szablonu (klucz => wartosc)', 3);
        }

        if ($this->_charCode && $this->_charCode != 'UTF-8') {
            $this->_content['content'] = iconv($this->_charCode, 'UTF-8', $this->_content['content']);
        }

        $templateContent = $this->_isNew ? $this->_content['content'] : null;

        if ($this->_isConfidental) {
            $this->_response = $this->_client->templateconfidental(
                            $clientHash = $this->_config['clientHash'], $serviceHash = $this->_config['serviceHash'], $number = $this->_number, $templateName = $this->_content['name'], $templateHash = md5($this->_content['content']), $templateParams = $this->_content['params'], $templateParamsConfidental = $this->_content['paramsConfidental'], $templateContent = $templateContent
            );
        } else {
            $this->_response = $this->_client->template(
                            $clientHash = $this->_config['clientHash'], $serviceHash = $this->_config['serviceHash'], $number = $this->_number, $templateName = $this->_content['name'], $templateHash = md5($this->_content['content']), $templateParams = $this->_content['params'], $templateContent = $templateContent
            );
        }
    }