/**
  * @param int $leagueId
  * @param int $year
  * @return array
  *
  * @todo based upon the year and league, return the total number of weeks
  */
 public function getWeeksForLeague($leagueId, $year, $forSelect = false)
 {
     $output = [];
     $this->buildUrl(self::$content);
     $this->gateway->addParam('command', 'getweekrangeforyear');
     $this->gateway->addParam('accountId', Session::getAccountId());
     $this->gateway->addParam('leagueId', $leagueId);
     $this->gateway->addParam('year', $year);
     $result = $this->gateway->request();
     if (ApiResult::success() == $result->result) {
         if ($forSelect) {
             $range = range($result->data[0]->maxWeek, $result->data[0]->minWeek);
             foreach ($range as $week) {
                 $output[$week] = $week;
             }
         } else {
             $output = $result->data;
         }
     }
     return $output;
 }
 /**
  * @param string $url
  * @return ApiResultDto
  *
  * @todo allow for different return types
  * @todo use curl and post once the service actually requires authorization
  */
 public function request($url = null)
 {
     /**
      * @var ApiResultDto $response
      */
     if (is_null($url)) {
         $url = $this->getUrl();
     }
     $output = null;
     $curl = curl_init();
     //echo(__FILE__ . '(' . __LINE__ . ') $url: <pre>' . print_r($url, true)) . '</pre>';
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_POST, 1);
     curl_setopt($curl, CURLOPT_HEADER, false);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $this->getParams());
     $result = curl_exec($curl);
     curl_close($curl);
     //die(__FILE__ . '(' . __LINE__ . ') $result: <pre>' . print_r($result, true)) . '</pre>';
     if ($response = json_decode($result)) {
         $output = new ApiResultDto();
         $output->data = $response->data;
         $output->result = ApiResult::getFromValue($response->result);
         $output->msg = $response->msg;
         $output->version = $response->version;
     }
     return $output;
 }