Skip to content

Commit

Permalink
Merge pull request #272 from Promact/removeSlackChannelDependency
Browse files Browse the repository at this point in the history
Removed slack channel dependency and added commands to link slack channel to OAuth project
  • Loading branch information
Ankit Bhanvadia committed Mar 14, 2017
2 parents bd3e6e3 + 167b2ba commit b0c1fa0
Show file tree
Hide file tree
Showing 26 changed files with 1,749 additions and 726 deletions.
Expand Up @@ -7,7 +7,6 @@ namespace Promact.Core.Repository.OauthCallsRepository
{
public interface IOauthCallsRepository
{

/// <summary>
/// Method to call an api from project oAuth server and get Employee detail by their slack userId. - SS
/// </summary>
Expand All @@ -32,24 +31,15 @@ public interface IOauthCallsRepository
/// <param name="accessToken">user's access token from Promact OAuth Server</param>
/// <returns>management details.List of object of User</returns>
Task<List<User>> GetManagementUserNameAsync(string accessToken);


/// <summary>
/// Method to call an api from project oAuth server and get Project details of the given group - JJ
/// </summary>
/// <param name="channelName">slack channel name</param>
/// <param name="accessToken">user's access token from Promact OAuth Server</param>
/// <returns>object of ProjectAc</returns>
Task<ProjectAc> GetProjectDetailsAsync(string channelName, string accessToken);


/// <summary>
/// This method is used to fetch list of users/employees of the given group name. - JJ
/// Method to call an api from project oAuth server and get Project details of the project id - JJ
/// </summary>
/// <param name="channelName">slack channel name</param>
/// <param name="projectId">Id of OAuth Project</param>
/// <param name="accessToken">user's access token from Promact OAuth Server</param>
/// <returns>list of object of User</returns>
Task<List<User>> GetUsersByChannelNameAsync(string channelName, string accessToken);
/// <returns>object of ProjectAc</returns>
Task<ProjectAc> GetProjectDetailsAsync(int projectId, string accessToken);


/// <summary>
Expand All @@ -69,6 +59,7 @@ public interface IOauthCallsRepository
/// <returns>true if user has admin role else false</returns>
Task<bool> UserIsAdminAsync(string userId, string accessToken);


/// <summary>
/// Method to get list of projects from oauth-server for an user
/// </summary>
Expand All @@ -77,12 +68,14 @@ public interface IOauthCallsRepository
/// <returns>list of project</returns>
Task<List<ProjectAc>> GetListOfProjectsEnrollmentOfUserByUserIdAsync(string userId, string accessToken);


/// <summary>
/// Method to get list of team member by project Id
/// </summary>
/// <param name="projectId">project Id</param>
/// <param name="accessToken">access token</param>
/// <returns>list of team members</returns>
Task<List<User>> GetAllTeamMemberByProjectIdAsync(int projectId, string accessToken);

}
}
Expand Up @@ -87,41 +87,22 @@ public async Task<List<User>> GetManagementUserNameAsync(string accessToken)


/// <summary>
/// Method to call an api from project oAuth server and get Project details of the given channel. - JJ
/// Method to call an api from project oAuth server and get Project details of the given project id. - JJ
/// </summary>
/// <param name="channelName">slack channel name</param>
/// <param name="projectId">Id of OAuth Project</param>
/// <returns>object of ProjectAc</returns>
public async Task<ProjectAc> GetProjectDetailsAsync(string channelName, string accessToken)
public async Task<ProjectAc> GetProjectDetailsAsync(int projectId, string accessToken)
{
var requestUrl = channelName;
var response = await _httpClientService.GetAsync(_stringConstant.ProjectUrl, requestUrl, accessToken);
string requestUrl = string.Format(_stringConstant.FirstAndSecondIndexStringFormat, _stringConstant.ProjectDetailUrl, projectId.ToString());
string response = await _httpClientService.GetAsync(_stringConstant.ProjectUrl, requestUrl, accessToken);
ProjectAc project = new ProjectAc();
if (!string.IsNullOrEmpty(response))
{
project = JsonConvert.DeserializeObject<ProjectAc>(response);
}
return project;
}


/// <summary>
/// This method is used to fetch list of users/employees of the given channel name from OAuth server. - JJ
/// </summary>
/// <param name="channelName">slack channel name</param>
/// <param name="accessToken">user's access token from Promact OAuth Server</param>
/// <returns>list of object of User</returns>
public async Task<List<User>> GetUsersByChannelNameAsync(string channelName, string accessToken)
{
string requestUrl = string.Format(_stringConstant.FirstAndSecondIndexStringFormat, _stringConstant.UsersDetailByChannelNameUrl, channelName);
string response = await _httpClientService.GetAsync(_stringConstant.UserUrl, requestUrl, accessToken);
List<User> users = new List<User>();
if (!string.IsNullOrEmpty(response))
{
users = JsonConvert.DeserializeObject<List<User>>(response);
}
return users;
}



/// <summary>
/// Method to call an api of oAuth server and get Casual leave allowed to user by user slackName. - SS
Expand Down Expand Up @@ -171,7 +152,7 @@ public async Task<List<ProjectAc>> GetListOfProjectsEnrollmentOfUserByUserIdAsyn
List<ProjectAc> projects = new List<ProjectAc>();
var requestUrl = string.Format(_stringConstant.FirstAndSecondIndexStringFormat, _stringConstant.DetailsAndSlashForUrl, userId);
var response = await _httpClientService.GetAsync(_stringConstant.ProjectUrl, requestUrl, accessToken);
if(response != null)
if (response != null)
{
projects = JsonConvert.DeserializeObject<List<ProjectAc>>(response);
}
Expand All @@ -195,6 +176,8 @@ public async Task<List<User>> GetAllTeamMemberByProjectIdAsync(int projectId, st
}
return teamMembers;
}


#endregion
}
}
Expand Up @@ -180,6 +180,8 @@
<Compile Include="ScrumReportRepository\ScrumReportRepository.cs" />
<Compile Include="ScrumRepository\IScrumBotRepository.cs" />
<Compile Include="ScrumRepository\ScrumBotRepository.cs" />
<Compile Include="ScrumSetUpRepository\IScrumSetUpRepository.cs" />
<Compile Include="ScrumSetUpRepository\ScrumSetUpRepository.cs" />
<Compile Include="ServiceRepository\IServiceRepository.cs" />
<Compile Include="ServiceRepository\ServiceRepository.cs" />
<Compile Include="SlackChannelRepository\ISlackChannelRepository.cs" />
Expand Down
Expand Up @@ -57,7 +57,7 @@ private async Task<IList<EmployeeScrumDetails>> GetEmployeeScrumDetailsAsync(Pro
}
else
{
foreach (var user in project.ApplicationUsers)
foreach (var user in project.Users)
{
EmployeeScrumDetails employeeScrumDetail = await AssignAnswersAsync(scrum, scrumDate, user);
employeeScrumDetails.Add(employeeScrumDetail);
Expand Down

0 comments on commit b0c1fa0

Please sign in to comment.