public async Task <IResponseResult <CollectionResponseData <Application> > > GetApplicationsAsync(string accessToken, int?skip, int?limit) { IQueryString queryString = null; if (skip != null) { queryString = QueryString.Add("skip", skip.Value); } if (limit != null) { queryString = queryString == null?QueryString.Add("limit", limit.Value) : queryString.Add("limit", limit.Value); } var response = await this.ApplicationsEndpoint.PostAsync <CollectionResponse <Application> >( urlParams : new ApplicationsEndpoint.ApplicationsEndpointUrlParams().SetMembershipId(this.MembershipId).UseMongoQuery(), body : new RequestBody(), queryString : queryString, headers : HeaderCollection.Add("Authorization", $"Bearer {accessToken}")); if (response.IsSuccess) { return(new ResponseResult <CollectionResponseData <Application> >(true) { Data = response.Data.Data }); } else { return(new ResponseResult <CollectionResponseData <Application> >(false, response.Message)); } }
public async Task <IResponseResult <CollectionResponseData <EventLog> > > GetEventsAsync(string accessToken, int?skip = null, int?limit = null) { IQueryString queryString = null; if (skip != null) { queryString = QueryString.Add("skip", skip.Value); } if (limit != null) { queryString = queryString == null?QueryString.Add("limit", limit.Value) : queryString.Add("limit", limit.Value); } var response = await this.EventsEndpoint.PostAsync( urlParams : new EventsEndpoint.EventsEndpointUrlParams().SetMembershipId(this.MembershipId).UseMongoQuery(), body : new RequestBody(), queryString : queryString, headers : HeaderCollection.Add("Authorization", $"Bearer {accessToken}")); if (response.IsSuccess) { string json = response.Data.ToString(); var root = Newtonsoft.Json.JsonConvert.DeserializeObject(json); if (root is JObject rootNode) { var dataNode = rootNode["data"]; var items = dataNode?["items"]; int.TryParse(dataNode?["count"].ToString(), out int totalCount); if (items is JArray itemsArray) { List <EventLog> eventList = new List <EventLog>(); foreach (var jsonToken in itemsArray) { var eventItem = this.DeserializeEvent(jsonToken); if (eventItem != null) { eventList.Add(eventItem); } } return(new ResponseResult <CollectionResponseData <EventLog> >(true) { Data = new CollectionResponseData <EventLog> { Items = eventList, Count = totalCount } }); } } return(new ResponseResult <CollectionResponseData <EventLog> >(false, "Events coul not deserialized!")); } else { return(new ResponseResult <CollectionResponseData <EventLog> >(false, response.Message)); } }