GitHub

Original file line numberDiff line numberDiff line change

@@ -377,6 +377,37 @@ public function remarketingList(Request $request, Response $response,

377377

return $response->withHeader("Content-type", "text/csv");

378378

}

379379
380+

public function startSms(Request $request, Response $response, $id,

381+

View $view, \Scat\Service\Data $data)

382+

{

383+

$person= $data->factory('Person')->find_one($id);

384+

if (!$person)

385+

throw new \Slim\Exception\HttpNotFoundException($request);

386+
387+

$accept= $request->getHeaderLine('Accept');

388+

if (strpos($accept, 'application/vnd.scat.dialog+html') !== false) {

389+

return $view->render($response, 'dialog/sms.html', [

390+

'person' => $person,

391+

]);

392+

}

393+
394+

throw new \Exception("This has to be a dialog.");

395+

}

396+
397+

public function sendSms(Request $request, Response $response, $id,

398+

\Scat\Service\Data $data, \Scat\Service\Phone $phone)

399+

{

400+

$person= $data->factory('Person')->find_one($id);

401+

if (!$person)

402+

throw new \Slim\Exception\HttpNotFoundException($request);

403+
404+

error_log("Sending message to {$person->phone}");

405+

$data= $phone->sendSMS($person->phone,

406+

$request->getParam('content'));

407+
408+

return $response;

409+

}

410+
380411

public function getTaxExemption(Request $request, Response $response, $id,

381412

\Scat\Service\Data $data,

382413

\Scat\Service\Tax $tax,

Read the original on github.com ↗