Oara\Network\Publisher\SkyParkSecure::getTransactionList PHP Method

getTransactionList() public method

public getTransactionList ( null $merchantList = null, DateTime $dStartDate = null, DateTime $dEndDate = null ) : array
$merchantList null
$dStartDate DateTime
$dEndDate DateTime
return array
    public function getTransactionList($merchantList = null, \DateTime $dStartDate = null, \DateTime $dEndDate = null)
    {
        $totalTransactions = array();
        $today = new \DateTime();
        $today->setTime(0, 0);
        $urls = array();
        $exportParams = array(new \Oara\Curl\Parameter('data[query][agent]', $this->_agent), new \Oara\Curl\Parameter('data[query][date1]', $dStartDate->format("Y-m-d")), new \Oara\Curl\Parameter('data[query][date2]', $dEndDate->format("Y-m-d")), new \Oara\Curl\Parameter('data[query][api_key]', $this->_apiKey));
        $urls[] = new \Oara\Curl\Request('http://www.skyparksecure.com/api/v4/jsonp/getSales?', $exportParams);
        $exportReport = $this->_client->get($urls);
        $report = \substr($exportReport[0], 1, \strlen($exportReport[0]) - 3);
        $exportData = \json_decode($report);
        foreach ($exportData->result as $booking) {
            $transaction = array();
            $transaction['merchantId'] = 1;
            $transaction['unique_id'] = $booking->booking_ref;
            $transaction['metadata'] = $booking->product_name;
            $transaction['custom_id'] = $booking->custom_id;
            $pickupDate = new \DateTime($booking->dateA);
            $transaction['date'] = $booking->booking_date;
            $transaction['metadata'] = $booking->product_id;
            if ($booking->booking_mode == "Booked" || $booking->booking_mode == "Amended") {
                $transaction['status'] = \Oara\Utilities::STATUS_PENDING;
                if ($today > $pickupDate) {
                    $transaction['status'] = \Oara\Utilities::STATUS_CONFIRMED;
                }
            } else {
                if ($booking->booking_mode == "Cancelled") {
                    $transaction['status'] = \Oara\Utilities::STATUS_DECLINED;
                } else {
                    throw new \Exception("New status found");
                }
            }
            $transaction['amount'] = \Oara\Utilities::parseDouble($booking->sale_price) / 1.2;
            $transaction['commission'] = \Oara\Utilities::parseDouble($booking->commission_affiliate) / 1.2;
            $totalTransactions[] = $transaction;
        }
        return $totalTransactions;
    }