////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>Constructor</summary>
        /// <param name="enumTangoCardServiceApi">The enum tango card service api.</param>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public Version2_Request(
            TangoCardServiceApiEnum enumTangoCardServiceApi,
            string username, 
            string password
        )
            : base(enumTangoCardServiceApi)
        {
            // -----------------------------------------------------------------
            // validate inputs
            // -----------------------------------------------------------------

            // username
            if (String.IsNullOrEmpty(username))
            {
                throw new ArgumentNullException(paramName: "username" );
            }

            // password
            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException(paramName: "password" );
            }

            this.Username = username;
            this.Password = password;
        }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>   Constructor. </summary>
 ///
 /// <param name="enumTangoCardServiceApi">  The enum tango card service api. </param>
 /// <param name="username">                 The username. </param>
 /// <param name="password">                 The password. </param>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public Version2_GetAvailableBalance_Request(
     TangoCardServiceApiEnum enumTangoCardServiceApi,
     string username, 
     string password
     )
     : base(enumTangoCardServiceApi, username, password)
 {
 }
        public void TestInitialize_PurchaseCard()
        {
            this._app_username = ConfigurationManager.AppSettings["app_username"];
            this._app_password = ConfigurationManager.AppSettings["app_password"];

            string app_tc_sdk_environment = ConfigurationManager.AppSettings["app_tc_sdk_environment"];
            this._enumTangoCardServiceApi = (TangoCardServiceApiEnum)Enum.Parse(typeof(TangoCardServiceApiEnum), app_tc_sdk_environment);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Gets an available balance. </summary>
        ///
        /// <param name="enumTangoCardServiceApi">  The enum tango card service api. </param>
        /// <param name="username">                 The username. </param>
        /// <param name="password">                 The password. </param>
        /// <param name="response">                 [out] The response. </param>
        ///
        /// <returns>   true if it succeeds, false if it fails. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public static bool GetAvailableBalance(
           TangoCardServiceApiEnum enumTangoCardServiceApi,
           string username,
           string password,
           out Version2_GetAvailableBalance_Response response
           )
        {
            // set up the request
            var request = new Version2_GetAvailableBalance_Request
            (
                enumTangoCardServiceApi: enumTangoCardServiceApi,
                username: String.IsNullOrEmpty(username) ? null : username.Trim(),
                password: password
            );

            // make the request
            return request.Execute(out response);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Purchase card. </summary>
        ///
        /// <param name="enumTangoCardServiceApi">  The enum tango card service api. </param>
        /// <param name="username">                 The username. </param>
        /// <param name="password">                 The password. </param>
        /// <param name="cardSku">                  The card sku. </param>
        /// <param name="cardValue">                The card value. </param>
        /// <param name="tcSend">                   Determines if Tango Card Service will send an email with gift card information to recipient. </param>
        /// <param name="recipientName">            Name of the recipient. </param>
        /// <param name="recipientEmail">           The recipient email. </param>
        /// <param name="giftMessage">              Message describing the gift. </param>
        /// <param name="giftFrom">                 The gift from. </param>
        /// <param name="companyIdentifier">        (optional) The Company identifier for which Email Template to use when sending Gift Card. </param>
        /// <param name="response">                 [out] The response. </param>
        ///
        /// <returns>   true if it succeeds, false if it fails. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public static bool PurchaseCard(
            TangoCardServiceApiEnum enumTangoCardServiceApi,
            string username,
            string password,
            string cardSku,
            int cardValue,
            bool tcSend,
            string recipientName,
            string recipientEmail,
            string giftMessage,
            string giftFrom,
            string companyIdentifier,
            out Version2_PurchaseCard_Response response
            )
        {
            // set up the request
            var request = new Version2_PurchaseCard_Request
            (
                enumTangoCardServiceApi: enumTangoCardServiceApi,
                username:       String.IsNullOrEmpty(username) ? null : username.Trim(),
                password:       password,
                cardSku:        cardSku.Trim(),
                cardValue:      cardValue,
                tcSend:         tcSend,
                recipientName:  String.IsNullOrEmpty(recipientName)         ? null : recipientName.Trim(),
                recipientEmail: String.IsNullOrEmpty(recipientEmail)        ? null : recipientEmail.Trim(),
                giftMessage:    String.IsNullOrEmpty(giftMessage)           ? null : giftMessage.Trim().Replace(System.Environment.NewLine, "<br>"),
                giftFrom:       String.IsNullOrEmpty(giftFrom)              ? null : giftFrom.Trim(),
                companyIdentifier: String.IsNullOrEmpty(companyIdentifier)  ? null : companyIdentifier.Trim()
            );

            // make the request
            return request.Execute(out response);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Constructor. </summary>
        ///
        /// <exception cref="ArgumentNullException">    Thrown when one or more required arguments are
        ///                                             null. </exception>
        /// <exception cref="ArgumentException">        Thrown when one or more arguments have
        ///                                             unsupported or illegal values. </exception>
        ///
        /// <param name="enumTangoCardServiceApi">  The enum tango card service api. </param>
        /// <param name="username">                 The username. </param>
        /// <param name="password">                 The password. </param>
        /// <param name="cardSku">                  The card sku. </param>
        /// <param name="cardValue">                The card value. </param>
        /// <param name="tcSend">                   Determines if Tango Card Service will send an email with gift card information to recipient. </param>
        /// <param name="recipientName">            (optional) The name of the recipient. </param>
        /// <param name="recipientEmail">           (optional) The recipient email. </param>
        /// <param name="giftMessage">              (optional) The gift message. </param>
        /// <param name="giftFrom">                 (optional) The gift from. </param>
        /// <param name="companyIdentifier">        (optional) The Company identifier for which Email Template to use when sending Gift Card. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        public Version2_PurchaseCard_Request(
            TangoCardServiceApiEnum enumTangoCardServiceApi,
            string username,
            string password,
            string cardSku,
            int cardValue,
            bool tcSend = false,
            string recipientName = null,
            string recipientEmail = null,
            string giftMessage = null,
            string giftFrom = null,
            string companyIdentifier = null
            )
            : base(enumTangoCardServiceApi, username, password)
        {
            // -----------------------------------------------------------------
            // validate inputs
            // -----------------------------------------------------------------

            // cardSku
            if (String.IsNullOrEmpty(cardSku))
            {
                throw new ArgumentNullException(paramName: "cardSku");
            }
            if (cardSku.Length < 1)
            {
                throw new ArgumentException(message: "Parameter 'cardSku' must have a length greater than zero.");
            }
            if (cardSku.Length > 255)
            {
                throw new ArgumentException(message: "Parameter 'cardSku' must have a length less than 255.");
            }

            // cardValue
            if (cardValue < 1)
            {
                throw new ArgumentException(message: "Parameter 'cardValue' must have a value which is greater than or equal to 1.");
            }

            if (tcSend)
            {
                // recipientName
                if (String.IsNullOrEmpty(recipientName))
                {
                    throw new ArgumentNullException(paramName: "recipientName");
                }
                if (recipientName.Length < 1)
                {
                    throw new ArgumentException(message: "Parameter 'recipientName' must have a length greater than zero.");
                }
                if (recipientName.Length > 255)
                {
                    throw new ArgumentException(message: "Parameter 'recipientName' must have a length less than 256.");
                }

                // recipientEmail
                if (String.IsNullOrEmpty(recipientEmail))
                {
                    throw new ArgumentNullException(paramName: "recipientEmail");
                }
                if (recipientEmail.Length < 3)
                {
                    throw new ArgumentException(message: "Parameter 'recipientEmail' must have a length greater than two.");
                }
                if (recipientEmail.Length > 255)
                {
                    throw new ArgumentException(message: "Parameter 'recipientEmail' must have a length less than 256.");
                }

                // giftFrom
                if (String.IsNullOrEmpty(giftFrom))
                {
                    throw new ArgumentNullException(paramName: "giftFrom");
                }
                if (giftFrom.Length < 1)
                {
                    throw new ArgumentException(message: "Parameter 'giftFrom' must have a length greater than zero.");
                }
                if (giftFrom.Length > 255)
                {
                    throw new ArgumentException(message: "Parameter 'giftFrom' must have a length less than 256.");
                }

                // giftMessage
                if (!String.IsNullOrEmpty(giftMessage))
                {
                    if (giftMessage.Length > 255)
                    {
                        throw new ArgumentException(message: "Parameter 'giftMessage' must have a length less than 256.");
                    }
                }

                // companyIdentifier
                if (!String.IsNullOrEmpty(companyIdentifier))
                {
                    if (companyIdentifier.Length > 255)
                    {
                        throw new ArgumentException(message: "Parameter 'companyIdentifier' must have a length less than 256.");
                    }
                }
            }

            // -----------------------------------------------------------------
            // save inputs
            // -----------------------------------------------------------------

            this.CardSku = cardSku;
            this.CardValue = cardValue;
            this.TcSend    = tcSend;
            if (tcSend) {
                this.RecipientName  = recipientName;
                this.RecipientEmail = recipientEmail;
                this.GiftFrom       = giftFrom;
                if (!String.IsNullOrEmpty(giftMessage))
                {
                    this.GiftMessage = giftMessage;
                }
                if (!String.IsNullOrEmpty(companyIdentifier))
                {
                    this.CompanyIdentifier = companyIdentifier;
                }
            }
        }