Esempio n. 1
0
 public function fire($job, $outbound_id)
 {
     $outbound = Outbound::findOrFail($outbound_id);
     $nexmo = new NexmoAccount(Cache::get('NEXMO_KEY', getenv('NEXMO_KEY')), Cache::get('NEXMO_SECRET', getenv('NEXMO_SECRET')));
     $response = $nexmo->sendMessage($outbound->from, $outbound->to, $outbound->text, array('status-report-req' => 1, 'client-ref' => $outbound_id));
     $isSent = true;
     if ($response['message-count'] > 0) {
         foreach ($response['messages'] as $message) {
             $outbound_chunk = new OutboundChunk();
             $outbound_chunk->outbound_id = $outbound_id;
             $outbound_chunk->message_id = $message['message-id'];
             $outbound_chunk->status_code = $message['status'];
             $outbound_chunk->price = $message['message-price'];
             $outbound_chunk->save();
             // update balance
             Pusherer::trigger('boom', 'update_balance', $message['remaining-balance']);
             if ($message['status'] > 0) {
                 $isSent = false;
             }
         }
     }
     // update status outbound
     if ($isSent) {
         $outbound->status = 'sent';
         $outbound->save();
     }
     $job->delete();
 }
Esempio n. 2
0
 public function setupNumberCallbackUrl($job, $data)
 {
     $nexmo = new NexmoAccount($data['nexmo_key'], $data['nexmo_secret']);
     $updated = $nexmo->updateNumber($data['country_code'], $data['number'], url('callback/mo'), array('voiceStatusCallback' => url('callback/voice')));
     if ($updated) {
         return $job->delete();
     }
     $job->release();
 }
Esempio n. 3
0
 public function setupDnCallbackUrl($job, $data)
 {
     $nexmo = new NexmoAccount($data['nexmo_key'], $data['nexmo_secret']);
     $nexmo->updateAccountSettings(array('drCallBackUrl' => url('callback/dn')));
     $job->delete();
 }
Esempio n. 4
0
 public function getSearch($country_code)
 {
     $nexmo = new NexmoAccount(Cache::get('NEXMO_KEY', getenv('NEXMO_KEY')), Cache::get('NEXMO_SECRET', getenv('NEXMO_SECRET')));
     return $nexmo->getAvailableInboundNumbers($country_code, array('size' => 100));
 }
Esempio n. 5
0
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::filter('nexmo', function () {
    $nexmo_key = getenv('NEXMO_KEY') ?: (Schema::hasTable('cache') ? Cache::get('NEXMO_KEY') : false);
    $nexmo_secret = getenv('NEXMO_SECRET') ?: (Schema::hasTable('cache') ? Cache::get('NEXMO_SECRET') : false);
    if (!$nexmo_key || !$nexmo_secret) {
        return Redirect::to('start');
    }
    // validate nexmo credentials
    $nexmo = new NexmoAccount($nexmo_key, $nexmo_secret);
    try {
        $isNexmoValid = Cache::get('nexmo');
        if (!$isNexmoValid) {
            Cache::put('nexmo', $nexmo->getBalance(), 10);
        }
    } catch (Exception $e) {
        return Redirect::to('start');
    }
});
/*
*	Main page
*/
Route::filter('dashboardFilter', function () {
    if (!Schema::hasTable('users')) {
        return Redirect::to('start');