Ejemplo n.º 1
0
        public async Task <IEnumerable <CryptocurrencyDto> > GetAvailableCryptocurrencies()
        {
            // Make http request
            var apiQuery = "?fields=id,symbol,name,slug,metrics/market_data/price_usd,profile/general/overview/project_details";
            HttpResponseMessage response;

            try
            {
                response = await MessariHelper.makeHttpRequest("/v2/assets" + apiQuery);
            }
            catch (MessariException e)
            {
                throw e;
            }

            // Throw error if response was not successful
            if (!response.IsSuccessStatusCode)
            {
                throw new MessariException("Failed to get successful response from Messari api.");
            }

            // Normalize data end return
            var data = await MessariHelper.GetCryptoListFromResponse(response, availvableCryptoCurrs);

            return(data);
        }
Ejemplo n.º 2
0
        public async Task <Envelope <ExchangeDto> > GetExchanges(int pageNumber = 1)
        {
            // Make http request
            var apiQuery = $"?page={pageNumber}";
            HttpResponseMessage response;

            try
            {
                response = await MessariHelper.makeHttpRequest("/v1/markets" + apiQuery);
            }
            catch (MessariException e)
            {
                throw e;
            }

            // Throw error if response was not successful
            if (!response.IsSuccessStatusCode)
            {
                throw new MessariException("Failed to get successful response from Messari api.");
            }

            // Normalize data end return
            var data = await MessariHelper.GetExchangesFromReponse(response);//GetDataFromResponse(response);

            var env = new Envelope <ExchangeDto>
            {
                Items      = data,
                PageNumber = pageNumber
            };

            return(env);
        }
Ejemplo n.º 3
0
        public async Task <float> GetCryptocurrencyPrice(string productIdentifier)
        {
            // Make http request
            var apiQuery = "?fields=market_data/price_usd";
            HttpResponseMessage response;

            try
            {
                response = await MessariHelper.makeHttpRequest($"/v1/assets/{productIdentifier}/metrics/market-data" + apiQuery);
            }
            catch (MessariException e)
            {
                throw e;
            }

            // Throw error if response was not successful
            if (!response.IsSuccessStatusCode)
            {
                throw new MessariException("Failed to get successful response from Messari api.");
            }

            // Normalize data end return
            return(await MessariHelper.GetCryptoPriceFromResponse(response));
        }