Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hipchat-client): expose ViewPrivateChatHistory on IHipchatClient interface #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Api/HipchatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -951,11 +951,11 @@ public bool UpdatePhoto(string idOrEmail, string photo)


#region ViewPrivateChatHistory
public HipchatViewRoomHistoryResponse ViewPrivateChatHistory(string user, string date = "recent", string timezone = "UTC", int startIndex = 0, int maxResults = 100, bool reverse = true)
public HipchatViewRoomHistoryResponse ViewPrivateChatHistory(string username, string date = "recent", string timezone = "UTC", int startIndex = 0, int maxResults = 100, bool reverse = true)
{
using (JsonSerializerConfigScope())
{
if (user.IsEmpty() || user.Length > 100)
if (username.IsEmpty() || username.Length > 100)
throw new ArgumentOutOfRangeException("user", "Valid roomName length is 1-100.");
if (date.IsEmpty())
throw new ArgumentOutOfRangeException("date", "Valid date should be passed.");
Expand All @@ -968,7 +968,7 @@ public HipchatViewRoomHistoryResponse ViewPrivateChatHistory(string user, string

try
{
return HipchatEndpoints.ViewPrivateChatHistoryEndpoint.Fmt(user)
return HipchatEndpoints.ViewPrivateChatHistoryEndpoint.Fmt(username)
.AddQueryParam("date", date)
.AddQueryParam("timezone", timezone)
.AddQueryParam("start-index", startIndex)
Expand Down
29 changes: 29 additions & 0 deletions src/Api/IHipchatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,5 +473,34 @@ bool SendNotification(string roomName, string message, RoomColors backgroundColo
/// https://www.hipchat.com/docs/apiv2/method/update_photo
/// </remarks>
bool UpdatePhoto(string idOrEmail, string photo);

/// <summary>
/// Fetch the history of a private chat
/// </summary>
/// <param name="username">The username.</param>
/// <param name="date">Either the latest date to fetch history for in ISO-8601 format, or 'recent' to fetch the latest 75 messages. Note, paging isn't supported for 'recent', however they are real-time values, whereas date queries may not include the most recent messages.</param>
/// <param name="timezone">Your timezone. Must be a supported timezone name, please see wikipedia TZ database page.</param>
/// <param name="startIndex">The start index for the result set</param>
/// <param name="maxResults">The maximum number of results. Valid length 0-100</param>
/// <param name="reverse">Reverse the output such that the oldest message is first. For consistent paging, set to <c>false</c>.</param>
/// <returns>
/// A HipchatGetAllRoomsResponse
/// </returns>
/// <exception cref="System.ArgumentOutOfRangeException">
/// roomName;Valid username length is 1-100.
/// or
/// date;Valid date should be passed.
/// or
/// timezone;Valid timezone should be passed.
/// or
/// startIndex;startIndex must be between 0 and 100
/// or
/// maxResults;maxResults must be between 0 and 1000
/// </exception>
/// <remarks>
/// Authentication required, with scope view_group, view_messages. https://www.hipchat.com/docs/apiv2/method/get_privatechat_message
/// </remarks>
HipchatViewRoomHistoryResponse ViewPrivateChatHistory(string username, string date = "recent", string timezone = "UTC", int startIndex = 0, int maxResults = 100, bool reverse = true);

}
}