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

Added self-hosted hip-chat servers #28

Open
wants to merge 3 commits 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
5 changes: 4 additions & 1 deletion src/Api/HipchatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ public class HipchatClient : IHipchatClient
/// file appSettings for 'hipchat_auth_token'
/// </summary>
/// <param name="authToken">the auth token given by hipchat</param>
public HipchatClient(string authToken = null)
/// <param name="serverName">self hosted server name, use null for hipchat.com</param>
public HipchatClient(string authToken = null, string serverName = null)
{
_authToken = authToken ?? HipchatApiConfig.AuthToken;

HipchatEndpoints.SetEndpointHost(serverName);

ConfigureSerializer();
}

Expand Down
13 changes: 10 additions & 3 deletions src/Api/HipchatEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ namespace HipchatApiV2
{
public class HipchatEndpoints
{
private static readonly string EndpointHost;
private static string EndpointHost;

private const string HipChatApi = "api.hipchat.com";

static HipchatEndpoints()
{
EndpointHost = ConfigurationManager.AppSettings["hipchat_endpoint_host"] ?? "api.hipchat.com";
EndpointHost = ConfigurationManager.AppSettings["hipchat_endpoint_host"] ?? HipChatApi;
}

public static void SetEndpointHost(string host)
{
EndpointHost = host ?? HipChatApi;
}

private HipchatEndpoints() {}
Expand All @@ -36,7 +44,6 @@ private HipchatEndpoints() {}
public static string UpdateUserEndpointFormat { get { return String.Format("https://{0}/v2/user/{{0}}", EndpointHost); } }
public static string DeleteUserEndpointFormat { get { return String.Format("https://{0}/v2/user/{{0}}", EndpointHost); } }
public static string PrivateMessageUserEnpointFormat {get { return string.Format("https://{0}/v2/user/{{0}}/message", EndpointHost); }}

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); } }
}
Expand Down