コード例 #1
0
        public async Task <AccionECP> GetAccionEcp()
        {
            string    urlBase = "https://cloud.iexapis.com/stable/stock/ec/quote?token=pk_0a497c0131984e8ba0d26422d0ea958c";
            AccionECP accion  = new AccionECP();

            await CallHttpResponse.fn_CallHttpResponse("GET", urlBase, "", "ecp", "");

            string result = MessageHttpResponse.Content;

            accion = JsonConvert.DeserializeObject <AccionECP>(MessageHttpResponse.Content);

            //MessageHttpResponse.Status
            return(accion);
        }
コード例 #2
0
        public async Task <ActionResult <AccionECPdto> > getAccionEcp()
        {
            Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            //Si el mensaje no se recibe con el usuario y token correcto, rechaza la petición
            if (await ValidateToken() == false)
            {
                return(Unauthorized());
            }

            // retorna listado
            AccionECP accion = await _service.GetAccionEcp();

            AccionECPdto accionDto = new AccionECPdto();

            accionDto.latestPrice  = accion.latestPrice;
            accionDto.latestUpdate = UnixTimeStampToDateTime(accion.latestUpdate);


            return(accionDto);
        }