using System;
using System.Security.Cryptography;
using System.Text;

namespace csharp_clients
{
    class Program
    {
        //Test ClientNumber:
        public const int _clientNumber = 100000001; //!!!NOT FOR CUSTOMER TESTING, USE YOUR OWN, USE YOUR OWN!!!
        //Test username:
        public const string _username = "myglsapitest@test.mygls.hu"; //!!!NOT FOR CUSTOMER TESTING, USE YOUR OWN, USE YOUR OWN!!!
        //Test password:
        public const string _password = "1pImY_gls.hu"; //!!!NOT FOR CUSTOMER TESTING, USE YOUR OWN, USE YOUR OWN!!!

        static void Main(string[] args)
        {
            try
            {
                #region "SOAP EXAMPLES"
                
                #region "Parcel service"
                SoapClient.PrintLabels();
                SoapClient.GetPrintedLabels(SoapClient.PrepareLabels());
                SoapClient.GetParcelList();
                SoapClient.GetParcelStatuses();
                #endregion
                
                #endregion

                #region "REST EXAMPLES"
                bool isXmlFormat = false;

                #region "Parcel service"
                RestClient.ServiceName = "ParcelService";
                RestClient.PrintLabelsAsync(isXmlFormat).Wait(); //E.g. because of the HttpClient, this example is ASYNC.
                RestClient.GetPrintedLabelsAsync(RestClient.PrepareLabelsAsync(isXmlFormat).Result, isXmlFormat).Wait();
                RestClient.GetParcelListAsync(isXmlFormat).Wait();
                RestClient.GetParcelStatusesAsync(isXmlFormat).Wait();
                #endregion
                
                #endregion
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            Console.Read();
        }

        /// <summary>
        /// Because of the password encryption.
        /// </summary>
        /// <param name="input">input</param>
        /// <returns>The encrypted version of a string (e.g. the password).</returns>
        public static byte[] Sha512(string input)
        {
            using (SHA512 sha = new SHA512Managed())
            {
                return sha.ComputeHash(Encoding.UTF8.GetBytes(input));
            }
        }
    }
}
