예제 #1
0
 /**
  * Formats the uri for a Request object.
  *
  * Parts of the uri that start with an
  * ":" are the parameters of the uri. This method initiates the formatting process
  * for such an uri by getting the parameters first, and with the name of a parameter,
  * i'ts value can be retrieved. The value is either stored inside a public property of
  * the request object. Or it can be retrieved by a getter.
  * It also add the query parameters add the end of the URI
  * @param AbstractRequest $request
  * @return string
  */
 public static function format(AbstractRequest $request)
 {
     $builder = new static($request);
     $parts = $builder->getParametersInUri();
     $values = $builder->getValuesFromUriParameters($parts);
     $uri = $builder->formatUri($values);
     if (!$request->getQueryParams()->isEmpty()) {
         $uri .= '?' . http_build_query($request->getQueryParams()->toArray());
     }
     return $uri;
 }
예제 #2
0
 /**
  * Update a user setting
  *
  * @param Token $token Access token
  * @param string $name Setting name
  * @param string $value Possible values are available in /settings
  */
 public function __construct(Token $token, $name, $value)
 {
     parent::__construct();
     $this->setToken($token);
     $this->addToBody('setting_name', $name);
     $this->addToBody('setting_value', $value);
 }
 /**
  * Select files of a torrent to start it
  *
  * Warning: To get file IDs, use /torrents/info/{id}
  * @param Token $token Access token
  * @param string $id Torrent ID
  * @param array $files Array of selected files IDs
  */
 public function __construct(Token $token, $id, array $files)
 {
     parent::__construct();
     $this->setToken($token);
     $this->id = $id;
     $this->addToBody('files', count($files) > 0 ? implode(',', $files) : 'all');
 }
예제 #4
0
 /**
  * Check if a file is downloadable on the concerned hoster
  *
  * @param string $link The original hoster link
  * @param string|null $password Password to unlock the file access hoster side
  */
 public function __construct($link, $password = null)
 {
     parent::__construct();
     $this->addToBody('link', $link);
     if (!empty($password)) {
         $this->addToBody('password', $password);
     }
 }
예제 #5
0
 /**
  * Get traffic details on each hoster used during a defined period
  *
  * @param Token $token Access token
  * @param Carbon $start Start period, default: a week ago
  * @param Carbon $end End period, default: today
  */
 public function __construct(Token $token, Carbon $start = null, Carbon $end = null)
 {
     parent::__construct();
     $this->setToken($token);
     if (!is_null($start)) {
         $this->addQueryParam('start', $start->format('Y-m-d'));
     }
     if (!is_null($end)) {
         $this->addQueryParam('end', $start->format('Y-m-d'));
     }
 }
예제 #6
0
 /**
  * Add a magnet link to download
  *
  * The files must be selected with the selectFiles method to start the torrent
  * @param Token $token Access token
  * @param string $magnet Magnet link
  * @param int|null $host Hoster domain (retrieved from /torrents/availableHosts)
  * @param int|null $split Split size (under max_split_size of concerned hoster retrieved from /torrents/availableHosts)
  */
 public function __construct(Token $token, $magnet, $host = null, $split = null)
 {
     parent::__construct();
     $this->setToken($token);
     $this->addToBody('magnet', $magnet);
     if (!empty($host)) {
         $this->addToBody('host', $host);
     }
     if (!empty($host) && !empty($split)) {
         $this->addToBody('split', $split);
     }
 }
예제 #7
0
 /**
  * Unrestrict a hoster link and get a new unrestricted link
  *
  * @param Token $token Access token
  * @param string $link The original hoster link
  * @param string|null $password Password to unlock the file access hoster side
  * @param string|null $remote Use Remote traffic, dedicated servers and account sharing protections lifted
  */
 public function __construct(Token $token, $link, $password = null, $remote = null)
 {
     parent::__construct();
     $this->setToken($token);
     $this->addToBody('link', $link);
     if (!empty($password)) {
         $this->addToBody('password', $password);
     }
     if (!empty($remote)) {
         $this->addToBody('remote', $remote);
     }
 }
예제 #8
0
 /**
  * Get user downloads list
  *
  * Warning: You can not use both offset and page at the same time, page is prioritized in case it happens.
  * @param Token $token Access token
  * @param int $page Pagination system
  * @param int $limit Entries returned per page / request (must be within 0 and 100, default: 50)
  * @param int $offset Starting offset (must be within 0 and X-Total-Count HTTP header)
  */
 public function __construct(Token $token, $page, $limit, $offset)
 {
     parent::__construct();
     $this->setToken($token);
     if (!is_null($page)) {
         $this->addQueryParam('page', $page);
     }
     $this->addQueryParam('limit', $limit);
     if (!is_null($offset) && is_null($page)) {
         $this->addQueryParam('offset', $offset);
     }
 }
예제 #9
0
 /**
  * Upload a new user avatar image
  *
  * @param Token $token Access token
  * @param string $path File to the avatar file
  */
 public function __construct(Token $token, $path)
 {
     parent::__construct();
     $this->setToken($token);
     $this->setFilePath($path);
 }
 /**
  * Get available hosts to upload the torrent to
  *
  * @param Token $token Access token
  */
 public function __construct(Token $token)
 {
     parent::__construct();
     $this->setToken($token);
 }
예제 #11
0
 /**
  * Unrestrict a hoster folder link and get individual links
  *
  * @param Token $token Access token
  * @param string $link The hoster folder link
  */
 public function __construct(Token $token, $link)
 {
     parent::__construct();
     $this->setToken($token);
     $this->addToBody('link', $link);
 }
예제 #12
0
 /**
  * Requests the abstract request.
  *
  * @param AbstractRequest $request
  * @param ResponseHandler $responseHandler
  * @return mixed|null The handled response
  * @throws \RealDebrid\Exception\BadTokenException
  * @throws \RealDebrid\Exception\PermissionDeniedException
  * @throws \RealDebrid\Exception\RealDebridException
  * @throws \RealDebrid\Exception\UnknownResourceException
  */
 protected function request(AbstractRequest $request, ResponseHandler $responseHandler = null)
 {
     return $request->make($this->client, $responseHandler);
 }
예제 #13
0
 /**
  * Get supported hosts
  */
 public function __construct()
 {
     parent::__construct();
 }