/// <summary> /// Retrieves list of user photos by album id. /// </summary> /// <param name="albumId">Albums Id for photos.</param> /// <param name="pageSize">Number of records to retrieve per page.</param> /// <param name="maxPages">Upper limit of pages to return.</param> /// <param name="fields">Custom list of Photo fields to retrieve.</param> /// <returns>List of User Photos.</returns> public async Task <IncrementalLoadingCollection <FacebookRequestSource <FacebookPhoto>, FacebookPhoto> > GetUserPhotosByAlbumIdAsync(string albumId, int pageSize, int maxPages, string fields = null) { fields = fields ?? FacebookPhoto.Fields; var config = new FacebookDataConfig { Query = $"/{albumId}/photos" }; return(await RequestAsync <FacebookPhoto>(config, pageSize, maxPages, fields)); }
/// <summary> /// Retrieves list of user photo albums. /// </summary> /// <param name="pageSize">Number of records to retrieve per page.</param> /// <param name="maxPages">Upper limit of pages to return.</param> /// <param name="fields">Custom list of Album fields to retrieve.</param> /// <returns>List of User Photo Albums.</returns> public async Task <IncrementalLoadingCollection <FacebookRequestSource <FacebookAlbum>, FacebookAlbum> > GetUserAlbumsAsync(int pageSize, int maxPages, string fields = null) { fields = fields ?? FacebookAlbum.Fields; var config = new FacebookDataConfig { Query = "/me/albums" }; return(await RequestAsync <FacebookAlbum>(config, pageSize, maxPages, fields)); }
/// <summary> /// Retrieves list of user photos by album id. /// </summary> /// <param name="albumId">Albums Id for photos.</param> /// <param name="maxRecords">Upper limit of records to return</param> /// <param name="fields">Custom list of Photo fields to retrieve.</param> /// <returns>List of User Photos.</returns> public async Task <List <FacebookPhoto> > GetUserPhotosByAlbumIdAsync(string albumId, int maxRecords = 20, string fields = null) { fields = fields ?? FacebookPhoto.Fields; var config = new FacebookDataConfig { Query = $"/{albumId}/photos" }; return(await RequestAsync <FacebookPhoto>(config, maxRecords, fields)); }
/// <summary> /// Retrieves list of user photo albums. /// </summary> /// <param name="maxRecords">Upper limit of records to return.</param> /// <param name="fields">Custom list of Album fields to retrieve.</param> /// <returns>List of User Photo Albums.</returns> public async Task <List <FacebookAlbum> > GetUserAlbumsAsync(int maxRecords = 20, string fields = null) { fields = fields ?? FacebookAlbum.Fields; var config = new FacebookDataConfig { Query = "/me/albums" }; return(await RequestAsync <FacebookAlbum>(config, maxRecords, fields)); }
/// <summary> /// Initializes a new instance of the <see cref="FacebookRequestSource{T}"/> class. /// </summary> /// <param name="config">Config containing query information.</param> /// <param name="fields">Comma-separated list of properties expected in the JSON response. Accompanying properties must be found on the strong-typed T.</param> /// <param name="limit">A string representation of the number of records for page - i.e. pageSize.</param> /// <param name="maxPages">Upper limit of pages to return.</param> public FacebookRequestSource(FacebookDataConfig config, string fields, string limit, int maxPages) { _config = config; _fields = fields; _limit = limit; _maxPages = maxPages; _propertySet = new PropertySet { { "fields", _fields }, { "limit", _limit } }; _factory = new FBJsonClassFactory(s => JsonConvert.DeserializeObject(s, typeof(T))); // FBPaginatedArray does not allow us to set page size per request so we must go with first supplied - see https://github.com/Microsoft/winsdkfb/issues/221 _paginatedArray = new FBPaginatedArray(_config.Query, _propertySet, _factory); }
/// <summary> /// Request list data from service provider based upon a given config / query. /// </summary> /// <typeparam name="T">Strong type of model.</typeparam> /// <param name="config">FacebookDataConfig instance.</param> /// <param name="maxRecords">Upper limit of records to return.</param> /// <param name="fields">A comma separated string of required fields, which will have strongly typed representation in the model passed in.</param> /// <returns>Strongly typed list of data returned from the service.</returns> public async Task <List <T> > RequestAsync <T>(FacebookDataConfig config, int maxRecords = 20, string fields = "id,message,from,created_time,link,full_picture") { if (Provider.LoggedIn) { var requestSource = new FacebookRequestSource <T>(config, fields, maxRecords.ToString(), 1); var list = await requestSource.GetPagedItemsAsync(0, maxRecords); return(new List <T>(list)); } var isLoggedIn = await LoginAsync(); if (isLoggedIn) { return(await RequestAsync <T>(config, maxRecords, fields)); } return(null); }
/// <summary> /// Request generic list data from service provider based upon a given config / query. /// </summary> /// <typeparam name="T">Strong type of model.</typeparam> /// <param name="config">FacebookDataConfig instance.</param> /// <param name="maxRecords">Upper limit of records to return.</param> /// <param name="fields">A comma seperated string of required fields, which will have strongly typed representation in the model passed in.</param> /// <returns>Strongly typed list of data returned from the service.</returns> public async Task <List <T> > RequestAsync <T>(FacebookDataConfig config, int maxRecords = 20, string fields = "id,message,from,created_time,link,full_picture") { if (Provider.LoggedIn) { var processedResults = new List <T>(); PropertySet propertySet = new PropertySet { { "fields", fields } }; var factory = new FBJsonClassFactory(s => JsonConvert.DeserializeObject(s, typeof(T))); paginatedArray = new FBPaginatedArray(config.Query, propertySet, factory); var result = await paginatedArray.FirstAsync(); if (result.Succeeded) { IReadOnlyList <object> results = (IReadOnlyList <object>)result.Object; await ProcessResultsAsync(results, maxRecords, processedResults); return(processedResults); } throw new Exception(result.ErrorInfo?.Message); } var isLoggedIn = await LoginAsync(); if (isLoggedIn) { return(await RequestAsync <T>(config, maxRecords, fields)); } return(null); }
/// <summary> /// Request generic list data from service provider based upon a given config / query. /// </summary> /// <typeparam name="T">Strong type of model.</typeparam> /// <param name="config">FacebookDataConfig instance.</param> /// <param name="pageSize">Upper limit of records to return.</param> /// <param name="maxPages">Upper limit of pages to return.</param> /// <param name="fields">A comma separated string of required fields, which will have strongly typed representation in the model passed in.</param> /// <returns>Strongly typed list of data returned from the service.</returns> public async Task <IncrementalLoadingCollection <FacebookRequestSource <T>, T> > RequestAsync <T>(FacebookDataConfig config, int pageSize, int maxPages, string fields = "id,message,from,created_time,link,full_picture") { if (Provider.LoggedIn) { var requestSource = new FacebookRequestSource <T>(config, fields, pageSize.ToString(), maxPages); return(new IncrementalLoadingCollection <FacebookRequestSource <T>, T>(requestSource)); } var isLoggedIn = await LoginAsync(); if (isLoggedIn) { return(await RequestAsync <T>(config, pageSize, maxPages, fields)); } return(null); }
/// <summary> /// Request list data from service provider based upon a given config / query. /// </summary> /// <param name="config">FacebookDataConfig instance.</param> /// <param name="pageSize">Upper limit of records to return.</param> /// <param name="maxPages">Upper limit of pages to return.</param> /// <returns>Strongly typed list of data returned from the service.</returns> public Task <IncrementalLoadingCollection <FacebookRequestSource <FacebookPost>, FacebookPost> > RequestAsync(FacebookDataConfig config, int pageSize, int maxPages) { return(RequestAsync <FacebookPost>(config, pageSize, maxPages, FacebookPost.Fields)); }
/// <summary> /// Request list data from service provider based upon a given config / query. /// </summary> /// <param name="config">FacebookDataConfig instance.</param> /// <param name="maxRecords">Upper limit of records to return.</param> /// <returns>Strongly typed list of data returned from the service.</returns> public Task <List <FacebookPost> > RequestAsync(FacebookDataConfig config, int maxRecords = 20) { return(RequestAsync <FacebookPost>(config, maxRecords, FacebookPost.Fields)); }
/// <summary> /// Request list data from service provider based upon a given config / query. /// </summary> /// <param name="config">FacebookDataConfig instance.</param> /// <param name="maxRecords">Upper limit of records to return.</param> /// <returns>Strongly typed list of data returned from the service.</returns> public async Task <List <FacebookPost> > RequestAsync(FacebookDataConfig config, int maxRecords = 20) { return(await RequestAsync <FacebookPost>(config, maxRecords)); }