/// <summary>
        /// Send Method to be called by Tenant.
        /// </summary>
        /// <param name="request">Request that is passed by Tenant.</param>
        /// <returns>Return the Request Acceptance Message alogn with the EI IDto Tenant.</returns>
        public AzureTBNService.EmailInterchangeResponseToken SendV2(AzureTBNService.RequestBase request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(ErrorExceptionMessagePredicate + RequestNullException);
            }

            AzureTBNService.EmailInterchangeResponseToken emailInterchangeResponseToken = new AzureTBNService.EmailInterchangeResponseToken();
            try
            {
                emailInterchangeResponseToken = CallSend(request, PrimaryEndpoint);
            }
            catch (Exception)
            {
                emailInterchangeResponseToken = CallSend(request, SecondaryEndpoint);
            }
            return(emailInterchangeResponseToken);
        }
        /// <summary>
        /// Method for Calling the Azure(Primary/Secondary) Endpoint.
        /// </summary>
        /// <param name="request">Request that is passed by Tenant.</param>
        /// <param name="endpointName">Azure endpoint to be used((Primary/Secondary).</param>
        /// <returns>Returns the Request Acceptance Message along with the EI ID to Calling method.</returns>
        internal AzureTBNService.EmailInterchangeResponseToken CallSend(AzureTBNService.RequestBase request, string endpointName)
        {
            int exceptionCount = 0;

            AzureTBNService.EmailInterchangeResponseToken emailInterchangeResponseToken = new AzureTBNService.EmailInterchangeResponseToken();
            emailInterchangeResponseToken.Result = AzureTBNService.EmailInterchangeResult.UnknownFailure;

            AzureTBNService.TriggerRequestNotificationClient client = null;
            for (int retryCount = 0; retryCount < retryAttempts; retryCount++)
            {
                try
                {
                    using (client = new AzureTBNService.TriggerRequestNotificationClient(endpointName))
                    {
                        emailInterchangeResponseToken = client.SendV2(request);
                    }

                    if (emailInterchangeResponseToken.Result != AzureTBNService.EmailInterchangeResult.UnknownFailure)
                    {
                        return(emailInterchangeResponseToken);
                    }
                }

                catch (Exception ex)
                {
                    if (client == null)
                    {
                        throw;
                    }

                    exceptionCount++;

                    // Throw exception if maxm retry attempts are exhausted
                    if (exceptionCount == retryAttempts)
                    {
                        throw new Exception(GenericExceptionMessagePredicate + ex.Message.ToString());
                    }
                }
            }
            return(emailInterchangeResponseToken);
        }
 /// <summary>
 /// Send Method to be called by Tenant.
 /// </summary>
 /// <param name="request">Request that is passed by Tenant.</param>
 /// <returns>Return the Request Acceptance Message to Tenant.</returns>
 public AzureTBNService.EmailInterchangeResult Send(AzureTBNService.RequestBase request)
 {
     AzureTBNService.EmailInterchangeResponseToken emailInterchangeResponseToken = new AzureTBNService.EmailInterchangeResponseToken();
     emailInterchangeResponseToken = this.SendV2(request);
     return(emailInterchangeResponseToken.Result);
 }