/// <summary>
        /// This function creates an invoice link based on the given parameters as an invoice from the program
        /// </summary>
        /// <param name="invoice">All paramters that are related to invoice</param>
        /// <returns>Link to the invoice of SADDED. The customer should be redirected to this link.</returns>
        public InvoiceResponse createInvoiceLink(CreateInvoiceRequest invoice)
        {
            SetEssentialParameters(invoice);
            InvoiceResponse validationResponse = IsValidCreateInvoiceLinkRequest(invoice);

            if (validationResponse.ErrorCode == 0)
            {
                string uri      = _url + EndPoints.InvoiceCreate;
                string response = HttpPost(uri, JsonConvert.SerializeObject(invoice));
                return(JsonConvert.DeserializeObject <InvoiceResponse>(response));
            }
            return(validationResponse);
        }
        /// <summary>
        /// This function validates invoice create request
        /// </summary>
        /// <param name="invoice">All paramters that are related to invoice</param>
        /// <returns>InvoiceResponse containing error messages if any</returns>
        private InvoiceResponse IsValidCreateInvoiceLinkRequest(CreateInvoiceRequest invoice)
        {
            List <string> listOfErrors = new List <string>();

            if (invoice.Amount <= 0)
            {
                listOfErrors.Add("Amount must be greater than zero");
            }

            if (invoice.Date == DateTime.MinValue)
            {
                listOfErrors.Add("Date is missing");
            }

            if (string.IsNullOrEmpty(invoice.Email) && invoice.NotificationMode.Equals((int)NotificationMode.Email))
            {
                listOfErrors.Add("Email is missing");
            }

            if (!string.IsNullOrEmpty(invoice.Email))
            {
                MailAddress mailAddress = new MailAddress(invoice.Email);
                if (mailAddress.Address != invoice.Email && invoice.NotificationMode.Equals((int)NotificationMode.Email))
                {
                    listOfErrors.Add("Email address is invalid");
                }
            }
            if (string.IsNullOrEmpty(invoice.Msisdn) && invoice.NotificationMode.Equals((int)NotificationMode.SMS))
            {
                listOfErrors.Add("Msisdn is missing");
            }

            if (invoice.NotificationMode.Equals((int)NotificationMode.Online) && string.IsNullOrEmpty(invoice.Msisdn) && string.IsNullOrEmpty(invoice.Email))
            {
                listOfErrors.Add("Msisdn or Email is missing");
            }

            if (string.IsNullOrEmpty(invoice.CustomerName))
            {
                listOfErrors.Add("CustomerName is missing");
            }

            if (invoice.NotificationMode.Equals((int)NotificationMode.Online))
            {
                if (string.IsNullOrEmpty(invoice.SuccessUrl))
                {
                    listOfErrors.Add("SuccessUrl is missing");
                }
                if (string.IsNullOrEmpty(invoice.ErrorUrl))
                {
                    listOfErrors.Add("ErrorUrl is missing");
                }
            }

            InvoiceResponse validationResponse = new InvoiceResponse()
            {
                ErrorCode = 0
            };

            if (listOfErrors.Count != 0)
            {
                validationResponse.ErrorCode    = 102; // missing parameters error code
                validationResponse.ErrorMessage = string.Join(" | ", listOfErrors.ToArray());
            }

            return(validationResponse);
        }