Esempio n. 1
0
        public void user_id(string cmd)
        {
            PanXmlApiResponse response;

            lock (client) response = new PanXmlApiResponse(client.DownloadString(string.Format(@"https://{0}/api/?type=user-id&key={1}&cmd={2}", address, key, WebUtility.UrlEncode(cmd))));
            validateResponse(response);
        }
Esempio n. 2
0
        private string keygen()
        {
            PanXmlApiResponse response;

            lock (client) response = new PanXmlApiResponse(client.DownloadString(string.Format(@"https://{0}/api/?type=keygen&user={1}&password={2}", address, username, WebUtility.UrlEncode(password))));
            validateResponse(response);
            return(response.Key);
        }
Esempio n. 3
0
        private void validateResponse(PanXmlApiResponse response)
        {
            var status = response.Status;

            if (status == null)
            {
                throw new PanXmlApiException("null", "Invalid response received. Raw response data: " + response);
            }
            else if (status.Equals("success"))
            {
                return;
            }
            else if (status.Equals("error"))
            {
                throw new PanXmlApiException(response.Code, response.Msg);
            }
            else
            {
                throw new PanXmlApiException(response.Status, "Unknown response status (" + response.Status + ") received. Raw response data: " + response);
            }
        }