private function download($fromDate = null, $toDate = null) {
        //use test data if running as test
        if ($this->runastest) {
            $response = file_get_contents(dirname(__FILE__). '/../../tests/currencyLayerTestData.json');
        }
        else {
            $base = 'USD';

            if ($this->settings['use-ssl']) {
                $url = 'https';
            } else {
                $url = 'http';
            }

            if (!empty($fromDate) and !empty($toDate)) {
                $url .= '://apilayer.net/api/timeframe?access_key='.$this->settings['currencylayer-access-key'].'&source='.$base.'&start_date='.$fromDate.'&end_date='.$toDate;
                }
            else if (!empty($fromDate)) {
                $url .= '://apilayer.net/api/historical?access_key=' . $this->settings['currencylayer-access-key'] . '&date=' . $fromDate . '&source=' . $base;

            } else {
                $url .= '://apilayer.net/api/live?access_key=' . $this->settings['currencylayer-access-key'] . '&source=' . $base;
            }
            $this->url = $url;
            $response = $this->connect($url);
        }

        return $response;
    }