Ejemplo n.º 1
0
        private static async Task <string> HttpGetFromWebApi(string url, string resultJsonStringParameterName, SetBearerTokenAction setBearerTokenAction)
        {
            string resultJsonParameterValue = "";

            using (var client = new HttpClient())
            {
                setBearerTokenAction.Invoke(client);
                var response = await client.GetAsync(url);

                var resultJson = await response.Content.ReadAsStringAsync();

                if (response.IsSuccessStatusCode)
                {
                    resultJsonParameterValue = JsonStringParser.GetValue(resultJsonStringParameterName, resultJson);
                }
                else
                {
                    throw new PinAuthenticationException(response.StatusCode.ToString()); //TODO: map from status code to the error
                    //TODO: make and use service exception
                }
            }
            return(resultJsonParameterValue);
        }
Ejemplo n.º 2
0
 private string parseJsonObject(string jsonParameterName, string jsonString) => JsonStringParser.GetValue(jsonParameterName, jsonString);