Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Latest commit

 

History

History
446 lines (315 loc) · 10.6 KB

index.md

File metadata and controls

446 lines (315 loc) · 10.6 KB

DOCUMENTATION

Create an event listener in the src/AppBundle/EventListener directory of your project:

namespace AppBundle\EventListener;

use WBW\Bundle\SmsModeBundle\Event\DeliveryReportCallbackEvent;
use WBW\Bundle\SmsModeBundle\Event\SmsReplyCallbackEvent;

class SmsEventListener {

    /**
     * On delivery report callback.
     *
     * @param DeliveryReportCallbackEvent $event The event.
     * @return DeliveryReportCallbackEvent Returns the event.
     */
    public function onDeliveryReportCallback(DeliveryReportCallbackEvent $event) {

        $deliveryReportCallback = $event->getDeliveryReportCallback();

        // YOUR CODE HERE 

        return $event;
    }

    /**
     * On SMS reply callback.
     *
     * @param SmsReplyCallbackEvent $event The event.
     * @return SmsReplyCallbackEvent Returns the event.
     */
    public function onSmsReplyCallback(SmsReplyCallbackEvent $event) {

        $smsReplyCallback = $event->getSmsReplyCallback();

        // YOUR CODE HERE 

        return $event;
    }
}

Add this event listener in app/config/services.yml file of your project:

services:

    app.smsmode.event_listener:
        class: AppBundle\EventListener\SmsEventListener
        tags:
            - { name: "kernel.event_listener", event: "wbw.smsmode.event.delivery_report_callback", method: "onDeliveryReportCallback" }
            - { name: "kernel.event_listener", event: "wbw.smsmode.event.sms_reply_callback",       method: "onSmsReplyCallback" }
  1. Authentication

Add this parameters in the app/config/config.yml file of your project:

parameters:

    # Set a couple login/password
    smsmode.pseudo: "pseudo"
    smsmode.pass:   "pass"
    
    # or use an access token
    #smsmode.token:  "token"

Creating an API key :

Add the following code in a command or controller class:

// Create a creating API key event.
$event = new CreatingApiKeyEvent();

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();

$response->getId();
$response->getAccessToken();
$response->getAccount();
$response->getCreationDate();
$response->getExpiration();
$response->getState();
  1. Sending SMS message

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement SendingSmsMessageInterface.

$model->getSmsModeNotificationUrl() must return the generated route 'wbw_smsmode_delivery_report_callback' if you want receive callback into the event listener.

$model->getSmsModeNotificationUrlReponse() must return the generated route 'wbw_smsmode_reply_callback' if you want receive callback into the event listener.

// Create a sending SMS message event.
$event = new SendingSmsMessageEvent($model); 

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();

$response->getSmsID();
  1. Delivery report

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement DeliveryReportInterface.

// Create a delivery report event.
$event = new DeliveryReportEvent($model); 

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();

foreach($response->getDeliveryReports() as $current) {
    $current->getCode();
    $current->getNumero();
}
  1. Account balance

Add the following code in a command or controller class:

// Create a account balance event.
$event = new AccountBalanceEvent();

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();

$response->getAccountBalance();
  1. Creating sub-account

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement CreatingSubAccountInterface.

// Create a creating sub-account event.
$event = new CreatingSubAccountEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();

Deleting sub-account :

IMPORTANT NOTICE:

The following $model must implement DeletingSubAccountInterface.

// Create a deleting sub-account API key event.
$event = new DeletingSubAccountEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();
  1. Transferring credits from one account to another

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement TransferringCreditsInterface.

// Create a transferring credits event.
$event = new TransferringCreditsEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();
  1. Adding contacts

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement AddingContactInterface.

// Create an adding contact event.
$event = new AddingContactEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();
  1. Deleting SMS

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement DeletingSmsInterface.

// Create a deleting SMS event.
$event = new DeletingSmsEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();
  1. Sent SMS message list

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement SentSmsMessageListInterface.

// Create a sent SMS message list event.
$event = new SentSmsMessageListEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();

foreach($response->getSentSmsMessages() as $current) {
    $current->getSmsID();
    $current->getSendDate();
    $current->getMessage();
    $current->getNumero();
    $current->getCostCredits();
    $current->getRecipientCount();
}
  1. Checking SMS message status

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement CheckingSmsMessageStatusInterface.

// Create a checking SMS message status event.
$event = new CheckingSmsMessageStatusEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();
  1. Retrieving SMS replies

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement RetrievingSmsReplyInterface.

// Create a retrieving SMS reply event.
$event = new RetrievingSmsReplyEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();

foreach($response->getSmsReplies() as $current) {
    $current->getResponseID();
    $current->getReceptionDate();
    $current->getFrom();
    $current->getText();
    $current->getTo();
    $current->getMessageID();
}
  1. Sending text-to-speech SMS

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement SendingTextToSpeechSmsInterface.

// Create a sending text-to-speech SMS event.
$event = new SendingTextToSpeechSmsEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();

$response->getSmsID();
  1. Sending unicode SMS

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement SendingUnicodeSmsInterface.

$model->getSmsModeNotificationUrl() must return the generated route 'wbw_smsmode_delivery_report_callback' if you want receive callback into the event listener.

$model->getSmsModeNotificationUrlReponse() must return the generated route 'wbw_smsmode_reply_callback' if you want receive callback into the event listener.

// Create a sending unicode SMS event.
$event = new SendingUnicodeSmsEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();

$response->getSmsID();
  1. Sending SMS in batch mode (attached file)

Add the following code in a command or controller class:

IMPORTANT NOTICE:

The following $model must implement SendingSmsBatchInterface.

$model->getSmsModeNotificationUrl() must return the generated route 'wbw_smsmode_delivery_report_callback' if you want receive callback into the event listener.

// Create a sending SMS batch event.
$event = new SendingSmsBatchEvent($model);

// Get the event dispatcher and dispatch the event.
$this->get("event_dispatcher")->dispatch($event->getEventName(), $event);

// Handle the response.
$response = $event->getResponse();

$response->getCode();
$response->getDescription();

$response->getCampagneID();