/** * @param $itemsPerPage * @param $pageNumber * @return OrderDownload[] */ public function getDownloads($itemsPerPage = -1, $pageNumber = -1) { APIWrapper::verifyReadiness(); $downloads = array(); $requestURL = "https://app.fetchapp.com/api/v2/downloads.xml?"; if ($itemsPerPage != -1) { $requestURL .= "per_page=" . $itemsPerPage; } if ($pageNumber != -1) { $requestURL .= $itemsPerPage != -1 ? "&" : ""; $requestURL .= "page=" . $pageNumber; } $requestURL = rtrim($requestURL, '?'); $results = APIWrapper::makeRequest($requestURL, "GET"); if (is_a($results, "SimpleXMLElement")) { foreach ($results->download as $download) { $tempDownload = new OrderDownload(); $tempDownload->setDownloadID($download->id); $tempDownload->setFileName($download->filename); $tempDownload->setSKU($download->product_sku); $tempDownload->setOrderID($download->order_id); $tempDownload->setIPAddress($download->ip_address); $tempDownload->setDownloadedOn(new \DateTime($download->downloaded_at)); $tempDownload->setSizeInBytes($download->size_bytes); $downloads[] = $tempDownload; } } return $downloads; }
/** * @return OrderDownload[] $downloads */ public function getDownloads() { APIWrapper::verifyReadiness(); $requestURL = "https://app.fetchapp.com/api/v2/orders/" . $this->OrderID . "/downloads"; $downloads = array(); $results = APIWrapper::makeRequest($requestURL, "GET"); foreach ($results->download as $d) { $download = new OrderDownload(); $download->setDownloadID((string) $d->id); $download->setFileName((string) $d->filename); $download->setSKU((string) $d->product_sku); $download->setOrderID((string) $d->order_id); $download->setOrderItemID((string) $d->order_item_id); $download->setIPAddress((string) $d->ip_address); $download->setDownloadedOn(new \DateTime($d->downloaded_at)); $download->setSizeInBytes((int) $d->size_bytes); $downloads[] = $download; } return $downloads; }