/** * @return bool True on success, otherwise False. */ public function getNewToken() { APIWrapper::verifyReadiness(); $success = false; $result = APIWrapper::makeRequest("https://app.fetchapp.com/api/v2/new_token", "GET"); $this->setAuthenticationToken($result[0]); $success = true; return $success; }
/** * @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; }
/** * @return OrderItem[] $items */ public function getItems() { APIWrapper::verifyReadiness(); $requestURL = "https://app.fetchapp.com/api/v2/orders/" . $this->OrderID . "/order_items"; $results = APIWrapper::makeRequest($requestURL, "GET"); $items = array(); foreach ($results->order_item as $item) { $i = new OrderItem(); $i->setItemID((string) $item->id); $i->setSKU((string) $item->sku); $i->setOrderID((string) $item->order_id); $i->setProductName((string) $item->product_name); $i->setPrice((double) $item->price); $i->setDownloadCount((int) $item->download_count); if (!isset($item->custom_1['nil'])) { $i->setCustom1($item->custom_1); } else { $i->setCustom1(null); } if (!isset($item->custom_2['nil'])) { $i->setCustom2($item->custom_2); } else { $i->setCustom2(null); } if (!isset($item->custom_3['nil'])) { $i->setCustom3($item->custom_3); } else { $i->setCustom3(null); } if (!isset($item->license_key['nil'])) { $i->setLicenseKey((string) $item->license_key); } else { $i->setLicenseKey(null); } $i->setCreationDate(new \DateTime($item->created_at)); // $i->setDownloadsRemaining(0); // We don't seem to be getting this back. $items[] = $i; } return $items; }
/** * @return mixed */ public function expire() { APIWrapper::verifyReadiness(); $requestURL = "https://app.fetchapp.com/api/v2/order_items/" . $this->ItemID . "/expire"; $response = APIWrapper::makeRequest($requestURL, "GET"); return $response; }