Ejemplo n.º 1
0
 public function findOrganizations($criteria = array())
 {
     if (empty($criteria) || !array_key_exists('organizationType', $criteria)) {
         throw new \Exception('Unknown organisations with these given criteria');
     }
     if (array_key_exists('departementCode', $criteria)) {
         $criteria['zipcode'] = $criteria['departementCode'] . '*';
     }
     $data = null;
     try {
         $request = $this->client->get('organizations', array(), array('query' => $criteria));
         $response = $request->send()->json();
         if (StatusConstants::OK == $response['status']) {
             $data = array();
             if (isset($response['data']) && !empty($response['data'])) {
                 foreach ($response['data'] as $org) {
                     $data[] = Organization::fromJson($org);
                 }
             }
         } else {
             throw new \Exception($response['message'], StatusConstants::toCode($response['status']));
         }
     } catch (\Exception $e) {
         throw new \Exception('Erreur lors de l\'appel au P4S : findOrganizations()', StatusConstants::toCode(StatusConstants::UNKNOWN_ERROR), $e);
     }
     return $data;
 }
Ejemplo n.º 2
0
 public static function fromJson($data)
 {
     $id = null;
     if (array_key_exists('org_id', $data)) {
         $id = $data['org_id'];
     } elseif (array_key_exists('id', $data)) {
         $id = $data['id'];
     }
     $org = new Organization(@$data['name'], @$data['organization_type'], @$data['website']);
     $org->setId($id);
     $org->setAddress($data);
     $org->setTel(@$data['phone']);
     $org->setFax(@$data['fax']);
     $org->setEmail(@$data['fax']);
     $org->setLogo(@$data['logo']);
     $org->setFinessNumber(@$data['finess_number']);
     $org->setSirenNumber(@$data['siren_number']);
     $org->setSiretNumber(@$data['siret_number']);
     return $org;
 }