public async Task <string> GenerateApiKey(string environment, string username, string password)
        {
            GenerateApiKeyResponse response = null;

            try
            {
                response = await soapClient.GenerateApiKeyAsync(environment, username, password);
            }
            catch (Exception e)
            {
                return("Error! Cannot connect to CHILI server");
            }

            if (response != null)
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(response.Body.GenerateApiKeyResult);

                if (xmlDocument.FirstChild.Attributes["succeeded"] != null && xmlDocument.FirstChild.Attributes["succeeded"].Value == "true")
                {
                    return(xmlDocument.FirstChild.Attributes["key"].Value);
                }
                else
                {
                    return("Error! API key has wrong credentials");
                }
            }

            return(null);
        }
        private async void MaterializeSuccessfulResponse(GenerateApiKeyResponse response, HttpResponseMessage httpResponse)
        {
            if (response.RequestMethod != HttpMethod.Post)
                throw new ArgumentException(GetType().Name + " only supports materializing POST responses.");

            using (var content = await httpResponse.Content.ReadAsStreamAsync().ForAwait())
            {
                Serializer.Populate(response, content);
            }
        }
        private async Task MaterializeSuccessfulResponseAsync(GenerateApiKeyResponse response, HttpResponseMessage httpResponse)
        {
            if (response.RequestMethod != HttpMethod.Post)
            {
                throw new ArgumentException(GetType().Name + " only supports materializing POST responses.");
            }

            using (var content = await httpResponse.Content.ReadAsStreamAsync().ForAwait())
            {
                Serializer.Populate(response, content);
            }
        }
Example #4
0
 public static GenerateApiKeyResponseAssertions Should(this GenerateApiKeyResponse response)
 {
     return(new GenerateApiKeyResponseAssertions(response));
 }