Пример #1
0
 /**
  * @param $itemsPerPage
  * @param $pageNumber
  * @return FileDetail[]
  */
 public function getFiles($itemsPerPage = -1, $pageNumber = -1)
 {
     APIWrapper::verifyReadiness();
     $files = array();
     $requestURL = "https://app.fetchapp.com/api/v2/files.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->file as $file) {
             $tempFile = new FileDetail();
             $tempFile->setFileID($file->id);
             $tempFile->setFileName($file->filename);
             $tempFile->setSizeInBytes($file->size_bytes);
             $tempFile->setContentType($file->content_type);
             $tempFile->setPermalink($file->permalink);
             $tempFile->setUrl($file->url);
             $tempFile->setType($file->type);
             $files[] = $tempFile;
         }
     }
     return $files;
 }
Пример #2
0
 /**
  * @return FileDetail[] $downloads
  */
 public function getFiles()
 {
     APIWrapper::verifyReadiness();
     $requestURL = "https://app.fetchapp.com/api/v2/products/" . $this->ProductID . "/files";
     $files = array();
     $results = APIWrapper::makeRequest($requestURL, "GET");
     foreach ($results->file as $file) {
         $tempFile = new FileDetail();
         $tempFile->setFileID($file->id);
         $tempFile->setFileName($file->filename);
         $tempFile->setSizeInBytes($file->size_bytes);
         $tempFile->setContentType($file->content_type);
         $tempFile->setPermalink($file->permalink);
         $tempFile->setURL($file->url);
         $files[] = $tempFile;
     }
     return $files;
 }