add support for Query Follower\Following(s) ...
This commit is contained in:
@@ -144,6 +144,9 @@ namespace xIdentityService.Constants
|
||||
[StringValue("Account/Friendship/{destUser}/RejectRequest")]
|
||||
RejectRequest,
|
||||
|
||||
[StringValue("Account/Friendship/{destUser}/FriendshipInfo")]
|
||||
FriendshipInfo,
|
||||
|
||||
[StringValue("Account/Friendship/{destUser}/IsFollower")]
|
||||
IsFollower,
|
||||
|
||||
@@ -159,6 +162,12 @@ namespace xIdentityService.Constants
|
||||
[StringValue("Account/Friendship/AllFollowers")]
|
||||
AllFollowers,
|
||||
|
||||
[StringValue("Account/Friendship/FollowersList")]
|
||||
FollowersList,
|
||||
|
||||
[StringValue("Account/Friendship/QueryFollowers")]
|
||||
QueryFollowers,
|
||||
|
||||
[StringValue("Account/Friendship/{destUser}/IsFollowing")]
|
||||
IsFollowing,
|
||||
|
||||
@@ -177,11 +186,8 @@ namespace xIdentityService.Constants
|
||||
[StringValue("Account/Friendship/FollowingsList")]
|
||||
FollowingsList,
|
||||
|
||||
[StringValue("Account/Friendship/FollowersList")]
|
||||
FollowersList,
|
||||
|
||||
[StringValue("Account/Friendship/{destUser}/FriendshipInfo")]
|
||||
FriendshipInfo,
|
||||
[StringValue("Account/Friendship/QueryFollowings")]
|
||||
QueryFollowings,
|
||||
#endregion
|
||||
|
||||
//
|
||||
|
||||
@@ -217,6 +217,11 @@ namespace xIdentityService.Interfaces
|
||||
string destUser
|
||||
);
|
||||
|
||||
Task<XFriendshipInfoDto> GetFriendshipInfo(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
);
|
||||
|
||||
Task<bool> IsFollower(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
@@ -236,6 +241,13 @@ namespace xIdentityService.Interfaces
|
||||
|
||||
Task<IEnumerable<XFriendshipFollower>> GetAllFollowers(XTokenResponse tokens);
|
||||
|
||||
Task<IEnumerable<string>> GetFollowingList(XTokenResponse tokens);
|
||||
|
||||
Task<XQueryResult<XFriendDto>> QueryFollowers(
|
||||
XQuery query,
|
||||
XTokenResponse tokens
|
||||
);
|
||||
|
||||
Task<bool> IsFollowing(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
@@ -255,13 +267,11 @@ namespace xIdentityService.Interfaces
|
||||
|
||||
Task<IEnumerable<XFriendshipFollowing>> GetAllFollowings(XTokenResponse tokens);
|
||||
|
||||
Task<IEnumerable<string>> GetFollowingList(XTokenResponse tokens);
|
||||
|
||||
Task<IEnumerable<string>> GetFollowersList(XTokenResponse tokens);
|
||||
|
||||
Task<XFriendshipInfoDto> GetFriendshipInfo(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
Task<XQueryResult<XFriendDto>> QueryFollowings(
|
||||
XQuery query,
|
||||
XTokenResponse tokens
|
||||
);
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -2,14 +2,18 @@ using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using xCommons.Extensions;
|
||||
using xHttpService.Constants;
|
||||
using xHttpService.Extensions;
|
||||
using xIdentityModels.Constants;
|
||||
using xIdentityModels.Dtos;
|
||||
using xIdentityModels.Models;
|
||||
using xIdentityModels.Navigations;
|
||||
using xIdentityService.Constants;
|
||||
using xModels.Dtos;
|
||||
|
||||
namespace xIdentityService.Providers {
|
||||
public partial class XIdentityProvider {
|
||||
namespace xIdentityService.Providers
|
||||
{
|
||||
public partial class XIdentityProvider
|
||||
{
|
||||
//
|
||||
#region Friendship ...
|
||||
/// <summary>
|
||||
@@ -21,7 +25,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<XFriendshipFollowing> Follow(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -61,7 +66,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<bool> Cancel(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -101,7 +107,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task UnFollowFollower(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -140,7 +147,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task UnFollowFollowing(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -179,7 +187,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<XFriendshipFollowing> Block(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -219,7 +228,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<XFriendshipFollowing> UnBlock(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -259,7 +269,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<XFriendshipFollower> AcceptRequest(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -299,7 +310,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<XFriendshipFollower> RejectRequest(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -330,6 +342,47 @@ namespace xIdentityService.Providers {
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Friendship Info Model between Specific User and Current User
|
||||
/// </summary>
|
||||
/// <param name="tokens">Authentication Tokens</param>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipInfoDto</see></returns>
|
||||
public async Task<XFriendshipInfoDto> GetFriendshipInfo(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(tokens)
|
||||
.AddNotEmpty(
|
||||
destUser,
|
||||
tokens.AccessToken
|
||||
)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var client = GetRestClient(tokens);
|
||||
|
||||
//
|
||||
var request = GetRestRequet(
|
||||
XApiAccountEndpoint.FriendshipInfo,
|
||||
@params: new Dictionary<string, string> { { XParam.XDestUser.GetStringValue (), destUser }
|
||||
}
|
||||
);
|
||||
|
||||
//
|
||||
var response = await RunRestRequest<XFriendshipInfoDto>(
|
||||
client,
|
||||
request,
|
||||
XHttpMethod.GET
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a User IsFollower of Requested User
|
||||
/// </summary>
|
||||
@@ -339,7 +392,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<bool> IsFollower(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -379,7 +433,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<XFriendshipFollower> GetFollower(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -419,7 +474,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<XFriendshipState> GetFollowerState(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -457,7 +513,8 @@ namespace xIdentityService.Providers {
|
||||
/// <returns>a collection of <see>XFriendshipFollower</see></returns>
|
||||
public async Task<IEnumerable<XFriendshipFollower>> GetFollowers(
|
||||
XTokenResponse tokens
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -489,7 +546,8 @@ namespace xIdentityService.Providers {
|
||||
/// <returns>a collection of <see>XFriendshipFollower</see></returns>
|
||||
public async Task<IEnumerable<XFriendshipFollower>> GetAllFollowers(
|
||||
XTokenResponse tokens
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -513,6 +571,76 @@ namespace xIdentityService.Providers {
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return Followers UserName's List of Current User
|
||||
/// </summary>
|
||||
/// <param name="tokens">Authentication Tokens</param>
|
||||
/// <returns>a collection of UserNames</returns>
|
||||
public async Task<IEnumerable<string>> GetFollowersList(
|
||||
XTokenResponse tokens
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(tokens)
|
||||
.AddNotEmpty(tokens.AccessToken)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var client = GetRestClient(tokens);
|
||||
|
||||
//
|
||||
var request = GetRestRequet(XApiAccountEndpoint.FollowersList);
|
||||
|
||||
//
|
||||
var response = await RunRestRequest<IEnumerable<string>>(
|
||||
client,
|
||||
request,
|
||||
XHttpMethod.GET
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve All User's Followers based on Query Model ...
|
||||
/// </summary>
|
||||
/// <param name="query">Query Model Descriptor</param>
|
||||
/// <param name="tokens">Requester User's Descriptor</param>
|
||||
/// <returns></returns>
|
||||
public async Task<XQueryResult<XFriendDto>> QueryFollowers(
|
||||
XQuery query,
|
||||
XTokenResponse tokens
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
.GroupValidationBuilder()
|
||||
.AddNotNull(tokens)
|
||||
.AddNotEmpty(tokens.AccessToken)
|
||||
.ValidateGroupAsync();
|
||||
|
||||
//
|
||||
var client = GetRestClient(tokens);
|
||||
|
||||
//
|
||||
var request = GetRestRequet(XApiAccountEndpoint.QueryFollowers);
|
||||
|
||||
//
|
||||
// Attach XQuery to Request ...
|
||||
request = request.AttachXQuery(query);
|
||||
|
||||
//
|
||||
var response = await RunRestRequest<XQueryResult<XFriendDto>>(
|
||||
client,
|
||||
request,
|
||||
XHttpMethod.GET
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check a User is in Followings of Current User
|
||||
/// </summary>
|
||||
@@ -522,7 +650,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<bool> IsFollowing(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -562,7 +691,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<XFriendshipFollowing> GetFollowing(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -603,7 +733,8 @@ namespace xIdentityService.Providers {
|
||||
public async Task<XFriendshipState> GetFollowingState(
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -641,7 +772,8 @@ namespace xIdentityService.Providers {
|
||||
/// <returns>a collection of <see>XFriendshipFollowing</see></returns>
|
||||
public async Task<IEnumerable<XFriendshipFollowing>> GetFollowings(
|
||||
XTokenResponse tokens
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -673,7 +805,8 @@ namespace xIdentityService.Providers {
|
||||
/// <returns>a collection of <see>XFriendshipFollowing</see></returns>
|
||||
public async Task<IEnumerable<XFriendshipFollowing>> GetAllFollowings(
|
||||
XTokenResponse tokens
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -704,7 +837,8 @@ namespace xIdentityService.Providers {
|
||||
/// <returns>a collection of UserNames</returns>
|
||||
public async Task<IEnumerable<string>> GetFollowingList(
|
||||
XTokenResponse tokens
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -729,13 +863,16 @@ namespace xIdentityService.Providers {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return Followers UserName's List of Current User
|
||||
/// Retrieve All User's Followings based on Query Model ...
|
||||
/// </summary>
|
||||
/// <param name="tokens">Authentication Tokens</param>
|
||||
/// <returns>a collection of UserNames</returns>
|
||||
public async Task<IEnumerable<string>> GetFollowersList (
|
||||
/// <param name="query">Query Model Descriptor</param>
|
||||
/// <param name="tokens">Requester User's Descriptor</param>
|
||||
/// <returns></returns>
|
||||
public async Task<XQueryResult<XFriendDto>> QueryFollowings(
|
||||
XQuery query,
|
||||
XTokenResponse tokens
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
@@ -748,50 +885,14 @@ namespace xIdentityService.Providers {
|
||||
var client = GetRestClient(tokens);
|
||||
|
||||
//
|
||||
var request = GetRestRequet (XApiAccountEndpoint.FollowersList);
|
||||
var request = GetRestRequet(XApiAccountEndpoint.QueryFollowings);
|
||||
|
||||
//
|
||||
var response = await RunRestRequest<IEnumerable<string>> (
|
||||
client,
|
||||
request,
|
||||
XHttpMethod.GET
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Friendship Info Model between Specific User and Current User
|
||||
/// </summary>
|
||||
/// <param name="tokens">Authentication Tokens</param>
|
||||
/// <param name="destUser">a user identifier which represent destination user</param>
|
||||
/// <returns>an instance of <see>XFriendshipInfoDto</see></returns>
|
||||
public async Task<XFriendshipInfoDto> GetFriendshipInfo (
|
||||
XTokenResponse tokens,
|
||||
string destUser
|
||||
) {
|
||||
//
|
||||
// Validate Args ...
|
||||
await validationProvider
|
||||
.GroupValidationBuilder ()
|
||||
.AddNotNull (tokens)
|
||||
.AddNotEmpty (
|
||||
destUser,
|
||||
tokens.AccessToken
|
||||
)
|
||||
.ValidateGroupAsync ();
|
||||
// Attach XQuery to Request ...
|
||||
request = request.AttachXQuery(query);
|
||||
|
||||
//
|
||||
var client = GetRestClient (tokens);
|
||||
|
||||
//
|
||||
var request = GetRestRequet (
|
||||
XApiAccountEndpoint.FriendshipInfo,
|
||||
@params : new Dictionary<string, string> { { XParam.XDestUser.GetStringValue (), destUser }
|
||||
}
|
||||
);
|
||||
|
||||
//
|
||||
var response = await RunRestRequest<XFriendshipInfoDto> (
|
||||
var response = await RunRestRequest<XQueryResult<XFriendDto>>(
|
||||
client,
|
||||
request,
|
||||
XHttpMethod.GET
|
||||
|
||||
Reference in New Issue
Block a user