/// <summary>
 /// Invokes a service request asyncronously
 /// </summary>
 /// <param name="request">Instance of ClientRequest object</param>
 public async Task <ClientResponse <T> > InvokeAsync <T>(string resource, ClientRequestMethod method, object body = null)
 {
     return(await InvokeAsync <T>(new ClientRequest()
     {
         Resource = resource,
         Method = method,
         Body = body
     }));
 }
        private async Task <ClientResponse <T> > SendRequestAsync <T>(
            string apiMethod,
            IDictionary <string, string> properties,
            bool isHttps = false,
            ClientRequestMethod httpMethod = ClientRequestMethod.Get,
            string responseType            = "json")
        {
            var client      = new HttpClient();
            var url         = $"http{(isHttps ? "s" : "")}{ENDPOINT_URL}";
            var queryString = BuildQueryString(apiMethod, httpMethod.ToString().ToUpper(), responseType, properties);

            switch (httpMethod.ToString().ToUpper())
            {
            case "GET":
                url += $"?{queryString}";
                var responseGet = await client.GetAsync(new Uri(url)).ConfigureAwait(false);

                var getContent = await responseGet.Content.ReadAsStringAsync().ConfigureAwait(false);

                if (responseGet.IsSuccessStatusCode)
                {
                    return(JsonConvert.DeserializeObject <ClientResponse <T> >(getContent));
                }
                else
                {
                    throw new TeamCowboyRequestException($"Method failed {apiMethod}\r\n{getContent}");
                }

            case "POST":
                var responsePost = await client.PostAsync(new Uri(url), new StringContent(queryString, Encoding.UTF8, "application/x-www-form-urlencoded")).ConfigureAwait(false);

                var postContent = await responsePost.Content.ReadAsStringAsync().ConfigureAwait(false);

                if (responsePost.IsSuccessStatusCode)
                {
                    return(JsonConvert.DeserializeObject <ClientResponse <T> >(postContent));
                }
                else
                {
                    throw new TeamCowboyRequestException($"Method failed {apiMethod}\r\n{postContent}");
                }

            default:
                throw new TeamCowboyRequestException($"Invalid HTTP method {httpMethod} for {apiMethod}");
            }
        }