/** * GetSales() cleans up the result of the raw SOAP call. PHP::SOAP does some wierd things that * make parsing difficult; mainly single results vs. multiple results are handled differently. * This function takes the raw result and cleans it up, returning an array of Client objects, * with all their fields initialized * @param int $saleID The exact sale ID * @param DateTime $saleStartDate The start date to retrieve sales * @param DateTime $saleEndDate The end date to retrieve sales * @param int $paymentMethodID The ID of the payment method that must have been used on the sales. * @param SourceCredentials $credentials A source credentials object to use with this call * @param string $XMLDetail * @param int $PageSize * @param int $CurrentPage * @param string $Fields * @return An array of Sale objects that match the current filter settings */ public function GetSales($saleID, $saleStartDate, $saleEndDate, $paymentMethodID, SourceCredentials $credentials = null, $XMLDetail = XMLDetail::Full, $PageSize = NULL, $CurrentPage = NULL, $Fields = NULL) { $result = $this->GetSalesRaw($saleID, $saleStartDate, $saleEndDate, $paymentMethodID, $credentials, $XMLDetail, $PageSize, $CurrentPage, $Fields); $properties = get_object_vars($result->GetSalesResult->Sales); if (empty($properties)) { $return = array(); } else { if (is_array($result->GetSalesResult->Sales->Sale)) { // Multiple results returned foreach ($result->GetSalesResult->Sales->Sale as $sale) { $return[] = Sale::ConvertFromstdClass($sale); } } else { // Only a single result $return[] = Sale::ConvertFromstdClass($result->GetSalesResult->Sales->Sale); } } if ($this->debug) { echo '<h2>GetSales Result</h2><pre>'; print_r($return); echo "</pre>"; } return $return; }