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

add view private chat history query #35

Merged
merged 1 commit into from
May 29, 2017
Merged
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
40 changes: 40 additions & 0 deletions src/Api/HipchatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -945,5 +945,45 @@ public bool UpdatePhoto(string idOrEmail, string photo)
}
}
#endregion


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

try
{
return HipchatEndpoints.ViewPrivateChatHistoryEndpoint.Fmt(user)
.AddQueryParam("date", date)
.AddQueryParam("timezone", timezone)
.AddQueryParam("start-index", startIndex)
.AddQueryParam("max-results", maxResults)
.AddQueryParam("reverse", reverse)
.AddHipchatAuthentication(_authToken)
.GetJsonFromUrl()
.FromJson<HipchatViewRoomHistoryResponse>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this object is being used now to map both ViewRoomHistory and PrivateUserHistory it should have a more generic name?

}
catch (Exception exception)
{
if (exception is WebException)
throw ExceptionHelpers.WebExceptionHelper(exception as WebException, "view_group");

throw ExceptionHelpers.GeneralExceptionHelper(exception, "ViewPrivateChatHistory");
}
}
}
#endregion
}
}
2 changes: 2 additions & 0 deletions src/Api/HipchatEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ private HipchatEndpoints() {}

public static string AddMemberEnpdointFormat { get { return String.Format("https://{0}/v2/room/{{0}}/member/{{1}}", EndpointHost); } }
public static string UpdatePhotoEnpdointFormat { get { return String.Format("https://{0}/v2/user/{{0}}/photo", EndpointHost); } }

public static string ViewPrivateChatHistoryEndpoint { get { return String.Format("https://{0}/v2/user/{{0}}/history", EndpointHost); } }
}
}