--- /dev/null
+<?php
+
+class CustomersController extends ApplicationController {
+
+ const SEARCH_LIMIT = 50;
+
+ /** @var PdoCustomerManager */
+ private $pdoCustomerManager;
+
+ private function getPdoCustomerManager(){
+ if (! $this->pdoCustomerManager){
+ $this->pdoCustomerManager = new PdoCustomerManager();
+ }
+ return $this->pdoCustomerManager;
+ }
+
+ /**
+ * @api {get} /index.php?action=customers_nb Récupération du nombre de clients
+ * @apiName Nb customers
+ * @apiGroup Customers
+ * @apiVersion 1.0.0
+ *
+ * @apiSuccessExample {json} Success-Reponse:
+ * 349
+ */
+ public function nbAction(){
+ return $this->getPdoCustomerManager()->getNbCustomers();
+ }
+
+ /**
+ * @api {get} /index.php?action=customers_list Récupère la liste des clients
+ * @apiGroup Customers
+ * @apiVersion 1.0.0
+ * @apiParam {Number} limit Nombre d'élements à récupérer
+ * @apiParam {Number} offset Numéro du premier élement à récupérer
+ *
+ * @apiSuccessExample {json} Success-Reponse:
+ * [{"id":"1","ap_id":"XYZT","name":"METROPOLIS","ap_contact":"foo@bar.com"},{"id":"2","ap_id":"IJKL","name":"SMALLVILLE","ap_contact":null}]
+ */
+ public function listAction(){
+ $offset = $this->getOffsetParameter();
+ $limit = $this->getLimitParameter();
+ $customer = $this->getPdoCustomerManager()->getCustomersForOutput($offset,$limit);
+ return $customer;
+ }
+
+ public function existsAction(){
+ $ap_id = $this->getParameters()->get('ap_id');
+ return $this->getPdoCustomerManager()->apidExists($ap_id);
+ }
+
+ /**
+ * @api {get} /index.php?action=customers_info Information sur un client
+ * @apiGroup Customers
+ * @apiVersion 1.0.0
+ * @apiParam {Int} id id du client
+ *
+ * @apiSuccessExample {json} Success-Reponse:
+ * a faire
+ */
+ public function infoAction(){
+ $id = $this->getParameters()->get('id');
+ $customer = $this->getPdoCustomerManager()->getCustomer($id);
+ return $customer;
+ }
+
+ /**
+ * @api {get} /index.php?action=customers_search Rechercher parmis les clients
+ * @apiGroup Customers
+ * @apiVersion 1.0.0
+ * @apiParam {String} q chaîne à chercher dans le nom ou l'identifiant AP du client
+ *
+ * @apiSuccessExample {json} Success-Reponse:
+ * {"retour":"OK","message":"","result":[{"name":"ADULLACT (34)","ap_id":""}]}
+ */
+ public function searchAction(){
+ $q = $this->getParameters()->get('q');
+ return $this->getPdoCustomerManager()->searchCustomer($q,self::SEARCH_LIMIT);
+ }
+
+}
\ No newline at end of file