diff --git a/src/Api.cs b/src/Api.cs index 87e16c3..fddca8d 100644 --- a/src/Api.cs +++ b/src/Api.cs @@ -3,8 +3,7 @@ public class Api { public string ApiFamily { get; set; } - public string ApiFunctionCall { get; set; } - } - + public string ApiFunctionCall { get; set; } + } } \ No newline at end of file diff --git a/src/SampleCode.cs b/src/SampleCode.cs index 2371de6..0d5b4e9 100644 --- a/src/SampleCode.cs +++ b/src/SampleCode.cs @@ -34,8 +34,6 @@ public static void Main(string[] args) // initializing logger object // LogManager.DisableLogging(); logger = LogManager.GetCurrentClassLogger(); - logger.Trace("\n"); - logger.Trace("PROGRAM EXECUTION BEGINS"); // Set Network Settings (To Avoid SSL/TLS Secure Channel Error) SetNetworkSettings(); @@ -56,8 +54,6 @@ public static void Main(string[] args) // Run the Sample Code as per user input RunSample(); - - logger.Trace("PROGRAM EXECUTION ENDS"); } public static void RunSample(string cmdLineArg = null) @@ -65,7 +61,6 @@ public static void RunSample(string cmdLineArg = null) try { _sampleToRun = string.IsNullOrEmpty(cmdLineArg) ? Console.ReadLine() : cmdLineArg; - logger.Trace($"Input provided for Sample Code to Run: {_sampleToRun}"); Console.WriteLine("\n"); Type className = null; @@ -76,16 +71,21 @@ public static void RunSample(string cmdLineArg = null) if (className != null) { - logger.Trace($"Sample Code found in the namespace: {path}"); break; } } + // Sample Code not found in the project files if (className == null) { logger.Warn("No Sample Code Found with the name: {0}", _sampleToRun); Console.WriteLine("No Sample Code Found with the name: {0}", _sampleToRun); + // Holding the full display of sample codes to show the response of current action + Console.WriteLine("Press any key to continue..."); + Console.ReadLine(); + + // Running the App from visual studio or from command line without passing any args if (cmdLineArg == null) { ShowMethods(); @@ -93,14 +93,13 @@ public static void RunSample(string cmdLineArg = null) } return; - } + // Sample Code is found in the project files, invoking it... var obj = Activator.CreateInstance(className); var methodInfo = className.GetMethod("Run"); if (methodInfo != null) { - logger.Trace($"Invoking Run() method of {_sampleToRun}"); methodInfo.Invoke(obj, null); } else @@ -108,6 +107,11 @@ public static void RunSample(string cmdLineArg = null) logger.Warn($"No Run Method Found in the class: {_sampleToRun}"); Console.WriteLine("No Run Method Found in the class: {0}", _sampleToRun); + // Holding the full display of sample codes to show the response of current action + Console.WriteLine("Press any key to continue..."); + Console.ReadLine(); + + // Running the App from visual studio or from command line without passing any args if (cmdLineArg == null) { ShowMethods(); @@ -130,6 +134,12 @@ public static void RunSample(string cmdLineArg = null) Console.WriteLine(e.StackTrace); } + // Holding the full display of sample codes to show the response of current action + Console.WriteLine("Press any key to continue..."); + Console.ReadLine(); + + // Previous Sample Code executed successfully. Displaying the sample codes again for the next run + // Running the App from visual studio or from command line without passing any args if (cmdLineArg == null) { ShowMethods(); @@ -139,8 +149,6 @@ public static void RunSample(string cmdLineArg = null) private static void ShowMethods() { - logger.Trace("Beginning to Show All Sample Codes on Console"); - Console.WriteLine(" ---------------------------------------------------------------------------------------------------"); Console.WriteLine(" - Code Sample Names -"); Console.WriteLine(" ---------------------------------------------------------------------------------------------------"); @@ -154,8 +162,6 @@ private static void ShowMethods() foreach (var apiFamily in apiFamilies) { - logger.Trace($"Showing Sample Codes for Api Family: {apiFamily}"); - Console.WriteLine(" " + apiFamily.ToUpper() + " API'S "); Console.WriteLine(" ---------------------------------------------------------------------------------------------------"); @@ -183,7 +189,6 @@ private static void ShowMethods() Console.WriteLine(" ---------------------------------------------------------------------------------------------------"); } - logger.Trace("All Sample Codes Shown on Console"); Console.WriteLine(string.Empty); Console.Write("Type a sample name & then press : "); } @@ -202,8 +207,6 @@ 4. Add the Api Object to the ApiList List. */ // 1. Find the Api Families (Folders inside the main 'Samples' Folder) - logger.Trace($"Samples Folder At:{Path.GetFullPath(PathOfSamplesFolder)}"); - var dirList = Directory.GetDirectories(PathOfSamplesFolder, "*"); var apiFamilies = new List(); @@ -221,9 +224,6 @@ 4. Add the Api Object to the ApiList List. // 2.Fetch all the Files Paths inside Api Family folder (and all of its subfoldes) var allfiles = Directory.GetFileSystemEntries(PathOfSamplesFolder + @"\" + apiFamily, "*.cs*", SearchOption.AllDirectories); - logger.Trace($"Api Family: {apiFamily}"); - logger.Trace($"Total Sample Codes Detected: {allfiles.Count()}"); - foreach (var file in allfiles) { var lastBackSlashIndex = file.LastIndexOf(@"\", StringComparison.Ordinal); @@ -275,7 +275,6 @@ private static void InitializeSampleClassesPathList() { // dirList has got all the folders and sub-folders for the Samples Folder Path var dirList = Directory.GetDirectories(PathOfSamplesFolder, "*", SearchOption.AllDirectories); - logger.Trace($"Project Namespace value provided: {ProjectNamespace}"); foreach (var dir in dirList) { diff --git a/src/SampleCode.csproj b/src/SampleCode.csproj index e7afb68..ad4e1ea 100644 --- a/src/SampleCode.csproj +++ b/src/SampleCode.csproj @@ -154,4 +154,4 @@ --> - + \ No newline at end of file diff --git a/src/Samples/Flex/CoreServices/GenerateKey.cs b/src/Samples/Flex/CoreServices/GenerateKey.cs index fbf19af..75de807 100644 --- a/src/Samples/Flex/CoreServices/GenerateKey.cs +++ b/src/Samples/Flex/CoreServices/GenerateKey.cs @@ -8,23 +8,69 @@ public class GenerateKey { public static FlexV1KeysPost200Response Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GenerateKey)}"); + + CyberSource.Client.Configuration clientConfig = null; + FlexV1KeysPost200Response result = null; + var requestObj = new GeneratePublicKeyRequest("None"); try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new KeyGenerationApi(clientConfig); - var result = apiInstance.GeneratePublicKey(requestObj); - Console.WriteLine(result); + result = apiInstance.GeneratePublicKey(requestObj); return result; } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GenerateKey)}):{e.Message}"); return null; } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GenerateKey)}"); + } + } } } -} +} \ No newline at end of file diff --git a/src/Samples/Flex/CoreServices/TokenizeCard.cs b/src/Samples/Flex/CoreServices/TokenizeCard.cs index 71f4d72..637df1d 100644 --- a/src/Samples/Flex/CoreServices/TokenizeCard.cs +++ b/src/Samples/Flex/CoreServices/TokenizeCard.cs @@ -14,6 +14,12 @@ public class TokenizeCard { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(TokenizeCard)}"); + + CyberSource.Client.Configuration clientConfig = null; + FlexV1TokensPost200Response result = null; + bool tokenVerificationResult = false; + var generateKeyResult = GenerateKey.Run(); var keyId = generateKeyResult.KeyId; var derFormat = generateKeyResult.Der.Format; @@ -35,11 +41,10 @@ public static void Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new FlexTokenApi(clientConfig); - var result = apiInstance.Tokenize(requestObj); - Console.WriteLine(result); + result = apiInstance.Tokenize(requestObj); var flexPublicKey = new FlexPublicKey(keyId, new FlexServerSDK.Model.DerPublicKey(derFormat, derAlgo, derPublicKey), null); var flexToken = new FlexToken() @@ -63,12 +68,53 @@ public static void Run() postParameters["token"] = flexToken.token; postParameters["timestamp"] = Convert.ToString(flexToken.timestamp); - var tokenVerificationResult = Verify(flexPublicKey, postParameters); - Console.WriteLine(tokenVerificationResult); + tokenVerificationResult = Verify(flexPublicKey, postParameters); } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(TokenizeCard)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(TokenizeCard)}"); + } } } diff --git a/src/Samples/Payments/CoreServices/CapturePayment.cs b/src/Samples/Payments/CoreServices/CapturePayment.cs index 552030b..0c3b25e 100644 --- a/src/Samples/Payments/CoreServices/CapturePayment.cs +++ b/src/Samples/Payments/CoreServices/CapturePayment.cs @@ -8,8 +8,13 @@ public class CapturePayment { public static PtsV2PaymentsCapturesPost201Response Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(CapturePayment)}"); + var processPaymentId = ProcessPayment.Run().Id; + CyberSource.Client.Configuration clientConfig = null; + PtsV2PaymentsCapturesPost201Response result = null; + var requestObj = new CapturePaymentRequest(); var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation @@ -57,18 +62,60 @@ public static PtsV2PaymentsCapturesPost201Response Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new CaptureApi(clientConfig); - var result = apiInstance.CapturePayment(requestObj, processPaymentId); - Console.WriteLine(result); + result = apiInstance.CapturePayment(requestObj, processPaymentId); + return result; } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(CapturePayment)}):{e.Message}"); return null; } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(CapturePayment)}"); + } + } } } } diff --git a/src/Samples/Payments/CoreServices/ProcessAuthorizationReversal.cs b/src/Samples/Payments/CoreServices/ProcessAuthorizationReversal.cs index 6751b02..567f3d1 100644 --- a/src/Samples/Payments/CoreServices/ProcessAuthorizationReversal.cs +++ b/src/Samples/Payments/CoreServices/ProcessAuthorizationReversal.cs @@ -9,29 +9,76 @@ public class ProcessAuthorizationReversal { public static PtsV2PaymentsReversalsPost201Response Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(ProcessAuthorizationReversal)}"); + var processPaymentId = ProcessPayment.Run().Id; + CyberSource.Client.Configuration clientConfig = null; + PtsV2PaymentsReversalsPost201Response result = null; + var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_reversal"); var amount = new Ptsv2paymentsidreversalsOrderInformationLineItems(null, "102.21"); var amountDetailsObj = new List { amount }; var orderInformationObj = new Ptsv2paymentsidreversalsOrderInformation(amountDetailsObj); - var requestBody = new AuthReversalRequest(clientReferenceInformationObj, null, null, orderInformationObj); + var requestObj = new AuthReversalRequest(clientReferenceInformationObj, null, null, orderInformationObj); try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReversalApi(clientConfig); - var result = apiInstance.AuthReversal(processPaymentId, requestBody); - Console.WriteLine(result); + result = apiInstance.AuthReversal(processPaymentId, requestObj); + return result; } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(ProcessAuthorizationReversal)}):{e.Message}"); return null; } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(ProcessAuthorizationReversal)}"); + } + } } } } diff --git a/src/Samples/Payments/CoreServices/ProcessCredit.cs b/src/Samples/Payments/CoreServices/ProcessCredit.cs index a054e9f..413a1e8 100644 --- a/src/Samples/Payments/CoreServices/ProcessCredit.cs +++ b/src/Samples/Payments/CoreServices/ProcessCredit.cs @@ -8,6 +8,11 @@ public class ProcessCredit { public static PtsV2CreditsPost201Response Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(ProcessCredit)}"); + + CyberSource.Client.Configuration clientConfig = null; + PtsV2CreditsPost201Response result = null; + var requestObj = new CreateCreditRequest(); var v2PaymentsClientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation @@ -61,18 +66,60 @@ public static PtsV2CreditsPost201Response Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new CreditApi(clientConfig); - var result = apiInstance.CreateCredit(requestObj); - Console.WriteLine(result); + result = apiInstance.CreateCredit(requestObj); + return result; } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(ProcessCredit)}):{e.Message}"); return null; } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(ProcessCredit)}"); + } + } } } -} +} \ No newline at end of file diff --git a/src/Samples/Payments/CoreServices/ProcessPayment.cs b/src/Samples/Payments/CoreServices/ProcessPayment.cs index 8a462ac..353f634 100644 --- a/src/Samples/Payments/CoreServices/ProcessPayment.cs +++ b/src/Samples/Payments/CoreServices/ProcessPayment.cs @@ -10,6 +10,11 @@ public class ProcessPayment public static PtsV2PaymentsPost201Response Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(ProcessPayment)}"); + + CyberSource.Client.Configuration clientConfig = null; + PtsV2PaymentsPost201Response result = null; + var processingInformationObj = new Ptsv2paymentsProcessingInformation() { CommerceIndicator = "internet" }; var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation { Code = "test_payment" }; @@ -74,18 +79,60 @@ public static PtsV2PaymentsPost201Response Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentsApi(clientConfig); - var result = apiInstance.CreatePayment(requestObj); - Console.WriteLine(result); + result = apiInstance.CreatePayment(requestObj); + return result; } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(ProcessPayment)}):{e.Message}"); return null; } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(ProcessPayment)}"); + } + } } } -} +} \ No newline at end of file diff --git a/src/Samples/Payments/CoreServices/RefundCapture.cs b/src/Samples/Payments/CoreServices/RefundCapture.cs index 5fdb171..b5b6544 100644 --- a/src/Samples/Payments/CoreServices/RefundCapture.cs +++ b/src/Samples/Payments/CoreServices/RefundCapture.cs @@ -8,26 +8,73 @@ public class RefundCapture { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(RefundCapture)}"); + var capturePaymentId = CapturePayment.Run().Id; + CyberSource.Client.Configuration clientConfig = null; + PtsV2PaymentsRefundPost201Response result = null; + var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation("test_refund_capture"); var amountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails("102.21", "USD"); var orderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(amountDetailsObj); - var requestBody = new RefundCaptureRequest(clientReferenceInformationObj,null, null, orderInformationObj); + var requestObj = new RefundCaptureRequest(clientReferenceInformationObj, null, null, orderInformationObj); try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new RefundApi(clientConfig); - var result = apiInstance.RefundCapture(requestBody, capturePaymentId); - Console.WriteLine(result); + result = apiInstance.RefundCapture(requestObj, capturePaymentId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(RefundCapture)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(RefundCapture)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Payments/CoreServices/RefundPayment.cs b/src/Samples/Payments/CoreServices/RefundPayment.cs index 6031c80..e622f5b 100644 --- a/src/Samples/Payments/CoreServices/RefundPayment.cs +++ b/src/Samples/Payments/CoreServices/RefundPayment.cs @@ -8,29 +8,76 @@ public class RefundPayment { public static PtsV2PaymentsRefundPost201Response Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(RefundPayment)}"); + ProcessPayment.CaptureTrueForProcessPayment = true; var processPaymentId = ProcessPayment.Run().Id; + CyberSource.Client.Configuration clientConfig = null; + PtsV2PaymentsRefundPost201Response result = null; + var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation("test_refund_payment"); var amountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails("10", "USD"); var orderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(amountDetailsObj); - var requestBody = new RefundPaymentRequest(clientReferenceInformationObj, null, null, orderInformationObj); + var requestObj = new RefundPaymentRequest(clientReferenceInformationObj, null, null, orderInformationObj); try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new RefundApi(clientConfig); - var result = apiInstance.RefundPayment(requestBody, processPaymentId); - Console.WriteLine(result); + result = apiInstance.RefundPayment(requestObj, processPaymentId); + return result; } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(RefundPayment)}):{e.Message}"); return null; } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(RefundPayment)}"); + } + } } } } \ No newline at end of file diff --git a/src/Samples/Payments/CoreServices/VoidCapture.cs b/src/Samples/Payments/CoreServices/VoidCapture.cs index 93250e7..de5a32e 100644 --- a/src/Samples/Payments/CoreServices/VoidCapture.cs +++ b/src/Samples/Payments/CoreServices/VoidCapture.cs @@ -8,23 +8,71 @@ public class VoidCapture { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(VoidCapture)}"); + var capturePaymentId = CapturePayment.Run().Id; + + CyberSource.Client.Configuration clientConfig = null; + PtsV2PaymentsVoidsPost201Response result = null; + var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_capture_void"); - var requestBody = new VoidCaptureRequest(clientReferenceInformationObj); + var requestObj = new VoidCaptureRequest(clientReferenceInformationObj); try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new VoidApi(clientConfig); - var result = apiInstance.VoidCapture(requestBody, capturePaymentId); - Console.WriteLine(result); + result = apiInstance.VoidCapture(requestObj, capturePaymentId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(VoidCapture)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(VoidCapture)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Payments/CoreServices/VoidCredit.cs b/src/Samples/Payments/CoreServices/VoidCredit.cs index a12def3..4f72f97 100644 --- a/src/Samples/Payments/CoreServices/VoidCredit.cs +++ b/src/Samples/Payments/CoreServices/VoidCredit.cs @@ -8,24 +8,71 @@ public class VoidCredit { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(VoidCredit)}"); + var processCreditId = ProcessCredit.Run().Id; + CyberSource.Client.Configuration clientConfig = null; + PtsV2PaymentsVoidsPost201Response result = null; + var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_credit_void"); - var requestBody = new VoidCreditRequest(clientReferenceInformationObj); + var requestObj = new VoidCreditRequest(clientReferenceInformationObj); try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new VoidApi(clientConfig); - var result = apiInstance.VoidCredit(requestBody, processCreditId); - Console.WriteLine(result); + result = apiInstance.VoidCredit(requestObj, processCreditId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(VoidCredit)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(VoidCredit)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Payments/CoreServices/VoidPayment.cs b/src/Samples/Payments/CoreServices/VoidPayment.cs index 542ebac..18b422a 100644 --- a/src/Samples/Payments/CoreServices/VoidPayment.cs +++ b/src/Samples/Payments/CoreServices/VoidPayment.cs @@ -8,7 +8,13 @@ public class VoidPayment { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(VoidPayment)}"); + ProcessPayment.CaptureTrueForProcessPayment = true; + + CyberSource.Client.Configuration clientConfig = null; + PtsV2PaymentsVoidsPost201Response result = null; + var processPaymentId = ProcessPayment.Run().Id; var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_payment_void"); var requestObj = new VoidPaymentRequest(clientReferenceInformationObj); @@ -16,16 +22,58 @@ public static void Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new VoidApi(clientConfig); - var result = apiInstance.VoidPayment(requestObj, processPaymentId); - Console.WriteLine(result); + result = apiInstance.VoidPayment(requestObj, processPaymentId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(VoidPayment)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(VoidPayment)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Payments/CoreServices/VoidRefund.cs b/src/Samples/Payments/CoreServices/VoidRefund.cs index b24c772..6dc21ff 100644 --- a/src/Samples/Payments/CoreServices/VoidRefund.cs +++ b/src/Samples/Payments/CoreServices/VoidRefund.cs @@ -8,24 +8,71 @@ public class VoidRefund { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(VoidRefund)}"); + var refundPaymentId = RefundPayment.Run().Id; + CyberSource.Client.Configuration clientConfig = null; + PtsV2PaymentsVoidsPost201Response result = null; + var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_refund_void"); - var requestBody = new VoidRefundRequest(clientReferenceInformationObj); + var requestObj = new VoidRefundRequest(clientReferenceInformationObj); try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new VoidApi(clientConfig); - var result = apiInstance.VoidRefund(requestBody, refundPaymentId); - Console.WriteLine(result); + result = apiInstance.VoidRefund(requestObj, refundPaymentId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(VoidRefund)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(VoidRefund)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Payouts/CoreServices/ProcessPayout.cs b/src/Samples/Payouts/CoreServices/ProcessPayout.cs index 191025b..84843d9 100644 --- a/src/Samples/Payouts/CoreServices/ProcessPayout.cs +++ b/src/Samples/Payouts/CoreServices/ProcessPayout.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Client; using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.Payouts.CoreServices @@ -8,6 +9,11 @@ public class ProcessPayout { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(ProcessPayout)}"); + + CyberSource.Client.Configuration clientConfig = null; + ApiResponse result = null; + var requestObj = new PtsV2PayoutsPostResponse(); var clientReferenceInformationObj = new PtsV2PaymentsPost201ResponseClientReferenceInformation @@ -109,16 +115,58 @@ public static void Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ProcessAPayoutApi(clientConfig); - var result = apiInstance.OctCreatePaymentWithHttpInfo(requestObj); - Console.WriteLine(result); + result = apiInstance.OctCreatePaymentWithHttpInfo(requestObj); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(ProcessPayout)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(ProcessPayout)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/CreateAdhocReport.cs b/src/Samples/Reporting/CoreServices/CreateAdhocReport.cs index c153f93..ba185bd 100644 --- a/src/Samples/Reporting/CoreServices/CreateAdhocReport.cs +++ b/src/Samples/Reporting/CoreServices/CreateAdhocReport.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using CyberSource.Api; +using CyberSource.Client; using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices @@ -10,43 +11,90 @@ public class CreateAdhocReport { public static void Run() { - try + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(CreateAdhocReport)}"); + + CyberSource.Client.Configuration clientConfig = null; + ApiResponse result = null; + + var requestObj = new RequestBody1 { - var requestObj = new RequestBody1 + ReportDefinitionName = "TransactionRequestClass", + ReportFields = new List() { - ReportDefinitionName = "TransactionRequestClass", - ReportFields = new List() - { - "Request.RequestID", - "Request.TransactionDate", - "Request.MerchantID" - }, - ReportMimeType = RequestBody1.ReportMimeTypeEnum.ApplicationXml, - ReportName = "testrest_vter9", - Timezone = "GMT", - ReportStartTime = DateTime.ParseExact("2018-09-01T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture), - ReportEndTime = DateTime.ParseExact("2018-09-02T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture) - }; - - var reportPreferencesObj = new ReportingV3ReportSubscriptionsGet200ResponseReportPreferences() - { - SignedAmounts = true, - FieldNameConvention = ReportingV3ReportSubscriptionsGet200ResponseReportPreferences.FieldNameConventionEnum.SOAPI - }; + "Request.RequestID", + "Request.TransactionDate", + "Request.MerchantID" + }, + ReportMimeType = RequestBody1.ReportMimeTypeEnum.ApplicationXml, + ReportName = "testrest_vter9", + Timezone = "GMT", + ReportStartTime = DateTime.ParseExact("2018-09-01T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture), + ReportEndTime = DateTime.ParseExact("2018-09-02T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture) + }; - requestObj.ReportPreferences = reportPreferencesObj; + var reportPreferencesObj = new ReportingV3ReportSubscriptionsGet200ResponseReportPreferences() + { + SignedAmounts = true, + FieldNameConvention = ReportingV3ReportSubscriptionsGet200ResponseReportPreferences.FieldNameConventionEnum.SOAPI + }; + requestObj.ReportPreferences = reportPreferencesObj; + + try + { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReportsApi(clientConfig); - var result = apiInstance.CreateReportWithHttpInfo(requestObj); - Console.WriteLine(result); + result = apiInstance.CreateReportWithHttpInfo(requestObj); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(CreateAdhocReport)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(CreateAdhocReport)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/CreateReportSubscriptionForReportNameByOrganization.cs b/src/Samples/Reporting/CoreServices/CreateReportSubscriptionForReportNameByOrganization.cs index 3474fe5..5f83721 100644 --- a/src/Samples/Reporting/CoreServices/CreateReportSubscriptionForReportNameByOrganization.cs +++ b/src/Samples/Reporting/CoreServices/CreateReportSubscriptionForReportNameByOrganization.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -using System.Globalization; using CyberSource.Api; +using CyberSource.Client; using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices @@ -10,10 +10,15 @@ public class CreateReportSubscriptionForReportNameByOrganization { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(CreateReportSubscriptionForReportNameByOrganization)}"); + + CyberSource.Client.Configuration clientConfig = null; + ApiResponse result = null; + const string reportName = "testrest_subcription_v1"; - var request = new RequestBody(ReportDefinitionName: "TransactionRequestClass", - ReportFields: new List() {"Request.RequestID", "Request.TransactionDate", "Request.MerchantID"}, + var requestObj = new RequestBody(ReportDefinitionName: "TransactionRequestClass", + ReportFields: new List() { "Request.RequestID", "Request.TransactionDate", "Request.MerchantID" }, ReportName: reportName) { ReportMimeType = RequestBody.ReportMimeTypeEnum.ApplicationXml, @@ -26,19 +31,60 @@ public static void Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReportSubscriptionsApi(clientConfig); - var result = apiInstance.CreateSubscriptionWithHttpInfo("", request); - Console.WriteLine(result); - - DeleteSubscriptionOfReportNameByOrganization.ReportNameToDelete = reportName; - DeleteSubscriptionOfReportNameByOrganization.Run(); + result = apiInstance.CreateSubscriptionWithHttpInfo(string.Empty, requestObj); } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(CreateReportSubscriptionForReportNameByOrganization)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(CreateReportSubscriptionForReportNameByOrganization)}"); + } + + DeleteSubscriptionOfReportNameByOrganization.ReportNameToDelete = reportName; + DeleteSubscriptionOfReportNameByOrganization.Run(); } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/DeleteSubscriptionOfReportNameByOrganization.cs b/src/Samples/Reporting/CoreServices/DeleteSubscriptionOfReportNameByOrganization.cs index a0f901f..81f1b38 100644 --- a/src/Samples/Reporting/CoreServices/DeleteSubscriptionOfReportNameByOrganization.cs +++ b/src/Samples/Reporting/CoreServices/DeleteSubscriptionOfReportNameByOrganization.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Client; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices { @@ -9,6 +10,11 @@ public class DeleteSubscriptionOfReportNameByOrganization public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(DeleteSubscriptionOfReportNameByOrganization)}"); + + CyberSource.Client.Configuration clientConfig = null; + ApiResponse result = null; + if (string.IsNullOrEmpty(ReportNameToDelete)) { ReportNameToDelete = "testrest_subcription_v1"; @@ -17,16 +23,52 @@ public static void Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReportSubscriptionsApi(clientConfig); - var result = apiInstance.DeleteSubscriptionWithHttpInfo(ReportNameToDelete); - Console.WriteLine(result); + result = apiInstance.DeleteSubscriptionWithHttpInfo(ReportNameToDelete); + ReportNameToDelete = null; } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(DeleteSubscriptionOfReportNameByOrganization)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(DeleteSubscriptionOfReportNameByOrganization)}"); + } } } } diff --git a/src/Samples/Reporting/CoreServices/DownloadReport.cs b/src/Samples/Reporting/CoreServices/DownloadReport.cs index 03e64c0..475ccc2 100644 --- a/src/Samples/Reporting/CoreServices/DownloadReport.cs +++ b/src/Samples/Reporting/CoreServices/DownloadReport.cs @@ -1,9 +1,9 @@ using System; -using System.Globalization; using System.IO; using System.Xml; using System.Xml.Serialization; using CyberSource.Api; +using CyberSource.Client; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices { @@ -11,6 +11,11 @@ public class DownloadReport { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(DownloadReport)}"); + + CyberSource.Client.Configuration clientConfig = null; + ApiResponse result = null; + // File will be created with the Data received in the Response Body // Provide the File Name @@ -27,11 +32,10 @@ public static void Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReportDownloadsApi(clientConfig); - var result = apiInstance.DownloadReportWithHttpInfo(reportDate, reportName, organizationId); - Console.WriteLine(result); + result = apiInstance.DownloadReportWithHttpInfo(reportDate, reportName, organizationId); File.WriteAllText(downloadFilePath, CreateXml(result.Data)); Console.WriteLine("\nFile downloaded at the below location:"); @@ -43,7 +47,43 @@ public static void Run() } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(DownloadReport)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(DownloadReport)}"); + } } } @@ -64,4 +104,4 @@ private static string CreateXml(object obj) } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/GetAllSubscriptions.cs b/src/Samples/Reporting/CoreServices/GetAllSubscriptions.cs index 655160d..b7742fa 100644 --- a/src/Samples/Reporting/CoreServices/GetAllSubscriptions.cs +++ b/src/Samples/Reporting/CoreServices/GetAllSubscriptions.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices { @@ -7,19 +8,60 @@ public class GetAllSubscriptions { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetAllSubscriptions)}"); + + CyberSource.Client.Configuration clientConfig = null; + ReportingV3ReportSubscriptionsGet200Response result = null; + try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReportSubscriptionsApi(clientConfig); - var result = apiInstance.GetAllSubscriptions(); - Console.WriteLine(result); + result = apiInstance.GetAllSubscriptions(); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetAllSubscriptions)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetAllSubscriptions)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/GetNotificationOfChanges.cs b/src/Samples/Reporting/CoreServices/GetNotificationOfChanges.cs index ff613d3..0de0068 100644 --- a/src/Samples/Reporting/CoreServices/GetNotificationOfChanges.cs +++ b/src/Samples/Reporting/CoreServices/GetNotificationOfChanges.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices { @@ -7,25 +8,63 @@ public class GetNotificationOfChanges { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetNotificationOfChanges)}"); + + CyberSource.Client.Configuration clientConfig = null; + ReportingV3NotificationofChangesGet200Response result = null; + var startTime = DateTime.Parse("2018-09-01T12:00:00-05:00"); var endTime = DateTime.Parse("2018-09-30T12:00:00-05:00"); - //var startTime = DateTime.Parse("2018-09-01T12:00:00.000Z"); - //var endTime = DateTime.Parse("2018-09-30T12:00:00.000Z"); - try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new NotificationOfChangesApi(clientConfig); - var result = apiInstance.GetNotificationOfChangeReport(startTime, endTime); - Console.WriteLine(result); + result = apiInstance.GetNotificationOfChangeReport(startTime, endTime); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetNotificationOfChanges)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetNotificationOfChanges)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/GetPurchaseAndRefundDetails.cs b/src/Samples/Reporting/CoreServices/GetPurchaseAndRefundDetails.cs index 5ae4d73..7234896 100644 --- a/src/Samples/Reporting/CoreServices/GetPurchaseAndRefundDetails.cs +++ b/src/Samples/Reporting/CoreServices/GetPurchaseAndRefundDetails.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Client; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices { @@ -7,6 +8,11 @@ public class GetPurchaseAndRefundDetails { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetPurchaseAndRefundDetails)}"); + + CyberSource.Client.Configuration clientConfig = null; + ApiResponse result = null; + const string organizationId = "testrest"; var startTime = DateTime.Parse("2018-05-01T12:00:00-05:00"); var endTime = DateTime.Parse("2018-05-30T12:00:00-05:00"); @@ -19,17 +25,53 @@ public static void Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PurchaseAndRefundDetailsApi(clientConfig); - var result = apiInstance.GetPurchaseAndRefundDetailsWithHttpInfo(startTime, endTime, organizationId, paymentSubtype, + result = apiInstance.GetPurchaseAndRefundDetailsWithHttpInfo(startTime, endTime, organizationId, paymentSubtype, viewBy, groupName, offset, limit); - Console.WriteLine(result); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetPurchaseAndRefundDetails)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetPurchaseAndRefundDetails)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/GetReportBasedOnReportid.cs b/src/Samples/Reporting/CoreServices/GetReportBasedOnReportid.cs index bb2e508..6fd0e1b 100644 --- a/src/Samples/Reporting/CoreServices/GetReportBasedOnReportid.cs +++ b/src/Samples/Reporting/CoreServices/GetReportBasedOnReportid.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices { @@ -7,22 +8,63 @@ public class GetReportBasedOnReportid { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetReportBasedOnReportid)}"); + + CyberSource.Client.Configuration clientConfig = null; + ReportingV3ReportsIdGet200Response result = null; + const string reportId = "79642c43-2368-0cd5-e053-a2588e0a7b3c"; const string organizationId = "testrest"; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReportsApi(clientConfig); - var result = apiInstance.GetReportByReportId(reportId, organizationId); - Console.WriteLine(result); + result = apiInstance.GetReportByReportId(reportId, organizationId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetReportBasedOnReportid)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetReportBasedOnReportid)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/GetReportDefinition.cs b/src/Samples/Reporting/CoreServices/GetReportDefinition.cs index e32ab14..9086a38 100644 --- a/src/Samples/Reporting/CoreServices/GetReportDefinition.cs +++ b/src/Samples/Reporting/CoreServices/GetReportDefinition.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices { @@ -7,21 +8,62 @@ public class GetReportDefinition { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetReportDefinition)}"); + + CyberSource.Client.Configuration clientConfig = null; + ReportingV3ReportDefinitionsNameGet200Response result = null; + const string reportDefinitionName = "SubscriptionDetailClass"; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReportDefinitionsApi(clientConfig); - var result = apiInstance.GetResourceInfoByReportDefinition(reportDefinitionName); - Console.WriteLine(result); + result = apiInstance.GetResourceInfoByReportDefinition(reportDefinitionName); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetReportDefinition)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetReportDefinition)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/GetReportingResourceInformation.cs b/src/Samples/Reporting/CoreServices/GetReportingResourceInformation.cs index 6d14aa8..74bd5ad 100644 --- a/src/Samples/Reporting/CoreServices/GetReportingResourceInformation.cs +++ b/src/Samples/Reporting/CoreServices/GetReportingResourceInformation.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices { @@ -7,21 +8,62 @@ public class GetReportingResourceInformation { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetReportingResourceInformation)}"); + + CyberSource.Client.Configuration clientConfig = null; + ReportingV3ReportDefinitionsGet200Response result = null; + const string organizationId = "testrest"; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReportDefinitionsApi(clientConfig); - var result = apiInstance.GetResourceV2Info(organizationId); - Console.WriteLine(result); + result = apiInstance.GetResourceV2Info(organizationId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetReportingResourceInformation)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetReportingResourceInformation)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/GetSubscriptionForReportName.cs b/src/Samples/Reporting/CoreServices/GetSubscriptionForReportName.cs index 027ba59..1a44fd4 100644 --- a/src/Samples/Reporting/CoreServices/GetSubscriptionForReportName.cs +++ b/src/Samples/Reporting/CoreServices/GetSubscriptionForReportName.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices { @@ -7,21 +8,62 @@ public class GetSubscriptionForReportName { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetSubscriptionForReportName)}"); + + CyberSource.Client.Configuration clientConfig = null; + ReportingV3ReportSubscriptionsGet200ResponseSubscriptions result = null; + var reportName = "testrest_subcription_v1"; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReportSubscriptionsApi(clientConfig); - var result = apiInstance.GetSubscription(reportName); - Console.WriteLine(result); + result = apiInstance.GetSubscription(reportName); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetSubscriptionForReportName)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetSubscriptionForReportName)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/RetrieveAvailableReports.cs b/src/Samples/Reporting/CoreServices/RetrieveAvailableReports.cs index 56b5300..4ef47ac 100644 --- a/src/Samples/Reporting/CoreServices/RetrieveAvailableReports.cs +++ b/src/Samples/Reporting/CoreServices/RetrieveAvailableReports.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices { @@ -7,6 +8,11 @@ public class RetrieveAvailableReports { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(RetrieveAvailableReports)}"); + + CyberSource.Client.Configuration clientConfig = null; + ReportingV3ReportsGet200Response result = null; + try { var startTime = "2018-10-01T00:00:00Z"; @@ -15,15 +21,51 @@ public static void Run() var organizationId = "testrest"; var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new ReportsApi(clientConfig); - var result = apiInstance.SearchReports(startTime, endTime, timeQueryType, organizationId); + result = apiInstance.SearchReports(startTime, endTime, timeQueryType, organizationId); } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(RetrieveAvailableReports)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(RetrieveAvailableReports)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/SecureFileShare/CoreServices/DownloadFileWithFileIdentifier.cs b/src/Samples/SecureFileShare/CoreServices/DownloadFileWithFileIdentifier.cs index 99757f7..594d321 100644 --- a/src/Samples/SecureFileShare/CoreServices/DownloadFileWithFileIdentifier.cs +++ b/src/Samples/SecureFileShare/CoreServices/DownloadFileWithFileIdentifier.cs @@ -3,6 +3,7 @@ using System.Xml; using System.Xml.Serialization; using CyberSource.Api; +using CyberSource.Client; namespace Cybersource_rest_samples_dotnet.Samples.SecureFileShare.CoreServices { @@ -10,6 +11,11 @@ public class DownloadFileWithFileIdentifier { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(DownloadFileWithFileIdentifier)}"); + + CyberSource.Client.Configuration clientConfig = null; + ApiResponse result = null; + try { // File will be created with the Data received in the Response Body @@ -25,11 +31,11 @@ public static void Run() var organizationId = "testrest"; var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new SecureFileShareApi(clientConfig); - var result = apiInstance.GetFileWithHttpInfo(fileId, organizationId); - Console.WriteLine(result); + result = apiInstance.GetFileWithHttpInfo(fileId, organizationId); + File.WriteAllText(downloadFilePath, CreateXml(result.Data)); Console.WriteLine("\nFile downloaded at the below location:"); Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n"); @@ -40,7 +46,43 @@ public static void Run() } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(DownloadFileWithFileIdentifier)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(DownloadFileWithFileIdentifier)}"); + } } } @@ -61,4 +103,4 @@ private static string CreateXml(object obj) } } } -} +} \ No newline at end of file diff --git a/src/Samples/SecureFileShare/CoreServices/GetListOfFiles.cs b/src/Samples/SecureFileShare/CoreServices/GetListOfFiles.cs index 56a9d76..1c19c04 100644 --- a/src/Samples/SecureFileShare/CoreServices/GetListOfFiles.cs +++ b/src/Samples/SecureFileShare/CoreServices/GetListOfFiles.cs @@ -1,29 +1,70 @@ -using System; -using System.Globalization; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.SecureFileShare.CoreServices +namespace Cybersource_rest_samples_dotnet.Samples.SecureFileShare.CoreServices { + using System; + using CyberSource.Api; + using CyberSource.Model; + public class GetListOfFiles { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetListOfFiles)}"); + + CyberSource.Client.Configuration clientConfig = null; + V1FileDetailsGet200Response result = null; + try { - var startDate ="2018-10-20"; + var startDate = "2018-10-20"; var endDate = "2018-10-30"; var organizationId = "testrest"; var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new SecureFileShareApi(clientConfig); - var result = apiInstance.GetFileDetails(startDate, endDate, organizationId); - Console.WriteLine(result); + result = apiInstance.GetFileDetails(startDate, endDate, organizationId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetListOfFiles)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetListOfFiles)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/TMS/CoreServices/CreateInstrumentIdentifier.cs b/src/Samples/TMS/CoreServices/CreateInstrumentIdentifier.cs index 600432f..c9f08f2 100644 --- a/src/Samples/TMS/CoreServices/CreateInstrumentIdentifier.cs +++ b/src/Samples/TMS/CoreServices/CreateInstrumentIdentifier.cs @@ -8,6 +8,11 @@ public class CreateInstrumentIdentifier { public static TmsV1InstrumentidentifiersPost200Response Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(CreateInstrumentIdentifier)}"); + + CyberSource.Client.Configuration clientConfig = null; + TmsV1InstrumentidentifiersPost200Response result = null; + var requestObj = new Body(); var cardObj = new Tmsv1instrumentidentifiersCard @@ -40,18 +45,60 @@ public static TmsV1InstrumentidentifiersPost200Response Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new InstrumentIdentifiersApi(clientConfig); - var result = apiInstance.TmsV1InstrumentidentifiersPost("93B32398-AD51-4CC2-A682-EA3E93614EB1", requestObj); - Console.WriteLine(result); + result = apiInstance.TmsV1InstrumentidentifiersPost("93B32398-AD51-4CC2-A682-EA3E93614EB1", requestObj); + return result; } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(CreateInstrumentIdentifier)}):{e.Message}"); return null; } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(CreateInstrumentIdentifier)}"); + } + } } } -} +} \ No newline at end of file diff --git a/src/Samples/TMS/CoreServices/CreatePaymentInstrument.cs b/src/Samples/TMS/CoreServices/CreatePaymentInstrument.cs index b1039f4..e5afc38 100644 --- a/src/Samples/TMS/CoreServices/CreatePaymentInstrument.cs +++ b/src/Samples/TMS/CoreServices/CreatePaymentInstrument.cs @@ -8,6 +8,11 @@ public class CreatePaymentInstrument { public static TmsV1PaymentinstrumentsPost201Response Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(CreatePaymentInstrument)}"); + + CyberSource.Client.Configuration clientConfig = null; + TmsV1PaymentinstrumentsPost201Response result = null; + var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; var requestObj = new Body2(); @@ -51,18 +56,60 @@ public static TmsV1PaymentinstrumentsPost201Response Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentInstrumentsApi(clientConfig); - var result = apiInstance.TmsV1PaymentinstrumentsPost(profileId, requestObj); - Console.WriteLine(result); + result = apiInstance.TmsV1PaymentinstrumentsPost(profileId, requestObj); + return result; } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(CreatePaymentInstrument)}):{e.Message}"); return null; } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(CreatePaymentInstrument)}"); + } + } } } -} +} \ No newline at end of file diff --git a/src/Samples/TMS/CoreServices/DeleteInstrumentIdentifier.cs b/src/Samples/TMS/CoreServices/DeleteInstrumentIdentifier.cs index 63cdc32..70fac91 100644 --- a/src/Samples/TMS/CoreServices/DeleteInstrumentIdentifier.cs +++ b/src/Samples/TMS/CoreServices/DeleteInstrumentIdentifier.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Client; namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices { @@ -7,22 +8,63 @@ public class DeleteInstrumentIdentifier { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(DeleteInstrumentIdentifier)}"); + + CyberSource.Client.Configuration clientConfig = null; + ApiResponse result = null; + var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; var tokenId = CreateInstrumentIdentifier.Run().Id; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new InstrumentIdentifierApi(clientConfig); - var result = apiInstance.TmsV1InstrumentidentifiersTokenIdDeleteWithHttpInfo(profileId, tokenId); - Console.WriteLine(result); + result = apiInstance.TmsV1InstrumentidentifiersTokenIdDeleteWithHttpInfo(profileId, tokenId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(DeleteInstrumentIdentifier)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(DeleteInstrumentIdentifier)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/TMS/CoreServices/DeletePaymentInstrument.cs b/src/Samples/TMS/CoreServices/DeletePaymentInstrument.cs index fd831fa..4e039db 100644 --- a/src/Samples/TMS/CoreServices/DeletePaymentInstrument.cs +++ b/src/Samples/TMS/CoreServices/DeletePaymentInstrument.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Client; namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices { @@ -7,22 +8,63 @@ public class DeletePaymentInstrument { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(DeletePaymentInstrument)}"); + + CyberSource.Client.Configuration clientConfig = null; + ApiResponse result = null; + var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; var tokenId = CreatePaymentInstrument.Run().Id; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentInstrumentsApi(clientConfig); - var result = apiInstance.TmsV1PaymentinstrumentsTokenIdDeleteWithHttpInfo(profileId, tokenId); - Console.WriteLine(result); + result = apiInstance.TmsV1PaymentinstrumentsTokenIdDeleteWithHttpInfo(profileId, tokenId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(DeletePaymentInstrument)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(DeletePaymentInstrument)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/TMS/CoreServices/RetrieveAllPaymentInstruments.cs b/src/Samples/TMS/CoreServices/RetrieveAllPaymentInstruments.cs index c47cf2f..4afc5cd 100644 --- a/src/Samples/TMS/CoreServices/RetrieveAllPaymentInstruments.cs +++ b/src/Samples/TMS/CoreServices/RetrieveAllPaymentInstruments.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices { @@ -7,22 +8,63 @@ public class RetrieveAllPaymentInstruments { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(RetrieveAllPaymentInstruments)}"); + + CyberSource.Client.Configuration clientConfig = null; + TmsV1InstrumentidentifiersPaymentinstrumentsGet200Response result = null; + var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; var tokenId = CreateInstrumentIdentifier.Run().Id; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentInstrumentsApi(clientConfig); - var result = apiInstance.TmsV1InstrumentidentifiersTokenIdPaymentinstrumentsGet(profileId, tokenId); - Console.WriteLine(result); + result = apiInstance.TmsV1InstrumentidentifiersTokenIdPaymentinstrumentsGet(profileId, tokenId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(RetrieveAllPaymentInstruments)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(RetrieveAllPaymentInstruments)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/TMS/CoreServices/RetrieveInstrumentIdentifier.cs b/src/Samples/TMS/CoreServices/RetrieveInstrumentIdentifier.cs index aceb153..87a9ae0 100644 --- a/src/Samples/TMS/CoreServices/RetrieveInstrumentIdentifier.cs +++ b/src/Samples/TMS/CoreServices/RetrieveInstrumentIdentifier.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices { @@ -7,22 +8,63 @@ public class RetrieveInstrumentIdentifier { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(RetrieveInstrumentIdentifier)}"); + + CyberSource.Client.Configuration clientConfig = null; + TmsV1InstrumentidentifiersPost200Response result = null; + var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; var tokenId = CreateInstrumentIdentifier.Run().Id; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new InstrumentIdentifierApi(clientConfig); - var result = apiInstance.TmsV1InstrumentidentifiersTokenIdGet(profileId, tokenId); - Console.WriteLine(result); + result = apiInstance.TmsV1InstrumentidentifiersTokenIdGet(profileId, tokenId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(RetrieveInstrumentIdentifier)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(RetrieveInstrumentIdentifier)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/TMS/CoreServices/RetrievePaymentInstrument.cs b/src/Samples/TMS/CoreServices/RetrievePaymentInstrument.cs index 183d403..d7e4779 100644 --- a/src/Samples/TMS/CoreServices/RetrievePaymentInstrument.cs +++ b/src/Samples/TMS/CoreServices/RetrievePaymentInstrument.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices { @@ -7,22 +8,63 @@ public class RetrievePaymentInstrument { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(RetrievePaymentInstrument)}"); + + CyberSource.Client.Configuration clientConfig = null; + TmsV1PaymentinstrumentsPost201Response result = null; + var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; var tokenId = CreatePaymentInstrument.Run().Id; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentInstrumentsApi(clientConfig); - var result = apiInstance.TmsV1PaymentinstrumentsTokenIdGet(profileId, tokenId); - Console.WriteLine(result); + result = apiInstance.TmsV1PaymentinstrumentsTokenIdGet(profileId, tokenId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(RetrievePaymentInstrument)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(RetrievePaymentInstrument)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/TMS/CoreServices/UpdateInstrumentIdentifier.cs b/src/Samples/TMS/CoreServices/UpdateInstrumentIdentifier.cs index 2f38be4..610fdf4 100644 --- a/src/Samples/TMS/CoreServices/UpdateInstrumentIdentifier.cs +++ b/src/Samples/TMS/CoreServices/UpdateInstrumentIdentifier.cs @@ -8,9 +8,14 @@ public class UpdateInstrumentIdentifier { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(UpdateInstrumentIdentifier)}"); + var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; var tokenId = CreateInstrumentIdentifier.Run().Id; + CyberSource.Client.Configuration clientConfig = null; + TmsV1InstrumentidentifiersPost200Response result = null; + var requestObj = new Body1(); var processingInformationObj = new Tmsv1instrumentidentifiersProcessingInformation(); @@ -36,16 +41,58 @@ public static void Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new InstrumentIdentifierApi(clientConfig); - var result = apiInstance.TmsV1InstrumentidentifiersTokenIdPatch(profileId, tokenId, requestObj); - Console.WriteLine(result); + result = apiInstance.TmsV1InstrumentidentifiersTokenIdPatch(profileId, tokenId, requestObj); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(UpdateInstrumentIdentifier)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(UpdateInstrumentIdentifier)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/TMS/CoreServices/UpdatePaymentInstrument.cs b/src/Samples/TMS/CoreServices/UpdatePaymentInstrument.cs index 7436962..973a31c 100644 --- a/src/Samples/TMS/CoreServices/UpdatePaymentInstrument.cs +++ b/src/Samples/TMS/CoreServices/UpdatePaymentInstrument.cs @@ -8,6 +8,11 @@ public class UpdatePaymentInstrument { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(UpdatePaymentInstrument)}"); + + CyberSource.Client.Configuration clientConfig = null; + TmsV1PaymentinstrumentsPost201Response result = null; + var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; var tokenId = CreatePaymentInstrument.Run().Id; @@ -53,16 +58,58 @@ public static void Run() try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new PaymentInstrumentsApi(clientConfig); - var result = apiInstance.TmsV1PaymentinstrumentsTokenIdPatch(profileId, tokenId, requestObj); - Console.WriteLine(result); + result = apiInstance.TmsV1PaymentinstrumentsTokenIdPatch(profileId, tokenId, requestObj); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(UpdatePaymentInstrument)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(UpdatePaymentInstrument)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/TransactionBatches/CoreServices/GetIndividualBatchFile.cs b/src/Samples/TransactionBatches/CoreServices/GetIndividualBatchFile.cs index 8403e96..2378fb5 100644 --- a/src/Samples/TransactionBatches/CoreServices/GetIndividualBatchFile.cs +++ b/src/Samples/TransactionBatches/CoreServices/GetIndividualBatchFile.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Client; namespace Cybersource_rest_samples_dotnet.Samples.TransactionBatches.CoreServices { @@ -7,20 +8,61 @@ public class GetIndividualBatchFile { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetIndividualBatchFile)}"); + + CyberSource.Client.Configuration clientConfig = null; + ApiResponse result = null; + try { var id = "Owcyk6pl"; var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new TransactionBatchApi(clientConfig); - var result = apiInstance.PtsV1TransactionBatchesIdGetWithHttpInfo(id); - Console.WriteLine(result); + result = apiInstance.PtsV1TransactionBatchesIdGetWithHttpInfo(id); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetIndividualBatchFile)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetIndividualBatchFile)}"); + } } } } diff --git a/src/Samples/TransactionBatches/CoreServices/GetListOfBatchFiles.cs b/src/Samples/TransactionBatches/CoreServices/GetListOfBatchFiles.cs index eded367..27922a7 100644 --- a/src/Samples/TransactionBatches/CoreServices/GetListOfBatchFiles.cs +++ b/src/Samples/TransactionBatches/CoreServices/GetListOfBatchFiles.cs @@ -1,6 +1,6 @@ using System; -using System.Globalization; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.TransactionBatches.CoreServices { @@ -8,21 +8,62 @@ public class GetListOfBatchFiles { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetListOfBatchFiles)}"); + + CyberSource.Client.Configuration clientConfig = null; + PtsV1TransactionBatchesGet200Response result = null; + try { var startTime = "2018-08-11T22:47:57Z"; var endTime = "2018-10-29T22:47:57Z"; var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new TransactionBatchesApi(clientConfig); - var result = apiInstance.PtsV1TransactionBatchesGet(startTime, endTime); - Console.WriteLine(result); + result = apiInstance.PtsV1TransactionBatchesGet(startTime, endTime); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetListOfBatchFiles)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetListOfBatchFiles)}"); + } } } } diff --git a/src/Samples/TransactionDetails/CoreServices/RetrieveTransaction.cs b/src/Samples/TransactionDetails/CoreServices/RetrieveTransaction.cs index dcb2400..7343baa 100644 --- a/src/Samples/TransactionDetails/CoreServices/RetrieveTransaction.cs +++ b/src/Samples/TransactionDetails/CoreServices/RetrieveTransaction.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.TransactionDetails.CoreServices { @@ -7,21 +8,62 @@ public class RetrieveTransaction { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(RetrieveTransaction)}"); + + CyberSource.Client.Configuration clientConfig = null; + TssV2TransactionsGet200Response result = null; + const string id = "5408386919326811103004"; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new TransactionDetailsApi(clientConfig); - var result = apiInstance.GetTransaction(id); - Console.WriteLine(result); + result = apiInstance.GetTransaction(id); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(RetrieveTransaction)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(RetrieveTransaction)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/TransactionSearch/CoreServices/CreateSearchRequest.cs b/src/Samples/TransactionSearch/CoreServices/CreateSearchRequest.cs index 7493454..4fe92b3 100644 --- a/src/Samples/TransactionSearch/CoreServices/CreateSearchRequest.cs +++ b/src/Samples/TransactionSearch/CoreServices/CreateSearchRequest.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.TransactionSearch.CoreServices { @@ -7,30 +8,77 @@ public class CreateSearchRequest { public static void Run() { - try + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(CreateSearchRequest)}"); + + CyberSource.Client.Configuration clientConfig = null; + TssV2TransactionsPost201Response result = null; + + var requestObj = new CyberSource.Model.TssV2TransactionsPostResponse() { - var requestObj = new CyberSource.Model.TssV2TransactionsPostResponse() - { - Save = false, - Name = "TSS search", - Timezone = "America/Chicago", - Query = "clientReferenceInformation.code:12345", - Offset = 0, - Limit = 100, - Sort = "id:asc, submitTimeUtc:asc" - }; + Save = false, + Name = "TSS search", + Timezone = "America/Chicago", + Query = "clientReferenceInformation.code:12345", + Offset = 0, + Limit = 100, + Sort = "id:asc, submitTimeUtc:asc" + }; + try + { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new SearchTransactionsApi(clientConfig); - var result = apiInstance.CreateSearch(requestObj); - Console.WriteLine(result); + result = apiInstance.CreateSearch(requestObj); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(CreateSearchRequest)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + if (!string.IsNullOrEmpty(clientConfig.ApiClient.Configuration.RequestBody)) + { + Console.WriteLine("\nAPI REQUEST BODY:"); + Console.WriteLine(clientConfig.ApiClient.Configuration.RequestBody); + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(CreateSearchRequest)}"); + } } } } -} +} \ No newline at end of file diff --git a/src/Samples/TransactionSearch/CoreServices/GetSearchResults.cs b/src/Samples/TransactionSearch/CoreServices/GetSearchResults.cs index d06097c..cde09b9 100644 --- a/src/Samples/TransactionSearch/CoreServices/GetSearchResults.cs +++ b/src/Samples/TransactionSearch/CoreServices/GetSearchResults.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.TransactionSearch.CoreServices { @@ -7,20 +8,61 @@ public class GetSearchResults { public static void Run() { - var id = "5f6b1f07-0190-460b-852e-6766252fbb18"; + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetSearchResults)}"); + + CyberSource.Client.Configuration clientConfig = null; + TssV2TransactionsPost201Response result = null; + + var id = "a39188d5-158a-4fb4-98e5-b4a05e0017d2"; try { var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new SearchTransactionsApi(clientConfig); - var result = apiInstance.GetSearch(id); - Console.WriteLine(result); + result = apiInstance.GetSearch(id); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetSearchResults)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetSearchResults)}"); + } } } } diff --git a/src/Samples/UserManagement/CoreServices/GetUserInformation.cs b/src/Samples/UserManagement/CoreServices/GetUserInformation.cs index b6d508c..87e33bc 100644 --- a/src/Samples/UserManagement/CoreServices/GetUserInformation.cs +++ b/src/Samples/UserManagement/CoreServices/GetUserInformation.cs @@ -1,5 +1,6 @@ using System; using CyberSource.Api; +using CyberSource.Model; namespace Cybersource_rest_samples_dotnet.Samples.UserManagement.CoreServices { @@ -7,6 +8,11 @@ public class GetUserInformation { public static void Run() { + Console.WriteLine($"\n[BEGIN] EXECUTION OF SAMPLE CODE: {nameof(GetUserInformation)}"); + + CyberSource.Client.Configuration clientConfig = null; + UmsV1UsersGet200Response result = null; + try { var organizationId = "testrest"; @@ -15,16 +21,52 @@ public static void Run() var username = "tesrest"; var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new UserManagementApi(clientConfig); - var result = apiInstance.GetUsers(organizationId); - Console.WriteLine(result); + result = apiInstance.GetUsers(organizationId); + } catch (Exception e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine($"\nException on calling the Sample Code({nameof(GetUserInformation)}):{e.Message}"); + } + finally + { + if (clientConfig != null) + { + // PRINTING REQUEST DETAILS + if (clientConfig.ApiClient.Configuration.RequestHeaders != null) + { + Console.WriteLine("\nAPI REQUEST HEADERS:"); + foreach (var requestHeader in clientConfig.ApiClient.Configuration.RequestHeaders) + { + Console.WriteLine(requestHeader); + } + } + + // PRINTING RESPONSE DETAILS + if (clientConfig.ApiClient.ApiResponse != null) + { + if (!string.IsNullOrEmpty(clientConfig.ApiClient.ApiResponse.StatusCode.ToString())) + { + Console.WriteLine($"\nAPI RESPONSE CODE: {clientConfig.ApiClient.ApiResponse.StatusCode}"); + } + + Console.WriteLine("\nAPI RESPONSE HEADERS:"); + + foreach (var responseHeader in clientConfig.ApiClient.ApiResponse.HeadersList) + { + Console.WriteLine(responseHeader); + } + + Console.WriteLine("\nAPI RESPONSE BODY:"); + Console.WriteLine(clientConfig.ApiClient.ApiResponse.Data); + } + + Console.WriteLine($"\n[END] EXECUTION OF SAMPLE CODE: {nameof(GetUserInformation)}"); + } } } } -} +} \ No newline at end of file