Beispiel #1
0
        public ResponseEnvelope <TwitchPingResponse> Response(PingarResponse response)
        {
            var envelope = new ResponseEnvelope <TwitchPingResponse>();

            envelope.HttpStatusCode = (HttpStatusCode)response.HttpStatusCode;

            if (envelope.Success)
            {
                envelope.Item = PingResponse(response.Item);
            }
            else
            {
                envelope.Error.Messages.Add(response.Erro);
            }

            return(envelope);
        }
        public override Task <PingarResponse> Pingar(PingarRequest request, ServerCallContext context)
        {
            var response = new PingarResponse();

            try
            {
                var empresaId = Guid.Parse(request.EmpresaId);

                var envelope = pingService.Pingar(request.TwitchUserId, request.ChannelId, request.IsUnlinked, request.PingKeyHeader, request.PingPausaHeader, empresaId);

                var parser = new parsers.Ping();

                response.Item = parser.Response(envelope);

                response.HttpStatusCode = (int)HttpStatusCode.OK;
            }
            catch (Exception ex)
            {
                response.HttpStatusCode = (int)HttpStatusCode.InternalServerError;
                response.Erro           = ex.Message;
            }

            return(Task.FromResult(response));
        }