new public static CustomerGetResponse Parse(XElement message)
        {
            CustomerGetResponse result = new CustomerGetResponse();

            result.Status    = message.Descendants("status").FirstOrDefault().Value.Equals("ok", StringComparison.OrdinalIgnoreCase) ? PleskApiResponseStatus.Ok : PleskApiResponseStatus.Error;
            result.ErrorCode = message.Descendants("errcode").FirstOrDefault()?.Value;
            result.ErrorText = message.Descendants("errtext").FirstOrDefault()?.Value;

            if (result.Status == PleskApiResponseStatus.Ok)
            {
                if (message.Descendants("data").Any())
                {
                    if (message.Descendants("result").Any())
                    {
                        result.Customers = message.Descendants("result")
                                           .Where(r => r.Descendants("gen_info").Any())
                                           .Select(r => Customer.FromXml(r.Descendants("gen_info").FirstOrDefault().Descendants().ToList()))
                                           .ToList();
                    }

                    result.CustomerId   = Convert.ToInt32(message.Descendants("id").FirstOrDefault()?.Value);
                    result.CustomerGuid = message.Descendants("guid").FirstOrDefault()?.Value;
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The get operation is used to retrieve all customers accounts settings from the database.
        /// </summary>
        /// <returns></returns>
        public CustomerGetResponse Get()
        {
            XElement message =
                new XElement("customer",
                             new XElement("get",
                                          new XElement("filter"),
                                          new XElement("dataset",
                                                       new XElement("gen_info"),
                                                       new XElement("stat")
                                                       )
                                          )
                             );

            return(CustomerGetResponse.Parse(ApiHttpClient.SendPacket(message)));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The get operation is used to retrieve customer account settings from the database.
        /// </summary>
        /// <param name="id">Specifies ID of a customer account.</param>
        /// <param name="login">Specifies login name of a customer account.</param>
        /// <param name="ownerId">Specifies ID of a customer account owner.</param>
        /// <param name="ownerLogin">Specifies login name of a customer account owner.</param>
        /// <param name="guid">Specifies the GUID of a customer account. For details on GUIDs, refer to the API RPC Protocol > GUIDs Overview section of Plesk API RPC Developer's Guide.</param>
        /// <param name="getGenInfo">Need to request for the general customer account settings.</param>
        /// <param name="getStat">Need to request statistics on the specified customers.</param>
        /// <returns></returns>
        public CustomerGetResponse Get(int?id = null, string login = null, int?ownerId = null, string ownerLogin = null, string guid = null, bool getGenInfo = true, bool getStat = false)
        {
            XElement message =
                new XElement("customer",
                             new XElement("get",
                                          new XElement("filter",
                                                       id.HasValue ?                            new XElement("id", id.Value) : null,
                                                       !String.IsNullOrWhiteSpace(login) ?      new XElement("login", login) : null,
                                                       ownerId.HasValue ?                       new XElement("owner-id", ownerId) : null,
                                                       !String.IsNullOrWhiteSpace(ownerLogin) ? new XElement("owner-login", ownerLogin) : null,
                                                       !String.IsNullOrWhiteSpace(guid) ?       new XElement("guid", guid) : null
                                                       ),
                                          new XElement("dataset",
                                                       getGenInfo ?    new XElement("gen_info") : null,
                                                       getStat ?       new XElement("stat") : null
                                                       )
                                          )
                             );

            return(CustomerGetResponse.Parse(ApiHttpClient.SendPacket(message)));
        }
Ejemplo n.º 4
0
        public CustomerGetResponse CustomerGet(string login = "")
        {
            XElement message = new XElement("packet",
                                            new XAttribute("version", "1.6.7.0"),
                                            new XElement("customer",
                                                         new XElement("get",
                                                                      new XElement("filter",
                                                                                   new XElement("login", login)
                                                                                   ),
                                                                      new XElement("dataset",
                                                                                   new XElement("gen_info")
                                                                                   )
                                                                      )
                                                         )
                                            );

            HttpWebRequest request = ApiHttpClient.Request(message);
            XElement       resp    = ApiHttpClient.GetResponse(request);

            return(CustomerGetResponse.Parse(resp));
        }
Ejemplo n.º 5
0
        public bool CustomerIsExist(string email)
        {
            CustomerGetResponse resp = CustomerGet(email);

            return(resp.Status == PleskApiResponseStatus.Ok);
        }