/// <summary>
        /// Stazeni seznamu odeslanych SMS zprav
        /// </summary>
        public static List <OutgoingSms> GetOutgoingSmsList(int limit, LoginInfo loginInfo)
        {
            if (loginInfo == null)
            {
                throw new ArgumentNullException("loginInfo");
            }
            if (limit <= 0 || limit > 30)
            {
                throw new ArgumentOutOfRangeException("limit", "Hodnota musi byt vetsi nez 0 a mensi nebo rovna 30.");
            }

            string url = ApiXml20SenderUrl
                         .Replace("[login]", HttpUtility.UrlEncodeUnicode(loginInfo.Login))
                         .Replace("[password]", HttpUtility.UrlEncodeUnicode(loginInfo.Password))
                         .Replace("[count]", limit.ToString())
                         .Replace("[query]", "query_outgoing");

            // odeslani
            string resultString = Communicator.CallUrl(url, string.Empty, "GET", "text/html");
            var    doc          = XDocument.Parse(resultString);

            var result = new List <OutgoingSms>(limit);

            if (string.Equals(doc.Root.Name.LocalName, "messages", StringComparison.OrdinalIgnoreCase))
            {
                foreach (var messageEl in doc.Root.Elements("message"))
                {
                    var message = new OutgoingSms();
                    message.OutgoingSmsID = messageEl.Elements("id").FirstOrDefault().Value;
                    message.Text          = messageEl.Elements("text").FirstOrDefault().Value;
                    message.SendAt        = DateTime.ParseExact(messageEl.Elements("send_at").FirstOrDefault().Value, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
                    message.Recipient     = messageEl.Elements("recipient").FirstOrDefault().Value;

                    result.Add(message);
                }
            }

            return(result);
        }
        /// <summary>
        /// Odeslani SMS zpravy
        /// </summary>
        public static SendSmsResult SendSms(OutgoingSms sms, LoginInfo loginInfo)
        {
            if (sms == null)
            {
                throw new ArgumentNullException("message");
            }
            if (loginInfo == null)
            {
                throw new ArgumentNullException("loginInfo");
            }

            #region pozadavek
            var doc    = new XDocument();
            var rootEl = new XElement("outgoing_message");
            doc.Add(rootEl);

            if (sms.RequireDeliveryReport.HasValue)
            {
                if (sms.RequireDeliveryReport == true)
                {
                    rootEl.Add(new XElement("dr_request", "20"));
                }
                else
                {
                    rootEl.Add(new XElement("dr_request", "0"));
                }
            }

            rootEl.Add(new XElement("text", new XCData(sms.Text)));
            rootEl.Add(new XElement("recipient", sms.Recipient));

            if (sms.SendAt.HasValue)
            {
                rootEl.Add(new XElement("send_at", sms.SendAt.Value.ToString("yyyyMMddHHmmss")));
            }

            var sb = new StringBuilder();
            using (var sw = new StringWriterUtf8(sb))
            {
                doc.Save(sw);
            }
            #endregion

            string url = ApiXml20RecieverUrl
                         .Replace("[login]", HttpUtility.UrlEncodeUnicode(loginInfo.Login))
                         .Replace("[password]", HttpUtility.UrlEncodeUnicode(loginInfo.Password))
                         .Replace("[affiliate]", loginInfo.Affiliate);

            // odeslani
            string resultString = Communicator.CallUrl(url, sb.ToString(), "POST", "text/xml");

            #region zpracovani odpovedi
            var result = new SendSmsResult()
            {
                Status = SendSmsResultStatus.OK, StatusDescription = "OK"
            };
            result.Message = sms;

            doc = XDocument.Parse(resultString);
            // chyba
            if (string.Equals(doc.Root.Name.LocalName, "messages", StringComparison.OrdinalIgnoreCase))
            {
                var messageEl = doc.Root.Elements("message").First();

                result.Message.OutgoingSmsID = messageEl.Elements("id").FirstOrDefault().Value;
                result.Message.Text          = messageEl.Elements("text").FirstOrDefault().Value;
                result.Message.SendAt        = DateTime.ParseExact(messageEl.Elements("send_at").FirstOrDefault().Value, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
                result.Message.Recipient     = messageEl.Elements("recipient").FirstOrDefault().Value;

                result.Parts  = int.Parse(messageEl.Elements("parts").FirstOrDefault().Value);
                result.Price  = decimal.Parse(messageEl.Elements("price").FirstOrDefault().Value, CultureInfo.GetCultureInfo(2057));
                result.Credit = decimal.Parse(doc.Root.Elements("credit").First().Value, CultureInfo.GetCultureInfo(2057));
            }
            else
            {
                result.StatusDescription = doc.Root.Elements("message").First().Value;
                switch (doc.Root.Elements("id").First().Value)
                {
                case "400;1":
                    result.Status = SendSmsResultStatus.InvalidMsisdn;
                    break;

                case "400;2":
                    result.Status = SendSmsResultStatus.InvalidText;
                    break;

                case "400":
                    result.Status = SendSmsResultStatus.InvalidAction;
                    break;

                case "401":
                    result.Status = SendSmsResultStatus.InvalidLogin;
                    break;

                case "402":
                    result.Status = SendSmsResultStatus.LowCredit;
                    break;

                case "500":
                    result.Status = SendSmsResultStatus.GatewayError;
                    break;

                default:
                    break;
                }
            }
            #endregion

            return(result);
        }