Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth sample code commented | GENAI=NO #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 49 additions & 49 deletions Source/Samples/Authentication/CallHttpMethods/DeleteMethod.cs
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
using System;
using ApiSdk.controller;
using AuthenticationSdk.core;
using AuthenticationSdk.util;
//using System;
//using ApiSdk.controller;
//using AuthenticationSdk.core;
//using AuthenticationSdk.util;

namespace Cybersource_rest_samples_dotnet.Samples.Authentication
{
public class DeleteMethod
{
//namespace Cybersource_rest_samples_dotnet.Samples.Authentication
//{
// public class DeleteMethod
// {
// DELETE Request to Delete subscription of (Unsubscribe) a report name by organization
// Below request unsubscribes 'TRR Report' Subscription for Organization ID: testrest
private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest";
//private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest";

public static void WriteLogAudit(int status)
{
var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.');
var filename = filePath[filePath.Length - 1];
Console.WriteLine($"[Sample Code Testing] [{filename}] {status}");
}
//public static void WriteLogAudit(int status)
//{
// var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.');
// var filename = filePath[filePath.Length - 1];
// Console.WriteLine($"[Sample Code Testing] [{filename}] {status}");
//}

public static void Run()
{
try
{
//public static void Run()
//{
// try
// {
// Setting up Merchant Config
var merchantConfig = new MerchantConfig
{
RequestTarget = RequestTarget,
RequestType = Enumerations.RequestType.DELETE.ToString()
};
//var merchantConfig = new MerchantConfig
//{
// RequestTarget = RequestTarget,
// RequestType = Enumerations.RequestType.DELETE.ToString()
//};

// Call to the Controller of API_SDK
var apiController = new APIController(merchantConfig);
var response = apiController.DeletePayment();
//var apiController = new APIController(merchantConfig);
//var response = apiController.DeletePayment();

// printing the response details
if (response != null)
{
Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id"));
Console.WriteLine("\n Response Code:{0}", response.StatusCode);
Console.WriteLine("\n Response Message:{0}", response.Data);
if (response.StatusCode == 200 || response.StatusCode == 404)
{
WriteLogAudit(200);
}
else
{
WriteLogAudit(response.StatusCode);
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
}
}
}
// if (response != null)
// {
// Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id"));
// Console.WriteLine("\n Response Code:{0}", response.StatusCode);
// Console.WriteLine("\n Response Message:{0}", response.Data);
// if (response.StatusCode == 200 || response.StatusCode == 404)
// {
// WriteLogAudit(200);
// }
// else
// {
// WriteLogAudit(response.StatusCode);
// }
// }
// }
// catch (Exception e)
// {
// Console.WriteLine(e.Message);
// Console.WriteLine(e.StackTrace);
// }
// }
// }
//}
84 changes: 42 additions & 42 deletions Source/Samples/Authentication/CallHttpMethods/GetMethod.cs
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
using System;
using ApiSdk.controller;
using AuthenticationSdk.core;
using AuthenticationSdk.util;
//using System;
//using ApiSdk.controller;
//using AuthenticationSdk.core;
//using AuthenticationSdk.util;

namespace Cybersource_rest_samples_dotnet.Samples.Authentication
{
public class GetMethod
{
//namespace Cybersource_rest_samples_dotnet.Samples.Authentication
//{
// public class GetMethod
// {
// GET request to retrieve the payment details of the provided Payment ID
// Below Request fetches the payment details of payment ID: 5319754772076048103525
private const string RequestTarget = "/pts/v2/payments/5526383152166546003003";
// private const string RequestTarget = "/pts/v2/payments/5526383152166546003003";

public static void WriteLogAudit(int status)
{
var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.');
var filename = filePath[filePath.Length - 1];
Console.WriteLine($"[Sample Code Testing] [{filename}] {status}");
}
//public static void WriteLogAudit(int status)
//{
// var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.');
// var filename = filePath[filePath.Length - 1];
// Console.WriteLine($"[Sample Code Testing] [{filename}] {status}");
//}

public static void Run()
{
try
{
//public static void Run()
//{
// try
// {
// Setting up Merchant Config
var merchantConfig = new MerchantConfig
{
RequestTarget = RequestTarget,
RequestType = Enumerations.RequestType.GET.ToString()
};
//var merchantConfig = new MerchantConfig
//{
// RequestTarget = RequestTarget,
// RequestType = Enumerations.RequestType.GET.ToString()
//};

// Call to the Controller of API_SDK
var apiController = new APIController(merchantConfig);
var response = apiController.GetPayment();
//var apiController = new APIController(merchantConfig);
//var response = apiController.GetPayment();

// printing the response details
if (response != null)
{
Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id"));
Console.WriteLine("\n Response Code:{0}", response.StatusCode);
Console.WriteLine("\n Response Message:{0}", response.Data);
WriteLogAudit(response.StatusCode);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
}
}
}
// if (response != null)
// {
// Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id"));
// Console.WriteLine("\n Response Code:{0}", response.StatusCode);
// Console.WriteLine("\n Response Message:{0}", response.Data);
// WriteLogAudit(response.StatusCode);
// }
// }
// catch (Exception e)
// {
// Console.WriteLine(e.Message);
// Console.WriteLine(e.StackTrace);
// }
// }
// }
//}
88 changes: 44 additions & 44 deletions Source/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
using System;
using ApiSdk.controller;
using AuthenticationSdk.core;
using AuthenticationSdk.util;
using SampleCode.data;
//using System;
//using ApiSdk.controller;
//using AuthenticationSdk.core;
//using AuthenticationSdk.util;
//using SampleCode.data;

namespace Cybersource_rest_samples_dotnet.Samples.Authentication
{
public class GetObjectMethod
{
//namespace Cybersource_rest_samples_dotnet.Samples.Authentication
//{
// public class GetObjectMethod
// {
// GET request to retrieve the payment details of the provided Payment ID
// Below Request fetches the payment details of payment ID: 5319754772076048103525
private const string RequestTarget = "/pts/v2/payments/5526478103126428303006";
//private const string RequestTarget = "/pts/v2/payments/5526478103126428303006";

public static void WriteLogAudit(int status)
{
var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.');
var filename = filePath[filePath.Length - 1];
Console.WriteLine($"[Sample Code Testing] [{filename}] {status}");
}
//public static void WriteLogAudit(int status)
//{
// var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.');
// var filename = filePath[filePath.Length - 1];
// Console.WriteLine($"[Sample Code Testing] [{filename}] {status}");
//}

public static void Run()
{
try
{
//public static void Run()
//{
// try
// {
// Creating a dictionary object which contains the merchant configuration
var config = new Configuration();
// var config = new Configuration();

// Passing the dictionary object to the Merchant Config Constructor to bypass the config set up via App.Config File
var merchantConfig = new MerchantConfig(config.GetConfiguration())
{
RequestTarget = RequestTarget,
RequestType = Enumerations.RequestType.GET.ToString()
};
//var merchantConfig = new MerchantConfig(config.GetConfiguration())
//{
// RequestTarget = RequestTarget,
// RequestType = Enumerations.RequestType.GET.ToString()
//};

// Call to the Controller of API_SDK
var apiController = new APIController(merchantConfig);
var response = apiController.GetPayment();
//var apiController = new APIController(merchantConfig);
//var response = apiController.GetPayment();

// printing the response details
if (response != null)
{
Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id"));
Console.WriteLine("\n Response Code:{0}", response.StatusCode);
Console.WriteLine("\n Response Message:{0}", response.Data);
WriteLogAudit(response.StatusCode);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
}
}
}
// if (response != null)
// {
// Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id"));
// Console.WriteLine("\n Response Code:{0}", response.StatusCode);
// Console.WriteLine("\n Response Message:{0}", response.Data);
// WriteLogAudit(response.StatusCode);
// }
// }
// catch (Exception e)
// {
// Console.WriteLine(e.Message);
// Console.WriteLine(e.StackTrace);
// }
// }
// }
//}
Loading