private string ConvertResponsefieldsToString(HyvesAlbumResponsefield responsefields) { StringBuilder responsefieldsBuilder = new StringBuilder(); if (responsefields == HyvesAlbumResponsefield.All) { responsefieldsBuilder.Append(EnumHelper.GetAllValuesAsString <HyvesAlbumResponsefield>()); } else { var userResponsefields = Enum.GetValues(typeof(HyvesAlbumResponsefield)); foreach (HyvesAlbumResponsefield responseField in userResponsefields) { if (EnumHelper.HasFlag(responsefields, responseField)) { responsefieldsBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(responseField))); } } } responsefieldsBuilder = responsefieldsBuilder.Replace( string.Format("{0},", EnumHelper.GetDescription(HyvesAlbumResponsefield.All)), string.Empty); string returnValue = responsefieldsBuilder.ToString(); return(returnValue.Substring(0, returnValue.Length - 1)); }
/// <summary> /// Gets the builtin albums from a user. This corresponds to the albums.getBuiltin Hyves method. /// </summary> /// <param name="visibility">The visibility of the albums.</param> /// <param name="responsefields">Get extra information from the requested album.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <returns>The information about the desired albums; null if the call fails.</returns> public Collection <Album> GetBuiltinAlbums(HyvesVisibility visibility, HyvesAlbumResponsefield responseFields, bool useFancyLayout) { HyvesRequest request = new HyvesRequest(this.session); request.Parameters["visibility"] = EnumHelper.GetDescription(visibility); request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responseFields); HyvesResponse response = request.InvokeMethod(HyvesMethod.AlbumsGetBuiltin, useFancyLayout); if (response.Status == HyvesResponseStatus.Succeeded) { return(response.ProcessResponse <Album>("album")); } return(null); }
/// <summary> /// Gets the desired albums from the specified albums. This corresponds to the albums.get Hyves method. /// </summary> /// <param name="albumId">The requested album ID.</param> /// <param name="responsefields">Get extra information from the requested album.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <returns>The information about the desired albums; null if the call fails.</returns> public Collection<Album> GetAlbums(string albumId, HyvesAlbumResponsefield responseFields, bool useFancyLayout) { if (string.IsNullOrEmpty(albumId)) { throw new ArgumentException("userId"); } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["albumid"] = albumId; request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responseFields); HyvesResponse response = request.InvokeMethod(HyvesMethod.AlbumsGet, useFancyLayout); if (response.Status == HyvesResponseStatus.Succeeded) { return response.ProcessResponse<Album>("album"); } return null; }
/// <summary> /// Gets the desired albums from the specified albums. This corresponds to the albums.get Hyves method. /// </summary> /// <param name="albumId">The requested album ID.</param> /// <param name="responsefields">Get extra information from the requested album.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <returns>The information about the desired albums; null if the call fails.</returns> public Collection <Album> GetAlbums(string albumId, HyvesAlbumResponsefield responseFields, bool useFancyLayout) { if (string.IsNullOrEmpty(albumId)) { throw new ArgumentException("userId"); } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["albumid"] = albumId; request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responseFields); HyvesResponse response = request.InvokeMethod(HyvesMethod.AlbumsGet, useFancyLayout); if (response.Status == HyvesResponseStatus.Succeeded) { return(response.ProcessResponse <Album>("album")); } return(null); }
/// <summary> /// Creates a new album. This corresponds to the /// albums.create Hyves method. /// </summary> /// <param name="title">Title of the album. </param> /// <param name="visibility">The visibility of the album.</param> /// <param name="printability">The printability of the album.</param> /// <param name="responseFields">Get extra information from the created album.</param> /// <returns>True if the call succeeds, false if the call fails.</returns> public bool CreateAlbum(string title, HyvesVisibility visibility, HyvesVisibility printability, HyvesAlbumResponsefield responseFields) { if (string.IsNullOrEmpty(title)) { throw new ArgumentNullException("title"); } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["title"] = title; request.Parameters["visibility"] = EnumHelper.GetDescription(visibility); request.Parameters["printability"] = EnumHelper.GetDescription(printability); request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responseFields); HyvesResponse response = request.InvokeMethod(HyvesMethod.AlbumsCreate); return(response.Status == HyvesResponseStatus.Succeeded); }
private string ConvertResponsefieldsToString(HyvesAlbumResponsefield responsefields) { StringBuilder responsefieldsBuilder = new StringBuilder(); if (responsefields == HyvesAlbumResponsefield.All) { responsefieldsBuilder.Append(EnumHelper.GetAllValuesAsString<HyvesAlbumResponsefield>()); } else { var userResponsefields = Enum.GetValues(typeof(HyvesAlbumResponsefield)); foreach (HyvesAlbumResponsefield responseField in userResponsefields) { if (EnumHelper.HasFlag(responsefields, responseField)) { responsefieldsBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(responseField))); } } } responsefieldsBuilder = responsefieldsBuilder.Replace( string.Format("{0},", EnumHelper.GetDescription(HyvesAlbumResponsefield.All)), string.Empty); string returnValue = responsefieldsBuilder.ToString(); return returnValue.Substring(0, returnValue.Length - 1); }
/// <summary> /// Creates a new album. This corresponds to the /// albums.create Hyves method. /// </summary> /// <param name="title">Title of the album. </param> /// <param name="visibility">The visibility of the album.</param> /// <param name="printability">The printability of the album.</param> /// <param name="responseFields">Get extra information from the created album.</param> /// <returns>True if the call succeeds, false if the call fails.</returns> public bool CreateAlbum(string title, HyvesVisibility visibility, HyvesVisibility printability, HyvesAlbumResponsefield responseFields) { if (string.IsNullOrEmpty(title)) { throw new ArgumentNullException("title"); } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["title"] = title; request.Parameters["visibility"] = EnumHelper.GetDescription(visibility); request.Parameters["printability"] = EnumHelper.GetDescription(printability); request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responseFields); HyvesResponse response = request.InvokeMethod(HyvesMethod.AlbumsCreate); return response.Status == HyvesResponseStatus.Succeeded; }
/// <summary> /// Gets the builtin albums from a user. This corresponds to the albums.getBuiltin Hyves method. /// </summary> /// <param name="visibility">The visibility of the albums.</param> /// <param name="responsefields">Get extra information from the requested album.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <returns>The information about the desired albums; null if the call fails.</returns> public Collection<Album> GetBuiltinAlbums(HyvesVisibility visibility, HyvesAlbumResponsefield responseFields, bool useFancyLayout) { HyvesRequest request = new HyvesRequest(this.session); request.Parameters["visibility"] = EnumHelper.GetDescription(visibility); request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responseFields); HyvesResponse response = request.InvokeMethod(HyvesMethod.AlbumsGetBuiltin, useFancyLayout); if (response.Status == HyvesResponseStatus.Succeeded) { return response.ProcessResponse<Album>("album"); } return null; }