db = $db; $this->configurationService = $configurationService; } /** * @param int $pdContactId Pipedrive contact ID * * @return array */ public function getMappingByPipedriveId(int $pdContactId): array { return $this->db->fetchRow( 'SELECT p.id, p.created_at, p.data, p.address_id FROM `pipedrive_contacts` AS `p` WHERE p.hidden = 0 AND p.pd_contact_id = :id', ['id' => $pdContactId] ); } /** * @param int $addressId Xentral Address ID * * @return array */ public function getMappingByAddressId(int $addressId): array { return $this->db->fetchRow( 'SELECT p.id, p.created_at, p.data, p.pd_contact_id FROM `pipedrive_contacts` AS `p` WHERE p.hidden = 0 AND p.address_id = :id', ['id' => $addressId] ); } /** * @param int $addressId * @param bool $withStatusField * * @throws PipedriveConfigurationException * * @return array */ public function getInternalAddressById(int $addressId, bool $withStatusField = false): array { $placeHolder = ''; if ($withStatusField === true) { // @codeCoverageIgnoreStart $leadFields = $this->configurationService->matchSelectedAddressFreeField(); $lsField = $leadFields['pipedrive_ls_field']; $placeHolder = ", a.{$lsField}"; // @codeCoverageIgnoreEnd } $sql = 'SELECT a.id, a.lead, a.typ, a.sprache, a.name, a.vorname, a.nachname, a.land, a.ort, a.plz, a.bundesstaat, a.telefon, a.email %s FROM `adresse` AS `a` WHERE a.geloescht = 0 AND a.id = :id'; return $this->db->fetchRow(sprintf($sql, $placeHolder), ['id' => $addressId]); } }