C#

Features ›› Reference Data ›› getCurrencyList ›› Sample Code ››
Parent Previous Next

Get Currency List



1. productTypes.cs



These four packages are required to be used.






Step 1. Create class file to store content of the web response.

Note: All reference data classes are written in a single class file "productTypes.cs".






2. Utility.cs


These 13 packages are required to be used.





Step 2 - 4. Create URL which will be post to the server. In this function, only header is needed.

            Post to  the server, and store response. URL is sent using web request function, and a response will be send back from the server. The response need to be deserialized into the ‘getCurrencyList’ class.

            Store all the currency Currency in variable 'p' and return 'p'.






Overview of productTypes.cs



using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;


namespace Demo

{

   public class productTypes

   {

       public productTypesContent Content { get; set; }

   }


   public class productTypesContent

   {

       public productTypesServiceResponse ServiceResponse { get; set; }

   }


   public class productTypesServiceResponse

   {

       public ProductList ProductList { get; set; }

       public productTypesServiceRespHeader ServiceRespHeader { get; set; }

   }


   public class productTypesServiceRespHeader

   {

       public object ErrorDetails { get; set; }

       public string ErrorText { get; set; }

       public string GlobalErrorID { get; set; }

   }


   public class ProductList

   {

       public List<productTypesProduct> Product { get; set; }

   }


   public class productTypesProduct

   {

       public string ProductID { get; set; }

       public string ProductName { get; set; }

   }


   //Transaction types

   public class TransactionTypes

   {

       public transacContent Content { get; set; }

   }


   public class transacContent

   {

       public transacServiceResponse ServiceResponse { get; set; }

   }


   public class transacServiceResponse

   {

       public transacServiceRespHeader ServiceRespHeader { get; set; }

       public transacTransactionTypeList TransactionTypeList { get; set; }

   }


   public class transacTransactionTypeList

   {

       public List<transacTransactionType> TransactionType { get; set; }

   }


   public class transacTransactionType

   {

       public string TransactionCode { get; set; }

       public string TransactionTypeID { get; set; }

       public string TransactionTypeName { get; set; }

   }


   public class transacServiceRespHeader

   {

       public object ErrorDetails { get; set; }

       public string ErrorText { get; set; }

       public string GlobalErrorID { get; set; }

   }


   //customer types

   public class CustomerTypes

   {

       public custContent Content { get; set; }

   }


   public class custContent

   {

       public custServiceResponse ServiceResponse { get; set; }

   }


   public class custServiceResponse

   {

       public CustomerTypeList CustomerTypeList { get; set; }

       public custServiceRespHeader ServiceRespHeader { get; set; }

   }


   public class custServiceRespHeader

   {

       public object ErrorDetails { get; set; }

       public string ErrorText { get; set; }

       public string GlobalErrorID { get; set; }

   }


   public class CustomerTypeList

   {

       public List<CustomerType> CustomerType { get; set; }

   }


   public class CustomerType

   {

       public string CustomerTypeID { get; set; }

       public string CustomerTypeName { get; set; }

   }


   //get billing organizations name

   public class GetBillingOrganizations

   {

       public boContent Content { get; set; }

   }


   public class boContent

   {

       public boServiceResponse ServiceResponse { get; set; }

   }


   public class boServiceResponse

   {

       public BillingOrgList BillingOrgList { get; set; }

       public boServiceRespHeader ServiceRespHeader { get; set; }

   }


   public class boServiceRespHeader

   {

       public object ErrorDetails { get; set; }

       public string ErrorText { get; set; }

       public string GlobalErrorID { get; set; }

   }


   public class BillingOrgList

   {

       public List<BillingOrg> BillingOrg { get; set; }

   }


   public class BillingOrg

   {

       public string AccountID { get; set; }

       public string BeneficiaryID { get; set; }

       public string BillingOrgName { get; set; }

   }


   //getAffinityList

   public class getAffinityListRootObject

   {

       public getAffinityListContent Content { get; set; }

   }

   public class getAffinityListContent

   {

       public getAffinityListServiceResponse ServiceResponse { get; set; }

   }

   public class getAffinityListServiceResponse

   {

       public getAffinityListAffinityList AffinityList { get; set; }

       public getAffinityListServiceRespHeader ServiceRespHeader { get; set; }

   }

   public class getAffinityListAffinity

   {

       public string AffinityID { get; set; }

       public string Level1 { get; set; }

       public string Level2 { get; set; }

   }


   public class getAffinityListAffinityList

   {

       public List<getAffinityListAffinity> Affinity { get; set; }

   }


   public class getAffinityListServiceRespHeader

   {

       public object ErrorDetails { get; set; }

       public string ErrorText { get; set; }

       public string GlobalErrorID { get; set; }

   }


   //getCurrencyList

   public class getCurrencyListRootObject

   {

       public getCurrencyListContent Content { get; set; }

   }

   public class getCurrencyListContent

   {

       public getCurrencyListServiceResponse ServiceResponse { get; set; }

   }

   public class getCurrencyListServiceResponse

   {

       public getCurrencyListCurrencyList CurrencyList { get; set; }

       public getCurrencyListServiceRespHeader ServiceRespHeader { get; set; }

   }

   public class getCurrencyListCurrency

   {

       public string CountryName { get; set; }

       public string CurrencyCode { get; set; }

       public string CurrencyName { get; set; }

   }


   public class getCurrencyListCurrencyList

   {

       public List<getCurrencyListCurrency> Currency { get; set; }

   }


   public class getCurrencyListServiceRespHeader

   {

       public object ErrorDetails { get; set; }

       public string ErrorText { get; set; }

       public string GlobalErrorID { get; set; }

   }

}



You can download "productTypes.cs" below.



productTypes.cs



Overview of Utility.cs


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using DotNetOpenAuth.OAuth2;

using Newtonsoft.Json;

using Newtonsoft.Json.Linq;

using System.Collections.Specialized;

using System.Configuration;

using System.Net;

using System.IO;

using System.Windows.Forms;

using System.Data;

using Microsoft.VisualBasic;


namespace Demo

{

   public class utilities

   {

       

       public static string newOTP()

       {

           string otp;

           otp = Interaction.InputBox("New OTP has been send, please enter new OTP.", "OTP Expired", "", -1, -1);

           return otp;

       }

       

       public static List<productTypesProduct> getProductTypes()

       {

           var ProductType = new HeaderJson();

           ProductType.serviceName = "getProductTypes";

           var headerObj = new HeaderJsonObject();

           headerObj.Header = ProductType;

           string header = JsonConvert.SerializeObject(headerObj);

           string url = "http://tbankonline.com/SMUtBank_API/Gateway?Header=" + header;

           var webRequest = (HttpWebRequest)WebRequest.Create(url);

           webRequest.ContentType = "application/json";

           webRequest.Method = "POST";

           var result = "";

           var httpResponse = (HttpWebResponse)webRequest.GetResponse();

           using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))

           {

               result = streamReader.ReadToEnd();

           }

           productTypes t = new productTypes();

           t = JsonConvert.DeserializeObject<productTypes>(result);


           var p = t.Content.ServiceResponse.ProductList.Product;


           return p;

       }


       public static List<transacTransactionType> getTransactionTypes()

       {

           var ProductType = new HeaderJson();

           ProductType.serviceName = "getTransactionTypes";

           var headerObj = new HeaderJsonObject();

           headerObj.Header = ProductType;

           string header = JsonConvert.SerializeObject(headerObj);

           string url = "http://tbankonline.com/SMUtBank_API/Gateway?Header=" + header;

           var webRequest = (HttpWebRequest)WebRequest.Create(url);

           webRequest.ContentType = "application/json";

           webRequest.Method = "POST";

           var result = "";

           var httpResponse = (HttpWebResponse)webRequest.GetResponse();

           using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))

           {

               result = streamReader.ReadToEnd();

           }

           TransactionTypes t = new TransactionTypes();

           t = JsonConvert.DeserializeObject<TransactionTypes>(result);


           var p = t.Content.ServiceResponse.TransactionTypeList.TransactionType;


           return p;

       }


       public static List<CustomerType> getCustomerTypes()

       {

           var ProductType = new HeaderJson();

           ProductType.serviceName = "getCustomerTypes";

           var headerObj = new HeaderJsonObject();

           headerObj.Header = ProductType;

           string header = JsonConvert.SerializeObject(headerObj);

           string url = "http://tbankonline.com/SMUtBank_API/Gateway?Header=" + header;

           var webRequest = (HttpWebRequest)WebRequest.Create(url);

           webRequest.ContentType = "application/json";

           webRequest.Method = "POST";

           var result = "";

           var httpResponse = (HttpWebResponse)webRequest.GetResponse();

           using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))

           {

               result = streamReader.ReadToEnd();

           }

           CustomerTypes t = new CustomerTypes();

           t = JsonConvert.DeserializeObject<CustomerTypes>(result);


           var p = t.Content.ServiceResponse.CustomerTypeList.CustomerType;


           return p;

       }


       public static List<BillingOrg> getBillingOrganizations()

       {

           var ProductType = new HeaderJson();

           ProductType.serviceName = "getBillingOrganizations";

           var headerObj = new HeaderJsonObject();

           headerObj.Header = ProductType;

           string header = JsonConvert.SerializeObject(headerObj);

           string url = "http://tbankonline.com/SMUtBank_API/Gateway?Header=" + header;

           var webRequest = (HttpWebRequest)WebRequest.Create(url);

           webRequest.ContentType = "application/json";

           webRequest.Method = "POST";

           var result = "";

           var httpResponse = (HttpWebResponse)webRequest.GetResponse();

           using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))

           {

               result = streamReader.ReadToEnd();

           }

           GetBillingOrganizations t = new GetBillingOrganizations();

           t = JsonConvert.DeserializeObject<GetBillingOrganizations>(result);


           var p = t.Content.ServiceResponse.BillingOrgList.BillingOrg;


           return p;

       }


       public static List<getAffinityListAffinity> getAffinityList()

       {

           var ProductType = new HeaderJson();

           ProductType.serviceName = "getAffinityList";

           var headerObj = new HeaderJsonObject();

           headerObj.Header = ProductType;

           string header = JsonConvert.SerializeObject(headerObj);

           string url = "http://tbankonline.com/SMUtBank_API/Gateway?Header=" + header;

           var webRequest = (HttpWebRequest)WebRequest.Create(url);

           webRequest.ContentType = "application/json";

           webRequest.Method = "POST";

           var result = "";

           var httpResponse = (HttpWebResponse)webRequest.GetResponse();

           using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))

           {

               result = streamReader.ReadToEnd();

           }

           getAffinityListRootObject t = new getAffinityListRootObject();

           t = JsonConvert.DeserializeObject<getAffinityListRootObject>(result);


           var p = t.Content.ServiceResponse.AffinityList.Affinity;


           return p;

       }


       public static List<getCurrencyListCurrency> getCurrencyList()

       {

           var ProductType = new HeaderJson();

           ProductType.serviceName = "getCurrencyList";

           var headerObj = new HeaderJsonObject();

           headerObj.Header = ProductType;

           string header = JsonConvert.SerializeObject(headerObj);

           string url = "http://tbankonline.com/SMUtBank_API/Gateway?Header=" + header;

           var webRequest = (HttpWebRequest)WebRequest.Create(url);

           webRequest.ContentType = "application/json";

           webRequest.Method = "POST";

           var result = "";

           var httpResponse = (HttpWebResponse)webRequest.GetResponse();

           using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))

           {

               result = streamReader.ReadToEnd();

           }

           getCurrencyListRootObject t = new getCurrencyListRootObject();

           t = JsonConvert.DeserializeObject<getCurrencyListRootObject>(result);


           var p = t.Content.ServiceResponse.CurrencyList.Currency;


           return p;

       }

   }

}



Download



Created with the Personal Edition of HelpNDoc: What is a Help Authoring tool?