Beispiel #1
0
        /// <summary>
        /// Fetches data from the FRED series/observations service endpoint and saves the result to a ZIP file.
        /// </summary>
        /// <param name="filePath">The file path at which to save the ZIP file.</param>
        /// <param name="overwrite">Indicates whether or not to overwrite the contents of an existing ZIP file. The default is true.</param>
        /// <returns>A boolean indicating whether or not the operation succeeded.</returns>
        public bool Fetch(string filePath, bool overwrite = true)
        {
            try
            {
                if (!overwrite && File.Exists(filePath))
                {
                    Exception = new Exception("File " + filePath + " already exists.");
                    return(false);
                }

                var request = new FileRequest {
                    FilePath = filePath, Excel = Excel
                };
                request.Fetch(Arguments);
                SetResultProperties();
                return(Exception == null);
            }
            catch (Exception exception)
            {
                Exception = exception;
            }
            return(false);
        }