Esempio n. 1
0
 /**
  * Builds a ticket from API response
  *
  * @param array $data The data from API
  *
  * @return Ticket
  */
 public static function buildTicket(array $data)
 {
     $ticket = new Ticket();
     $captcha = CaptchaBuilder::buildCaptcha($data['captcha_url'], $data['captcha_w'], $data['captcha_h']);
     $ticket->setCode($data['ticket'])->setCaptcha($captcha)->setWaitTime($data['wait_time'])->setExpirationDate(static::buildDate($data['valid_until']));
     return $ticket;
 }
Esempio n. 2
0
 /**
  * Returns the download link
  *
  * @param Ticket $ticket          The ticket previously generated
  * @param string $captchaResponse The captcha response
  *
  * @return DownloadLink
  */
 public function getDownloadLink(Ticket $ticket, $captchaResponse = null)
 {
     $params = ['file' => $ticket->getFileId(), 'ticket' => $ticket->getCode()];
     if ($captchaResponse) {
         $params['captcha_response'] = $captchaResponse;
     }
     $response = $this->processRequest('file/dl', $params);
     $result = $this->processResponse($response);
     return LinkBuilder::buildDownloadLink($result);
 }