OVH Click 2 Call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\ConfigOvh; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Auth; | |
use Illuminate\Support\Facades\Session; | |
use Ovh\Api; | |
class OvhClick2CallController extends Controller | |
{ | |
public function test() | |
{ | |
return view('admin.ovhClick2Call.test'); | |
} | |
/** | |
* @param Request $request | |
* @return \Illuminate\Http\RedirectResponse | |
* @throws \Illuminate\Validation\ValidationException | |
* @throws \Ovh\Exceptions\InvalidParameterException | |
*/ | |
public function click2Call(Request $request) | |
{ | |
$this->validate(request(), [ | |
'calledNumber' => 'required', | |
]); | |
$calledNumber = phoneNumberFormat($request->calledNumber); | |
if (ConfigOvh::where('active', true)->where('click2Call', true)->count()) { | |
if (! empty(Auth::user()->ovhBillingAccount) | |
&& ! empty(Auth::user()->ovhCallingNumber)) { | |
$configOvh = ConfigOvh::where('active', true)->where('click2Call', true)->first(); | |
$api = new Api($configOvh->app_key, $configOvh->app_secret, $configOvh->app_endpoint, $configOvh->app_conskey); | |
$api->post('/telephony/'.Auth::user()->ovhBillingAccount.'/line/'.Auth::user()->ovhCallingNumber.'/click2Call', [ | |
'calledNumber' => $calledNumber, | |
'intercom' => true, | |
]); | |
flash(__('app.ovhClick2CallUp', ['calledNumber' => $calledNumber]))->success(); | |
return back(); | |
} else { | |
flash(__('app.ovhClick2CallNotConfigured'))->error(); | |
return back(); | |
} | |
} else { | |
flash(__('app.ovhClick2CallNotConfigured'))->error(); | |
return back(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment