public function itemizedEntriesGet(\DateTime $start = null, \DateTime $end = null, $localUriList = null) { $result = $this->call('samurai.ItemizedEntriesGet', ['PeriodStart' => is_null($start) ? null : $start->format('Y-m-d\\TH:i:s'), 'PeriodEnd' => is_null($end) ? null : $end->format('Y-m-d\\TH:i:s'), 'LocalUriList' => $localUriList]); return array_map(function ($entry) { return ItemizedEntry::fromResponse($entry); }, $result['ItemizedEntries']); }
protected function insert($userId, ItemizedEntry $entry, UserSettings $userSettings) { /** @var \PDOStatement $stmt */ try { $sql = 'INSERT IGNORE INTO `*PREFIX*sipgate_itemized` ' . 'SET userId=:userId, time=:time, sourceUri=:sourceUri, targetUri=:targetUri, priceTotal=:priceTotal, ' . 'priceCurrency=:priceCurrency, ticksA=:ticksA, ticksB=:ticksB, unitsCharged=:unitsCharged, ' . 'tariffName=:tariffName, duration=:duration, tos=:tos'; $stmt = $this->db->prepare($sql); $stmt->bindValue(':userId', $userId, \PDO::PARAM_STR); $stmt->bindValue(':time', $entry->getTime()->format('Y-m-d H:i:s'), \PDO::PARAM_STR); $stmt->bindValue(':sourceUri', $entry->getSourceUri(), \PDO::PARAM_STR); $stmt->bindValue(':targetUri', $entry->getTargetUri(), \PDO::PARAM_STR); $stmt->bindValue(':priceTotal', $entry->getPrice()->getTotalIncludingVat(), \PDO::PARAM_STR); $stmt->bindValue(':priceCurrency', $entry->getPrice()->getCurrency(), \PDO::PARAM_STR); $stmt->bindValue(':ticksA', $entry->getTicksA(), \PDO::PARAM_INT); $stmt->bindValue(':ticksB', $entry->getTicksB(), \PDO::PARAM_INT); $stmt->bindValue(':unitsCharged', $entry->getUnitsCharged(), \PDO::PARAM_INT); $stmt->bindValue(':tariffName', $entry->getTariffName(), \PDO::PARAM_STR); $stmt->bindValue(':duration', $entry->getDuration(), \PDO::PARAM_INT); $stmt->bindValue(':tos', $entry->getTypeOfService(), \PDO::PARAM_STR); $stmt->execute(); return $stmt->rowCount(); } catch (DbException $e) { $this->logger->error('Error inserting into database: %s', $e->getMessage()); } }