public IResponse Subscribe(LoggingSubscribeParamInclude include = LoggingSubscribeParamInclude.New, IEnumerable <LoggingEventName> filter = null, uint duration = 0, int includeTimeOffset = 0) { try { string result = _client.Get(new Uri(LoggingEndpoint.Subscribe(include, filter, duration, includeTimeOffset), UriKind.Relative)); SubscribeJson subscribeResponse = JsonConvert.DeserializeObject <SubscribeJson>(result); IResponse response = null; if (subscribeResponse.Success) { response = new LoggingSubscribeResponse(subscribeResponse.Result.Id); } else { response = Utils.ErrorResponse(result); } return(response); } catch { throw; } }
public IResponse Caps() { try { string result = _client.Get(new Uri(LoggingEndpoint.Caps(), UriKind.Relative)); CapsResponseJson capsResponse = JsonConvert.DeserializeObject <CapsResponseJson>(result); IResponse response = null; if (capsResponse.Success) { response = new LoggingCapsResponse(capsResponse.Result.Events); } else { response = Utils.ErrorResponse(result); } return(response); } catch { throw; } }
public IResponse Unsubscribe(uint id) { try { string result = _client.Get(new Uri(LoggingEndpoint.Unsubscribe(id), UriKind.Relative)); UnsubscribeJson unsubscribeResponse = JsonConvert.DeserializeObject <UnsubscribeJson>(result); IResponse response = null; if (unsubscribeResponse.Success) { response = new LoggingUnsubscribeResponse(); } else { response = Utils.ErrorResponse(result); } return(response); } catch { throw; } }
public IResponse Pull(uint id, uint timeout = 0) { try { string result = _client.Get(new Uri(LoggingEndpoint.Pull(id, timeout), UriKind.Relative)); PullResponseJson pullResponse = JsonConvert.DeserializeObject <PullResponseJson>(result); IResponse response = null; if (pullResponse.Success) { List <LoggingEventEntity> entities = new List <LoggingEventEntity>(); pullResponse.Result.Events.ForEach(x => { LoggingEventName eventName = Utils.ParseEnum <LoggingEventName>(x.Name); entities.Add(new LoggingEventEntity() { Id = x.Id, TzShift = x.TzShift, UtcTime = x.UtcTime, UpTime = x.UpTime, Event = eventName, Params = GetParams(eventName, x.Params) }); }); response = new LoggingPullResponse(entities); } else { response = Utils.ErrorResponse(result); } return(response); } catch { throw; } }