private string ConvertResponsefieldsToString(HyvesEventResponsefield responsefields) { StringBuilder responsefieldsBuilder = new StringBuilder(); if (responsefields == HyvesEventResponsefield.All) { responsefieldsBuilder.Append(EnumHelper.GetAllValuesAsString <HyvesEventResponsefield>()); } else { var responsefieldsValues = Enum.GetValues(typeof(HyvesEventResponsefield)); foreach (HyvesEventResponsefield responseField in responsefieldsValues) { if (EnumHelper.HasFlag(responsefields, responseField)) { responsefieldsBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(responseField))); } } } responsefieldsBuilder = responsefieldsBuilder.Replace( string.Format("{0},", EnumHelper.GetDescription(HyvesEventResponsefield.All)), string.Empty); string returnValue = responsefieldsBuilder.ToString(); return(returnValue.Substring(0, returnValue.Length - 1)); }
/// <summary> /// Gets the desired information about the specified event. This corresponds to the /// events.get Hyves method. /// </summary> /// <param name="eventIds">The requested eventIds.</param> /// <param name="responsefields">Get extra information from the requested event.</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 specified event; null if the call fails.</returns> public Collection<Event> GetEvents(Collection<string> eventIds, HyvesEventResponsefield responsefields, bool useFancyLayout) { if (eventIds == null || eventIds.Count == 0) { throw new ArgumentException("eventIds"); } StringBuilder eventIdBuilder = new StringBuilder(); if (eventIds != null) { foreach (string id in eventIds) { if (eventIdBuilder.Length != 0) { eventIdBuilder.Append(","); } eventIdBuilder.Append(id); } } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["eventid"] = eventIdBuilder.ToString(); request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields); HyvesResponse response = request.InvokeMethod(HyvesMethod.EventsGet, useFancyLayout); if (response.Status == HyvesResponseStatus.Succeeded) { return response.ProcessResponse<Event>("event"); } return null; }
/// <summary> /// Gets the desired events from the loggedin user. This corresponds to the /// events.getByLoggedin Hyves method. /// </summary> /// <param name="inFuture">Select only events in the future.</param> /// <param name="responsefields">Get extra information from the requested event.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <param name="page">The requested page.</param> /// <param name="resultsPerPage">The number of results per page.</param> /// <returns>The information about the specified event; null if the call fails.</returns> public Collection <Event> GetEventsByLoggedin(bool inFuture, HyvesEventResponsefield responsefields, bool useFancyLayout, int page, int resultsPerPage) { HyvesRequest request = new HyvesRequest(this.session); request.Parameters["infuture"] = inFuture.ToString(); request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields); HyvesResponse response = request.InvokeMethod(HyvesMethod.EventsGetByLoggedin, useFancyLayout, page, resultsPerPage); if (response.Status == HyvesResponseStatus.Succeeded) { return(response.ProcessResponse <Event>("event")); } return(null); }
/// <summary> /// Gets the desired events from the specified user. This corresponds to the /// events.getByUser Hyves method. /// </summary> /// <param name="userId">The requested user Id.</param> /// <param name="responsefields">Get extra information from the requested event.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <param name="page">The requested page.</param> /// <param name="resultsPerPage">The number of results per page.</param> /// <returns>The information about the specified event; null if the call fails.</returns> public Collection <Event> GetEventsByUserPresent(string userId, HyvesEventResponsefield responsefields, bool useFancyLayout, int page, int resultsPerPage) { if (string.IsNullOrEmpty(userId)) { throw new ArgumentNullException("userId"); } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["userid"] = userId; request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields); HyvesResponse response = request.InvokeMethod(HyvesMethod.EventsGetByUserPresent, useFancyLayout, page, resultsPerPage); if (response.Status == HyvesResponseStatus.Succeeded) { return(response.ProcessResponse <Event>("event")); } return(null); }
/// <summary> /// Gets the desired information about the specified event. This corresponds to the /// events.get Hyves method. /// </summary> /// <param name="eventIds">The requested eventIds.</param> /// <param name="responsefields">Get extra information from the requested event.</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 specified event; null if the call fails.</returns> public Collection <Event> GetEvents(Collection <string> eventIds, HyvesEventResponsefield responsefields, bool useFancyLayout) { if (eventIds == null || eventIds.Count == 0) { throw new ArgumentException("eventIds"); } StringBuilder eventIdBuilder = new StringBuilder(); if (eventIds != null) { foreach (string id in eventIds) { if (eventIdBuilder.Length != 0) { eventIdBuilder.Append(","); } eventIdBuilder.Append(id); } } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["eventid"] = eventIdBuilder.ToString(); request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields); HyvesResponse response = request.InvokeMethod(HyvesMethod.EventsGet, useFancyLayout); if (response.Status == HyvesResponseStatus.Succeeded) { return(response.ProcessResponse <Event>("event")); } return(null); }
/// <summary> /// Gets the desired events from the specified user. This corresponds to the /// events.getByUser Hyves method. /// </summary> /// <param name="userId">The requested user Id.</param> /// <param name="responsefields">Get extra information from the requested event.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <param name="page">The requested page.</param> /// <param name="resultsPerPage">The number of results per page.</param> /// <returns>The information about the specified event; null if the call fails.</returns> public Collection<Event> GetEventsByUserPresent(string userId, HyvesEventResponsefield responsefields, bool useFancyLayout, int page, int resultsPerPage) { if (string.IsNullOrEmpty(userId)) { throw new ArgumentNullException("userId"); } HyvesRequest request = new HyvesRequest(this.session); request.Parameters["userid"] = userId; request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields); HyvesResponse response = request.InvokeMethod(HyvesMethod.EventsGetByUserPresent, useFancyLayout, page, resultsPerPage); if (response.Status == HyvesResponseStatus.Succeeded) { return response.ProcessResponse<Event>("event"); } return null; }
private string ConvertResponsefieldsToString(HyvesEventResponsefield responsefields) { StringBuilder responsefieldsBuilder = new StringBuilder(); if (responsefields == HyvesEventResponsefield.All) { responsefieldsBuilder.Append(EnumHelper.GetAllValuesAsString<HyvesEventResponsefield>()); } else { var responsefieldsValues = Enum.GetValues(typeof(HyvesEventResponsefield)); foreach (HyvesEventResponsefield responseField in responsefieldsValues) { if (EnumHelper.HasFlag(responsefields, responseField)) { responsefieldsBuilder.Append(string.Format("{0},", EnumHelper.GetDescription(responseField))); } } } responsefieldsBuilder = responsefieldsBuilder.Replace( string.Format("{0},", EnumHelper.GetDescription(HyvesEventResponsefield.All)), string.Empty); string returnValue = responsefieldsBuilder.ToString(); return returnValue.Substring(0, returnValue.Length - 1); }
/// <summary> /// Gets the desired events from the loggedin user. This corresponds to the /// events.getByLoggedin Hyves method. /// </summary> /// <param name="inFuture">Select only events in the future.</param> /// <param name="responsefields">Get extra information from the requested event.</param> /// <param name="useFancyLayout">Display information the same way that that is being done on the site, including things like smilies.</param> /// <param name="page">The requested page.</param> /// <param name="resultsPerPage">The number of results per page.</param> /// <returns>The information about the specified event; null if the call fails.</returns> public Collection<Event> GetEventsByLoggedin(bool inFuture, HyvesEventResponsefield responsefields, bool useFancyLayout, int page, int resultsPerPage) { HyvesRequest request = new HyvesRequest(this.session); request.Parameters["infuture"] = inFuture.ToString(); request.Parameters["ha_responsefields"] = ConvertResponsefieldsToString(responsefields); HyvesResponse response = request.InvokeMethod(HyvesMethod.EventsGetByLoggedin, useFancyLayout, page, resultsPerPage); if (response.Status == HyvesResponseStatus.Succeeded) { return response.ProcessResponse<Event>("event"); } return null; }