示例#1
0
        public static void Run()
        {
            var          fileId           = "QmF0Y2hGaWxlc0RldGFpbFJlcG9ydC5jc3YtMjAyMC0wMS0zMA==";
            const string fileName         = "DownloadedFileWithFileID.csv";
            const string downloadFilePath = @".\Resource\" + fileName;
            string       organizationId   = "testrest";

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);

                var apiInstance = new SecureFileShareApi(clientConfig);
                var content     = apiInstance.GetFileWithHttpInfo(fileId, organizationId);

                // START : FILE DOWNLOAD FUNCTIONALITY
                File.WriteAllText(downloadFilePath, CreateXml(content.Data));

                Console.WriteLine("\nFile Downloaded at the following location : ");
                Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n");
                // END : FILE DOWNLOAD FUNCTIONALITY
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File Not Found : Kindly verify the path.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
            }
        }
        public static void Run()
        {
            try
            {
                // File will be created with the Data received in the Response Body

                // Provide the File Name
                const string fileName = "DownloadFileWithFileIdentifier.csv";

                // Provide the path where the file needs to be downloaded
                // This can be either a relative path or an absolute path
                const string downloadFilePath = @".\Resource\" + fileName;

                var fileId         = "VFJSUmVwb3J0LTc4NTVkMTNmLTkzOTgtNTExMy1lMDUzLWEyNTg4ZTBhNzE5Mi5jc3YtMjAxOC0xMC0yMA==";
                var organizationId = "testrest";

                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
                var apiInstance      = new SecureFileShareApi(clientConfig);

                var result = apiInstance.GetFileWithHttpInfo(fileId, organizationId);
                Console.WriteLine(result);
                File.WriteAllText(downloadFilePath, CreateXml(result.Data));
                Console.WriteLine("\nFile downloaded at the below location:");
                Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File Not Found: Kindly verify the path");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }
        }
        public static void Run()
        {
            try
            {
                // File will be created with the Data received in the Response Body

                // Provide the File Name
                const string fileName = "DownloadFileWithFileIdentifier.csv";

                // Provide the path where the file needs to be downloaded
                // This can be either a relative path or an absolute path
                const string downloadFilePath = @".\Resource\" + fileName;

                var fileId         = "dGVzdHJlc3Rfc3ViY3JpcHRpb25fdjI5ODktYTM3ZmI2ZjUtM2QzYi0wOGVhLWUwNTMtYTI1ODhlMGFkOTJjLnhtbC0yMDIwLTA0LTMw";
                var organizationId = "testrest";

                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);
                var apiInstance      = new SecureFileShareApi(clientConfig);

                var content = apiInstance.GetFileWithHttpInfo(fileId, organizationId);

                File.WriteAllText(downloadFilePath, CreateXml(content.Data));

                Console.WriteLine("\nFile downloaded at the below location:");
                Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File Not Found: Kindly verify the path");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API: " + e.Message);
            }
        }