public function send(MessageInterface $message, $skipErrors = true) {
        if (count($message->getRecipient()) > self::MAX_RECIPIENS) {
            throw new ConfigurationException('Too many recipiens. For SerwerSms gateway limit is ' . self::MAX_RECIPIENS);
        }

        $client = $this->getClient();

        // details must be always true
        $extraParams = $this->getParam('extra');
        if (!isset($extraParams['details']) || $extraParams['details'] === false) {
            $extraParams['details'] = true;
        }

        try {
            $response = $client->messages->sendSms(
                $message->getRecipients(),
                $message->getText(),
                $this->getParam('sender'),
                $extraParams
            );

            if ((int)$response->unsent > 0) {
                foreach ($response->items as $item) {
                    // @see http://dev.serwersms.pl/https-api-v2/wysylanie-wiadomosci-sms-o-jednakowej-tresci
                    if ($item->status === 'unsent') {
                        $this->addError(new SendingError($item->phone, $item->error_code, $item->error_message . 'id:' . $item->id));
                        if (!$skipErrors) {
                            throw new \RuntimeException($item->error_message, $item->error_code);
                        }
                    }
                }
            }
        }
        catch (Exception $e) {
            $this->addError(new SendingError('', $e->getCode(), $e->getMessage()));
            if (!$skipErrors) {
                throw new \RuntimeException($e->getMessage());
            }
        }
        return $this->getErrors()->count() === 0;
    }
public function send(MessageInterface $message, $skipErrors = true) {
        if (count($message->getRecipient()) > self::MAX_RECIPIENS) {
            throw new ConfigurationException('Too many recipiens. For SerwerSms gateway limit is ' . self::MAX_RECIPIENS);
        }

        $client = $this->getClient();

        // details must be always true
        $extraParams = $this->getParam('extra');
        if (!isset($extraParams['details']) || $extraParams['details'] === false) {
            $extraParams['details'] = true;
        }

        try {
            $response = $client->messages->sendSms(
                $message->getRecipients(),
                $message->getText(),
                $this->getParam('sender'),
                $extraParams
            );

            if ((int)$response->unsent > 0) {
                foreach ($response->items as $item) {
                    // @see http://dev.serwersms.pl/https-api-v2/wysylanie-wiadomosci-sms-o-jednakowej-tresci
                    if ($item->status === 'unsent') {
                        $this->addError(new SendingError($item->phone, $item->error_code, $item->error_message . 'id:' . $item->id));
                        if (!$skipErrors) {
                            throw new \RuntimeException($item->error_message, $item->error_code);
                        }
                    }
                }
            }
        }
        catch (Exception $e) {
            $this->addError(new SendingError('', $e->getCode(), $e->getMessage()));
            if (!$skipErrors) {
                throw new \RuntimeException($e->getMessage());
            }
        }
        return $this->getErrors()->count() === 0;
    }
public function send ( MessageInterface $ message , $ skipErrors = true ) { if ( count ( $ message -> getRecipient ( ) ) > self :: MAX_RECIPIENS ) { throw new ConfigurationException ( 'Too many recipiens. For SerwerSms gateway limit is ' . self :: MAX_RECIPIENS ) ; } $ client = $ this -> getClient ( ) ; // details must be always true $ extraParams = $ this -> getParam ( 'extra' ) ; if ( ! isset ( $ extraParams [ 'details' ] ) || $ extraParams [ 'details' ] === false ) { $ extraParams [ 'details' ] = true ; } try { $ response = $ client -> messages -> sendSms ( $ message -> getRecipients ( ) , $ message -> getText ( ) , $ this -> getParam ( 'sender' ) , $ extraParams ) ; if ( ( int ) $ response -> unsent > 0 ) { foreach ( $ response -> items as $ item ) { // @see http://dev.serwersms.pl/https-api-v2/wysylanie-wiadomosci-sms-o-jednakowej-tresci if ( $ item -> status === 'unsent' ) { $ this -> addError ( new SendingError ( $ item -> phone , $ item -> error_code , $ item -> error_message . 'id:' . $ item -> id ) ) ; if ( ! $ skipErrors ) { throw new \ RuntimeException ( $ item -> error_message , $ item -> error_code ) ; } } } } } catch ( Exception $ e ) { $ this -> addError ( new SendingError ( '' , $ e -> getCode ( ) , $ e -> getMessage ( ) ) ) ; if ( ! $ skipErrors ) { throw new \ RuntimeException ( $ e -> getMessage ( ) ) ; } } return $ this -> getErrors ( ) -> count ( ) === 0 ; }
Send message through SerwerSms gateway
@param SmsMessageModel $message
@return bool
Send message through SerwerSms gateway