Add mobile api privacy settings call #130

This commit is contained in:
Kendrick Chan 2018-05-23 22:40:44 +08:00
parent 7d3873022e
commit be5a66e68a
2 changed files with 64 additions and 0 deletions

View file

@ -1428,4 +1428,33 @@ class APIController extends Controller
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();
}
}

View file

@ -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;
}
}