Merge branch '130-ios-api-calls' into 'master'
Resolve "iOS API calls" Closes #130 See merge request jankstudio/resq!111
This commit is contained in:
commit
2dddcfb35f
4 changed files with 122 additions and 0 deletions
|
|
@ -104,3 +104,13 @@ api_device_id:
|
|||
path: /api/device_id
|
||||
controller: App\Controller\APIController:updateDeviceID
|
||||
methods: [POST]
|
||||
|
||||
api_privacy:
|
||||
path: /api/privacy
|
||||
controller: App\Controller\APIController:privacySettings
|
||||
methods: [POST]
|
||||
|
||||
api_resend_code:
|
||||
path: /api/resend_code
|
||||
controller: App\Controller\APIController:resendCode
|
||||
methods: [POST]
|
||||
|
|
|
|||
|
|
@ -1398,4 +1398,63 @@ class APIController extends Controller
|
|||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function resendCode(Request $req)
|
||||
{
|
||||
$required_params = [];
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
|
||||
// already confirmed
|
||||
if ($this->session->isConfirmed())
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('User is already confirmed.');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
// have sent code before
|
||||
if ($this->session->getDateCodeSent() != null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Can only send confirm code every 5 mins.');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
|
||||
// TODO: send via sms
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function privacySettings(Request $req)
|
||||
{
|
||||
$required_params = [
|
||||
'priv_third_party',
|
||||
'priv_promo',
|
||||
];
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
|
||||
// get customer
|
||||
$cust = $this->session->getCustomer();
|
||||
if ($cust == null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('No customer information found');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
// set privacy settings
|
||||
$cust->setPrivacyThirdParty($req->request->get('priv_third_party'))
|
||||
->setPrivacyPromo($req->request->get('priv_promo'));
|
||||
|
||||
$em->flush();
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,6 +131,16 @@ class Customer
|
|||
*/
|
||||
protected $email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $priv_third_party;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="boolean")
|
||||
*/
|
||||
protected $priv_promo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->numbers = new ArrayCollection();
|
||||
|
|
@ -152,6 +162,9 @@ class Customer
|
|||
$this->phone_fax = '';
|
||||
|
||||
$this->email = '';
|
||||
|
||||
$this->priv_third_party = 0;
|
||||
$this->priv_promo = 0;
|
||||
}
|
||||
|
||||
public function getID()
|
||||
|
|
@ -379,4 +392,26 @@ class Customer
|
|||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setPrivacyThirdParty($bool = true)
|
||||
{
|
||||
$this->priv_third_party = $bool;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrivacyThirdParty()
|
||||
{
|
||||
return $this->priv_third_party;
|
||||
}
|
||||
|
||||
public function setPrivacyPromo($bool = true)
|
||||
{
|
||||
$this->priv_promo = $bool;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrivacyPromo()
|
||||
{
|
||||
return $this->priv_promo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,12 @@ class MobileSession
|
|||
*/
|
||||
protected $date_confirmed;
|
||||
|
||||
// date and time that the confirmation code was last sent
|
||||
/**
|
||||
* @ORM\Column(type="datetime", nullable=true)
|
||||
*/
|
||||
protected $date_code_sent;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -88,6 +94,7 @@ class MobileSession
|
|||
$this->customer = null;
|
||||
$this->confirm_flag = false;
|
||||
$this->date_confirmed = null;
|
||||
$this->date_code_sent = null;
|
||||
}
|
||||
|
||||
public function generateKeyID()
|
||||
|
|
@ -204,4 +211,15 @@ class MobileSession
|
|||
{
|
||||
return $this->date_confirmed;
|
||||
}
|
||||
|
||||
public function setDateCodeSent(DateTime $date)
|
||||
{
|
||||
$this->date_code_sent = $date;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDateCodeSent()
|
||||
{
|
||||
return $this->date_code_sent;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue